diff --git a/.github/workflows/ultramodern-workspace-gates.yml b/.github/workflows/ultramodern-workspace-gates.yml index efc7d902c..ad00c5f64 100644 --- a/.github/workflows/ultramodern-workspace-gates.yml +++ b/.github/workflows/ultramodern-workspace-gates.yml @@ -401,10 +401,12 @@ jobs: working-directory: app env: MODERN_PUBLIC_SITE_URL: https://shell-super-app.invalid + pnpm_config_workspace_concurrency: "1" ULTRAMODERN_PUBLIC_URL_ASSORTMENT: https://assortment.invalid ULTRAMODERN_PUBLIC_URL_CATALOG: https://catalog.invalid ULTRAMODERN_PUBLIC_URL_COMMERCE_CUSTOMER_CONTEXT: https://commerce-customer-context.invalid ULTRAMODERN_PUBLIC_URL_COMMERCE_MARKET_CATALOG: https://commerce-market-catalog.invalid + ULTRAMODERN_PUBLIC_URL_INVENTORY: https://inventory.invalid ULTRAMODERN_PUBLIC_URL_PARTY_REGISTRY: https://party-registry.invalid ULTRAMODERN_PUBLIC_URL_PAYMENT_TERM_CATALOG: https://payment-term-catalog.invalid ULTRAMODERN_PUBLIC_URL_PRICE_GROUP_CATALOG: https://price-group-catalog.invalid diff --git a/app/apps/shell-super-app/module-federation.config.ts b/app/apps/shell-super-app/module-federation.config.ts index 0e398ac0c..9e7f8699a 100644 --- a/app/apps/shell-super-app/module-federation.config.ts +++ b/app/apps/shell-super-app/module-federation.config.ts @@ -73,6 +73,13 @@ const moduleFederationConfig: Parameters[0] filename: 'remoteEntry.js', name: 'shellSuperApp', remotes: { + inventory: createRemoteManifestUrl({ + manifestEnv: 'VERTICAL_INVENTORY_MF_MANIFEST', + mfName: 'verticalInventory', + port: 4109, + publicUrlEnv: 'ULTRAMODERN_PUBLIC_URL_INVENTORY', + workerName: 'app-inventory', + }), partyRegistry: createRemoteManifestUrl({ manifestEnv: 'VERTICAL_PARTY_REGISTRY_MF_MANIFEST', mfName: 'verticalPartyRegistry', diff --git a/app/apps/shell-super-app/package.json b/app/apps/shell-super-app/package.json index c2224fd33..7a5f9a70c 100644 --- a/app/apps/shell-super-app/package.json +++ b/app/apps/shell-super-app/package.json @@ -27,12 +27,15 @@ }, "dependencies": { "@app/assortment": "workspace:*", + "@app/better-auth-effect-drizzle": "workspace:*", "@app/catalog": "workspace:*", "@app/commerce-customer-context": "workspace:*", "@app/commerce-market-catalog": "workspace:*", "@app/core-runtime": "workspace:*", + "@app/inventory": "workspace:*", "@app/party-registry": "workspace:*", "@app/payment-term-catalog": "workspace:*", + "@app/price-group-catalog": "workspace:*", "@app/pricing": "workspace:*", "@app/shared-contracts": "workspace:*", "@app/shared-design-tokens": "workspace:*", @@ -61,9 +64,7 @@ "i18next": "26.4.2", "jose": "6.2.5", "react": "19.2.8", - "react-dom": "19.2.8", - "@app/price-group-catalog": "workspace:*", - "@app/better-auth-effect-drizzle": "workspace:*" + "react-dom": "19.2.8" }, "devDependencies": { "@cloudflare/workers-types": "5.20260923.1", @@ -101,6 +102,7 @@ "partyRegistry": "@app/party-registry@workspace:*", "commerceMarketCatalog": "@app/commerce-market-catalog@workspace:*", "catalog": "@app/catalog@workspace:*", - "assortment": "@app/assortment@workspace:*" + "assortment": "@app/assortment@workspace:*", + "inventory": "@app/inventory@workspace:*" } } diff --git a/app/apps/shell-super-app/playwright.config.ts b/app/apps/shell-super-app/playwright.config.ts index 55cae763a..c88e9615d 100644 --- a/app/apps/shell-super-app/playwright.config.ts +++ b/app/apps/shell-super-app/playwright.config.ts @@ -72,6 +72,15 @@ export default defineConfig({ reuseExistingServer: !continuousIntegration, url: 'http://127.0.0.1:4102/party-registry-api/party-registry/readiness', }, + { + command: 'pnpm dev', + cwd: '../../verticals/inventory', + env: { + ULTRAMODERN_MF_DEV_ORIGIN: origin, + }, + reuseExistingServer: !continuousIntegration, + url: 'http://127.0.0.1:4109/inventory-api/inventory/readiness', + }, { command: 'pnpm dev', reuseExistingServer: !continuousIntegration, diff --git a/app/apps/shell-super-app/src/api/vertical-clients.ts b/app/apps/shell-super-app/src/api/vertical-clients.ts index 8cae94e88..6c9cc8d29 100644 --- a/app/apps/shell-super-app/src/api/vertical-clients.ts +++ b/app/apps/shell-super-app/src/api/vertical-clients.ts @@ -17,6 +17,8 @@ export { createPaymentTermCatalogClient, getPaymentTermCatalogReadiness } from ' export type { PaymentTermCatalogClientOptions } from '@app/payment-term-catalog/api/client'; export { createPriceGroupCatalogClient, getPriceGroupCatalogReadiness } from '@app/price-group-catalog/api/client'; export type { PriceGroupCatalogClientOptions } from '@app/price-group-catalog/api/client'; +export { createInventoryClient, getInventoryReadiness } from '@app/inventory/api/client'; +export type { InventoryClientOptions } from '@app/inventory/api/client'; export { createPricingClient, getPricingReadiness } from '@app/pricing/api/client'; export type { PricingClientOptions } from '@app/pricing/api/client'; export { createStorefrontRegistryClient, getStorefrontRegistryReadiness } from '@app/storefront-registry/api/client'; diff --git a/app/apps/shell-super-app/src/modern-app-env.d.ts b/app/apps/shell-super-app/src/modern-app-env.d.ts index 022a4ce5b..9b9fa1684 100644 --- a/app/apps/shell-super-app/src/modern-app-env.d.ts +++ b/app/apps/shell-super-app/src/modern-app-env.d.ts @@ -7,6 +7,10 @@ declare module 'catalog/Widget' { export default CatalogWidget; } +declare module 'inventory/Widget' { + export { default } from '@app/inventory/Widget'; +} + declare module 'partyRegistry/Page*' { const VerticalPage: React.FunctionComponent<{ readonly routeParams: Readonly>; diff --git a/app/apps/shell-super-app/tests/e2e/login.spec.ts b/app/apps/shell-super-app/tests/e2e/login.spec.ts index 49cf99a94..af60acfd3 100644 --- a/app/apps/shell-super-app/tests/e2e/login.spec.ts +++ b/app/apps/shell-super-app/tests/e2e/login.spec.ts @@ -492,10 +492,13 @@ test('keeps the authenticated dashboard reachable without horizontal overflow at ); await expect(page.getByRole('complementary', { name: 'Dashboard sidebar' })).toBeInViewport(); - await expect(page.locator('header[aria-label="Dashboard header"]')).toBeInViewport(); - await expect(page.getByRole('button', { name: 'E2E user' })).toBeInViewport(); await expect(page.getByRole('link', { name: 'Home' })).toBeInViewport(); + const dashboardHeader = page.locator('header[aria-label="Dashboard header"]'); + await dashboardHeader.scrollIntoViewIfNeeded(); + await expect(dashboardHeader).toBeInViewport(); + await expect(page.getByRole('button', { name: 'E2E user' })).toBeInViewport(); const tenant = page.getByRole('combobox', { name: 'Current tenant' }); + await tenant.scrollIntoViewIfNeeded(); await expect(tenant).toBeInViewport(); await tenant.click(); const secondTenant = page.getByRole('option', { diff --git a/app/apps/shell-super-app/tests/integration/module-federation-i18n-runtime.test.ts b/app/apps/shell-super-app/tests/integration/module-federation-i18n-runtime.test.ts index 6d599e541..686a635f1 100644 --- a/app/apps/shell-super-app/tests/integration/module-federation-i18n-runtime.test.ts +++ b/app/apps/shell-super-app/tests/integration/module-federation-i18n-runtime.test.ts @@ -31,6 +31,14 @@ registerHooks({ }); describe('module-federation-i18n-runtime', () => { + it.effect('registers the Inventory widget remote from the generated topology contract', () => + Effect.gen(function* registersInventoryRemote() { + const { default: shellConfig } = yield* Effect.promise(() => import(shellConfigUrl.href)); + + expect(shellConfig.remotes?.inventory).toBe('verticalInventory@http://localhost:4109/mf-manifest.json'); + }), + ); + it.effect('Shell and Party Registry share the i18n runtime that owns the federated provider context', () => Effect.gen(function* sharesFederatedI18nRuntime() { const [{ default: shellConfig }, { default: partyRegistryConfig }] = yield* Effect.promise(() => diff --git a/app/apps/shell-super-app/tests/unit/installed-verticals.test.ts b/app/apps/shell-super-app/tests/unit/installed-verticals.test.ts index 6c5fa55cc..1f899be70 100644 --- a/app/apps/shell-super-app/tests/unit/installed-verticals.test.ts +++ b/app/apps/shell-super-app/tests/unit/installed-verticals.test.ts @@ -26,6 +26,7 @@ it.effect('derives installed vertical IDs from the injected topology without har 'pricing', 'storefront-registry', 'price-group-catalog', + 'inventory', 'assortment', ]); expect(expectedInstalledIds.has('party.registry')).toBe(false); diff --git a/app/package.json b/app/package.json index c2c29f3d9..1d27d750d 100644 --- a/app/package.json +++ b/app/package.json @@ -51,15 +51,15 @@ "sandbox:new": "sh ./scripts/locki-feature.sh", "env:local:ensure": "node ./scripts/ensure-local-environment.mts", "spicedb:tls:local": "node ./scripts/local-spicedb-tls.mts", - "db:generate": "pnpm --filter @app/core-runtime db:generate && pnpm --filter @app/shell-super-app db:generate && pnpm --filter @app/party-registry db:generate && pnpm --filter @app/payment-term-catalog db:generate && pnpm --filter @app/price-group-catalog db:generate && pnpm --filter @app/commerce-customer-context db:generate && pnpm --filter @app/commerce-market-catalog db:generate && pnpm --filter @app/catalog db:generate && pnpm --filter @app/pricing db:generate && pnpm --filter @app/storefront-registry db:generate && pnpm --filter @app/assortment db:generate && pnpm db:portal-auth:generate", + "db:generate": "pnpm --filter @app/core-runtime db:generate && pnpm --filter @app/shell-super-app db:generate && pnpm --filter @app/party-registry db:generate && pnpm --filter @app/payment-term-catalog db:generate && pnpm --filter @app/price-group-catalog db:generate && pnpm --filter @app/commerce-customer-context db:generate && pnpm --filter @app/commerce-market-catalog db:generate && pnpm --filter @app/catalog db:generate && pnpm --filter @app/inventory db:generate && pnpm --filter @app/pricing db:generate && pnpm --filter @app/storefront-registry db:generate && pnpm --filter @app/assortment db:generate && pnpm db:portal-auth:generate", "db:bootstrap-runtime-role": "node ./scripts/postgres/bootstrap-runtime-role.mts", "db:portal-auth:check": "node ./scripts/run-optional-commerce-portal-auth-db.mts check", "db:portal-auth:generate": "node ./scripts/run-optional-commerce-portal-auth-db.mts generate", "db:portal-auth:migrate": "node ./scripts/run-optional-commerce-portal-auth-db.mts migrate", "db:bootstrap-spicedb": "node ./scripts/postgres/bootstrap-spicedb-database.mts", - "db:check": "pnpm --filter @app/core-runtime db:check && pnpm --filter @app/shell-super-app db:check && pnpm --filter @app/party-registry db:check && pnpm --filter @app/payment-term-catalog db:check && pnpm --filter @app/price-group-catalog db:check && pnpm --filter @app/commerce-customer-context db:check && pnpm --filter @app/commerce-market-catalog db:check && pnpm --filter @app/catalog db:check && pnpm --filter @app/assortment db:check && pnpm db:portal-auth:check", - "db:migrate": "pnpm db:bootstrap-runtime-role && pnpm --filter @app/core-runtime db:migrate && pnpm --filter @app/shell-super-app db:migrate && pnpm --filter @app/party-registry db:migrate && pnpm --filter @app/payment-term-catalog db:migrate && pnpm --filter @app/price-group-catalog db:migrate && pnpm --filter @app/commerce-customer-context db:migrate && pnpm --filter @app/commerce-market-catalog db:migrate && pnpm --filter @app/catalog db:migrate && pnpm --filter @app/pricing db:migrate && pnpm --filter @app/storefront-registry db:migrate && pnpm --filter @app/assortment db:migrate && pnpm db:bootstrap-runtime-role && pnpm db:portal-auth:migrate", - "db:test": "pnpm --filter @app/core-runtime db:test && pnpm --filter @app/shell-super-app test:integration && pnpm --filter @app/party-registry db:test && pnpm --filter @app/payment-term-catalog db:test && pnpm --filter @app/price-group-catalog db:test && pnpm --filter @app/commerce-customer-context db:test && pnpm --filter @app/commerce-market-catalog db:test && pnpm --filter @app/catalog db:test && pnpm --filter @app/assortment db:test", + "db:check": "pnpm --filter @app/core-runtime db:check && pnpm --filter @app/shell-super-app db:check && pnpm --filter @app/party-registry db:check && pnpm --filter @app/payment-term-catalog db:check && pnpm --filter @app/price-group-catalog db:check && pnpm --filter @app/commerce-customer-context db:check && pnpm --filter @app/commerce-market-catalog db:check && pnpm --filter @app/catalog db:check && pnpm --filter @app/inventory db:check && pnpm --filter @app/assortment db:check && pnpm db:portal-auth:check", + "db:migrate": "pnpm db:bootstrap-runtime-role && pnpm --filter @app/core-runtime db:migrate && pnpm --filter @app/shell-super-app db:migrate && pnpm --filter @app/party-registry db:migrate && pnpm --filter @app/payment-term-catalog db:migrate && pnpm --filter @app/price-group-catalog db:migrate && pnpm --filter @app/commerce-customer-context db:migrate && pnpm --filter @app/commerce-market-catalog db:migrate && pnpm --filter @app/catalog db:migrate && pnpm --filter @app/inventory db:migrate && pnpm --filter @app/pricing db:migrate && pnpm --filter @app/storefront-registry db:migrate && pnpm --filter @app/assortment db:migrate && pnpm db:bootstrap-runtime-role && pnpm db:portal-auth:migrate", + "db:test": "pnpm --filter @app/core-runtime db:test && pnpm --filter @app/shell-super-app test:integration && pnpm --filter @app/party-registry db:test && pnpm --filter @app/payment-term-catalog db:test && pnpm --filter @app/price-group-catalog db:test && pnpm --filter @app/commerce-customer-context db:test && pnpm --filter @app/commerce-market-catalog db:test && pnpm --filter @app/catalog db:test && pnpm --filter @app/inventory db:test && pnpm --filter @app/assortment db:test", "database-trust:audit": "node ./scripts/audit-database-trust-boundaries.mts", "db:verify": "node ./scripts/verify-application-db-schema.mts", "local:initialize": "node ./scripts/initialize-local-development.mts", @@ -118,6 +118,7 @@ "dependencies": { "@app/commerce-customer-context": "workspace:*", "@app/core-runtime": "workspace:*", + "@app/inventory": "workspace:*", "@app/party-registry": "workspace:*", "@app/price-group-catalog": "workspace:*", "@authzed/authzed-node": "1.6.1", diff --git a/app/packages/core-runtime/src/actions/runtime.ts b/app/packages/core-runtime/src/actions/runtime.ts index e39d50a88..6c7d6d5c6 100644 --- a/app/packages/core-runtime/src/actions/runtime.ts +++ b/app/packages/core-runtime/src/actions/runtime.ts @@ -21,6 +21,8 @@ import type { OperationalScope, OperationalScopeResolverService } from '../opera import { OperationalScopeResolver } from '../operations/context.ts'; import { ContextAccess, + InventoryAuthorizationResourceIdSchema, + InventoryAuthorizationResourceTypeSchema, PricingAuthorizationResourceIdSchema, isBusinessPermissionTargetCompatible, toAssortmentPermissionAccessKey, @@ -489,6 +491,15 @@ const BusinessAccessTargetSchema = Schema.Union([ pricingCatalogId: PricingAuthorizationResourceIdSchema, tenantId: BusinessTenantIdSchema, }), + Schema.Struct({ + kind: Schema.Literal('inventory_resource'), + resource: Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: InventoryAuthorizationResourceIdSchema, + resourceType: InventoryAuthorizationResourceTypeSchema, + }), + tenantId: BusinessTenantIdSchema, + }), ]); const ActionBusinessPermissionTargetSchema = Schema.Struct({ permission: BusinessPermissionCodeSchema, @@ -506,9 +517,13 @@ const businessTargetResourceId = (target: ActionBusinessPermissionTarget['target if (target.kind === 'counterparty_storefront') { return `${target.counterpartyId}:${target.storefrontId}`; } - return target.kind === 'pricing_catalog' - ? target.pricingCatalogId - : `${target.pricingCatalogId}:${target.priceGroupId}`; + if (target.kind === 'pricing_catalog') { + return target.pricingCatalogId; + } + if (target.kind === 'price_group') { + return `${target.pricingCatalogId}:${target.priceGroupId}`; + } + return target.resource.resourceId; }; const resolveActionBusinessPermissionTarget = ( @@ -547,6 +562,9 @@ const resolveActionBusinessPermissionTarget = ( resolved.trustedStorefrontId === undefined ); } + if (resolved.target.kind === 'inventory_resource') { + return resolved.trustedStorefrontId === undefined; + } return ( resolved.target.legalEntityId === scope.legalEntityId && (resolved.target.kind === 'counterparty_storefront' @@ -1249,6 +1267,14 @@ export const makeActionRuntime = (...construction: ActionRuntimeConstruction): A }> => { if (Option.isSome(businessPermissionTarget)) { const { permission: targetPermission, target } = businessPermissionTarget.value; + if (target.kind === 'inventory_resource') { + const actionTarget = { + targetModuleKey: target.resource.moduleId, + targetResourceId: target.resource.resourceId, + targetResourceType: target.resource.resourceType, + }; + return { actionTarget, governedTransport: buildGovernedTransport(transport, actionTarget) }; + } const actionTarget = { targetModuleKey: input.registration.descriptor.owningModuleKey, targetResourceId: businessTargetResourceId(target), diff --git a/app/packages/core-runtime/src/outbox/worker-entrypoint.ts b/app/packages/core-runtime/src/outbox/worker-entrypoint.ts index 0966716f3..8bf99a4ab 100644 --- a/app/packages/core-runtime/src/outbox/worker-entrypoint.ts +++ b/app/packages/core-runtime/src/outbox/worker-entrypoint.ts @@ -1,6 +1,7 @@ /** Focused server-only entrypoint used to bundle the combined Outbox Worker host and its MicroVertical entries. */ export { defineTenantModuleEntrypoint } from '../modules/module-entrypoint.ts'; export { defineScopedRoutine } from '../db/scoped-routine.ts'; +export { findPostgresFailure } from '../database/postgres-failure.ts'; export { BusinessPermissionCodeSchema, defineBusinessPermissionCatalog } from '../permissions/business-permission.ts'; export { AuthorizationMutationReconciliationUnavailable } from '../permissions/authorization-reconciler.ts'; export { diff --git a/app/packages/core-runtime/src/permissions/authorization-mutation-saga.ts b/app/packages/core-runtime/src/permissions/authorization-mutation-saga.ts index 984265b77..095b2f865 100644 --- a/app/packages/core-runtime/src/permissions/authorization-mutation-saga.ts +++ b/app/packages/core-runtime/src/permissions/authorization-mutation-saga.ts @@ -2,7 +2,11 @@ import { Effect } from 'effect'; import type { AuthorizationMutationJournalEntry, AuthorizationMutationState } from './authorization-mutation.ts'; import { canTransitionAuthorizationMutation } from './authorization-mutation.ts'; import { AuthorizationMutationSagaError } from './authorization-mutation-saga-error.ts'; -import { hasCanonicalPricingAuthorizationTargetIds, isBusinessPermissionTargetCompatible } from './context-access.ts'; +import { + hasCanonicalInventoryAuthorizationTarget, + hasCanonicalPricingAuthorizationTargetIds, + isBusinessPermissionTargetCompatible, +} from './context-access.ts'; import type { BusinessPermissionRelationshipMutationInput, BusinessPermissionRelationshipMutationService, @@ -50,6 +54,24 @@ const expectedPendingState = ( operation: AuthorizationMutationJournalEntry['operation'], ): 'PENDING_GRANT' | 'PENDING_REVOKE' => (operation === 'grant' ? 'PENDING_GRANT' : 'PENDING_REVOKE'); +type CounterpartyBusinessTarget = Extract< + AuthorizationMutationJournalEntry['businessTarget'], + { readonly kind: 'counterparty' | 'counterparty_storefront' } +>; + +const sameCounterpartyTarget = ( + left: CounterpartyBusinessTarget, + right: AuthorizationMutationJournalEntry['businessTarget'], +): boolean => + left.kind === 'counterparty' + ? right.kind === 'counterparty' && + left.legalEntityId === right.legalEntityId && + left.counterpartyId === right.counterpartyId + : right.kind === 'counterparty_storefront' && + left.legalEntityId === right.legalEntityId && + left.counterpartyId === right.counterpartyId && + left.storefrontId === right.storefrontId; + const sameBusinessTarget = ( left: AuthorizationMutationJournalEntry['businessTarget'], right: AuthorizationMutationJournalEntry['businessTarget'], @@ -57,20 +79,8 @@ const sameBusinessTarget = ( if (left.kind !== right.kind || left.tenantId !== right.tenantId) { return false; } - if (left.kind === 'counterparty') { - return ( - right.kind === 'counterparty' && - left.legalEntityId === right.legalEntityId && - left.counterpartyId === right.counterpartyId - ); - } - if (left.kind === 'counterparty_storefront') { - return ( - right.kind === 'counterparty_storefront' && - left.legalEntityId === right.legalEntityId && - left.counterpartyId === right.counterpartyId && - left.storefrontId === right.storefrontId - ); + if (left.kind === 'counterparty' || left.kind === 'counterparty_storefront') { + return sameCounterpartyTarget(left, right); } if (left.kind === 'retail_profile') { return ( @@ -82,6 +92,14 @@ const sameBusinessTarget = ( if (left.kind === 'pricing_catalog') { return right.kind === 'pricing_catalog' && left.pricingCatalogId === right.pricingCatalogId; } + if (left.kind === 'inventory_resource') { + return ( + right.kind === 'inventory_resource' && + left.resource.moduleId === right.resource.moduleId && + left.resource.resourceId === right.resource.resourceId && + left.resource.resourceType === right.resource.resourceType + ); + } return ( right.kind === 'price_group' && left.pricingCatalogId === right.pricingCatalogId && @@ -97,7 +115,8 @@ const validIntentScope = (entry: AuthorizationMutationJournalEntry): boolean => entry.principal.tenantId !== target.tenantId || target.tenantId.length === 0 || !isBusinessPermissionTargetCompatible({ permission: entry.permission, target }) || - !hasCanonicalPricingAuthorizationTargetIds(target) + !hasCanonicalPricingAuthorizationTargetIds(target) || + !hasCanonicalInventoryAuthorizationTarget(target) ) { return false; } @@ -107,6 +126,9 @@ const validIntentScope = (entry: AuthorizationMutationJournalEntry): boolean => if (target.kind === 'price_group') { return true; } + if (target.kind === 'inventory_resource') { + return true; + } if (target.legalEntityId.length === 0) { return false; } diff --git a/app/packages/core-runtime/src/permissions/business-permission-mutation.ts b/app/packages/core-runtime/src/permissions/business-permission-mutation.ts index 45aa7a9cd..8a54f1b8b 100644 --- a/app/packages/core-runtime/src/permissions/business-permission-mutation.ts +++ b/app/packages/core-runtime/src/permissions/business-permission-mutation.ts @@ -14,6 +14,7 @@ import { loadSpiceDbConfig } from './config.ts'; import type { SpiceDbConfigValue } from './config.ts'; import type { SpiceDbConfigError } from './config-error.ts'; import { + hasCanonicalInventoryAuthorizationTarget, hasCanonicalPricingAuthorizationTargetIds, isBusinessPermissionTargetCompatible, toBusinessPermissionAccessObjectId, @@ -76,6 +77,7 @@ const prepare = ( const invalidScope = !isBusinessPermissionTargetCompatible({ permission: input.permission, target: input.target }) || !hasCanonicalPricingAuthorizationTargetIds(input.target) || + !hasCanonicalInventoryAuthorizationTarget(input.target) || input.principal.tenantId !== input.target.tenantId || input.principal.principalId.length === 0 || (targetRequiresLegalEntity && input.target.legalEntityId.length === 0) || diff --git a/app/packages/core-runtime/src/permissions/business-permission.ts b/app/packages/core-runtime/src/permissions/business-permission.ts index 2840cfd4f..da1bd4904 100644 --- a/app/packages/core-runtime/src/permissions/business-permission.ts +++ b/app/packages/core-runtime/src/permissions/business-permission.ts @@ -1,7 +1,7 @@ import { Predicate, Result, Schema } from 'effect'; const dottedPermissionPattern = - /^(?:(?:retail|counterparty)(?:\.[a-z][a-z0-9_]*)+|pricing\.price_group(?:\.[a-z][a-z0-9_]*)+|assortment\.(?:binding\.(?:create|end)|boundary\.(?:create|end)|configuration\.read|decision\.explain|rule\.(?:create|revision\.create|retire)))$/u; + /^(?:(?:retail|counterparty|inventory)(?:\.[a-z][a-z0-9_]*)+|pricing\.price_group(?:\.[a-z][a-z0-9_]*)+|assortment\.(?:binding\.(?:create|end)|boundary\.(?:create|end)|configuration\.read|decision\.explain|rule\.(?:create|revision\.create|retire)))$/u; const dottedEntrypointPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\.[a-z][a-z0-9_-]*)+$/u; const schemaVersionPattern = /^[1-9][0-9]*$/u; const nonEmptyString = Schema.String.check(Schema.isMinLength(1)); @@ -19,6 +19,7 @@ export const BusinessPermissionScopeKindSchema = Schema.Literals([ 'assortment_rule', 'counterparty', 'counterparty_storefront', + 'inventory_resource', 'price_group', 'pricing_catalog', 'retail_profile', @@ -84,13 +85,17 @@ export const defineBusinessPermission = ( return invalid(`business permission ${descriptor.key} must allow at least one scope kind`); } const pricingPermission = descriptor.key.startsWith('pricing.price_group.'); + const inventoryPermission = descriptor.key.startsWith('inventory.'); const hasPricingScope = descriptor.allowedScopeKinds.some( (scope) => scope === 'pricing_catalog' || scope === 'price_group', ); + const hasInventoryScope = descriptor.allowedScopeKinds.includes('inventory_resource'); if ( (pricingPermission && descriptor.allowedScopeKinds.some((scope) => scope !== 'pricing_catalog' && scope !== 'price_group')) || - (!pricingPermission && hasPricingScope) + (!pricingPermission && hasPricingScope) || + (inventoryPermission && descriptor.allowedScopeKinds.some((scope) => scope !== 'inventory_resource')) || + (!inventoryPermission && hasInventoryScope) ) { return invalid(`business permission ${descriptor.key} uses an incompatible target scope`); } diff --git a/app/packages/core-runtime/src/permissions/context-access.ts b/app/packages/core-runtime/src/permissions/context-access.ts index 5a13bb5ce..e823f0687 100644 --- a/app/packages/core-runtime/src/permissions/context-access.ts +++ b/app/packages/core-runtime/src/permissions/context-access.ts @@ -279,6 +279,15 @@ export type BusinessAccessTarget = priceGroupId: string; pricingCatalogId: string; tenantId: string; + }> + | Readonly<{ + kind: 'inventory_resource'; + resource: Readonly<{ + moduleId: 'commerce.inventory'; + resourceId: string; + resourceType: string; + }>; + tenantId: string; }>; const canonicalPricingAuthorizationResourceId = Schema.String.check(Schema.isUUID()); @@ -289,6 +298,22 @@ export const PricingAuthorizationResourceIdSchema = canonicalPricingAuthorizatio Schema.decodeTo(canonicalPricingAuthorizationResourceId), ); +const canonicalInventoryAuthorizationResourceId = Schema.String.check(Schema.isUUID()); +const canonicalInventoryAuthorizationResourceType = Schema.String.check( + Schema.isPattern(/^commerce\.inventory\.[a-z][a-z0-9-]*$/u), +); + +/** Durable Inventory resource identity. Location/item tuples and display keys are never valid targets. */ +export const InventoryAuthorizationResourceIdSchema = canonicalInventoryAuthorizationResourceId.pipe( + Schema.brand('InventoryAuthorizationResourceId'), + Schema.decodeTo(canonicalInventoryAuthorizationResourceId), +); + +export const InventoryAuthorizationResourceTypeSchema = canonicalInventoryAuthorizationResourceType.pipe( + Schema.brand('InventoryAuthorizationResourceType'), + Schema.decodeTo(canonicalInventoryAuthorizationResourceType), +); + export interface BusinessPermissionAccessTarget { readonly permission: BusinessPermissionCode; readonly target: BusinessAccessTarget; @@ -300,6 +325,12 @@ export const hasCanonicalPricingAuthorizationTargetIds = (target: BusinessAccess : Schema.is(PricingAuthorizationResourceIdSchema)(target.pricingCatalogId) && (target.kind !== 'price_group' || Schema.is(PricingAuthorizationResourceIdSchema)(target.priceGroupId)); +export const hasCanonicalInventoryAuthorizationTarget = (target: BusinessAccessTarget): boolean => + target.kind !== 'inventory_resource' || + (target.resource.moduleId === 'commerce.inventory' && + Schema.is(InventoryAuthorizationResourceIdSchema)(target.resource.resourceId) && + Schema.is(InventoryAuthorizationResourceTypeSchema)(target.resource.resourceType)); + /** Keeps every business Permission family on its declared authorization target vocabulary. */ export const isBusinessPermissionTargetCompatible = ({ permission, @@ -311,6 +342,9 @@ export const isBusinessPermissionTargetCompatible = ({ if (permission.startsWith('retail.')) { return target.kind === 'retail_profile'; } + if (permission.startsWith('inventory.')) { + return target.kind === 'inventory_resource'; + } return ( permission.startsWith('counterparty.') && (target.kind === 'counterparty' || target.kind === 'counterparty_storefront') @@ -444,16 +478,28 @@ const businessTargetParts = (target: BusinessAccessTarget): readonly string[] => if (target.kind === 'counterparty_storefront') { return [target.tenantId, target.legalEntityId, target.kind, target.counterpartyId, target.storefrontId]; } - return target.kind === 'pricing_catalog' - ? [target.tenantId, target.kind, target.pricingCatalogId] - : [target.tenantId, target.kind, target.pricingCatalogId, target.priceGroupId]; + if (target.kind === 'pricing_catalog') { + return [target.tenantId, target.kind, target.pricingCatalogId]; + } + if (target.kind === 'price_group') { + return [target.tenantId, target.kind, target.pricingCatalogId, target.priceGroupId]; + } + return [ + target.tenantId, + target.kind, + target.resource.moduleId, + target.resource.resourceType, + target.resource.resourceId, + ]; }; export const toBusinessPermissionAccessObjectId = ( permission: BusinessPermissionCode, target: BusinessAccessTarget, ): string | undefined => - isBusinessPermissionTargetCompatible({ permission, target }) && hasCanonicalPricingAuthorizationTargetIds(target) + isBusinessPermissionTargetCompatible({ permission, target }) && + hasCanonicalPricingAuthorizationTargetIds(target) && + hasCanonicalInventoryAuthorizationTarget(target) ? encodeObjectId([permission, ...businessTargetParts(target)]) : undefined; @@ -800,7 +846,9 @@ export const makeContextAccess = (client: SpiceDbPermissionClient): ContextAcces const alternatives = targets.map((target) => { const hasTrustedTenant = target.target.tenantId === principal.tenantId; const hasCompatibleTarget = - isBusinessPermissionTargetCompatible(target) && hasCanonicalPricingAuthorizationTargetIds(target.target); + isBusinessPermissionTargetCompatible(target) && + hasCanonicalPricingAuthorizationTargetIds(target.target) && + hasCanonicalInventoryAuthorizationTarget(target.target); const hasTrustedStorefront = target.target.kind !== 'counterparty_storefront' || (trustedStorefrontId !== undefined && trustedStorefrontId === target.target.storefrontId); diff --git a/app/packages/core-runtime/src/reads/runtime.ts b/app/packages/core-runtime/src/reads/runtime.ts index 1bb4f6816..13638a4fd 100644 --- a/app/packages/core-runtime/src/reads/runtime.ts +++ b/app/packages/core-runtime/src/reads/runtime.ts @@ -18,6 +18,7 @@ import { OperationalScopeResolver } from '../operations/context.ts'; import { ContextAccess, LEGAL_ENTITY_PERMISSION_KEYS, + hasCanonicalInventoryAuthorizationTarget, hasCanonicalPricingAuthorizationTargetIds, isBusinessPermissionTargetCompatible, isAssortmentPermissionTargetValid, @@ -290,7 +291,8 @@ const businessPermissionTargetIsValid = ( !stableTargetKey(target.businessPermission.permission) || !stableTargetKey(business.tenantId) || !isBusinessPermissionTargetCompatible(target.businessPermission) || - !hasCanonicalPricingAuthorizationTargetIds(business) + !hasCanonicalPricingAuthorizationTargetIds(business) || + !hasCanonicalInventoryAuthorizationTarget(business) ) { return false; } @@ -301,6 +303,9 @@ const businessPermissionTargetIsValid = ( target.trustedStorefrontId === undefined ); } + if (business.kind === 'inventory_resource') { + return target.trustedStorefrontId === undefined; + } return ( stableTargetKey(business.legalEntityId) && (business.kind !== 'counterparty_storefront' || @@ -498,15 +503,26 @@ const readBusinessTargetResourceId = ( if (target.kind === 'counterparty_storefront') { return `${target.counterpartyId}:${target.storefrontId}`; } - return target.kind === 'pricing_catalog' - ? target.pricingCatalogId - : `${target.pricingCatalogId}:${target.priceGroupId}`; + if (target.kind === 'pricing_catalog') { + return target.pricingCatalogId; + } + if (target.kind === 'price_group') { + return `${target.pricingCatalogId}:${target.priceGroupId}`; + } + return target.resource.resourceId; }; const targetMetadata = (target: ResolvedReadPermissionTarget, scope: OperationalScope) => { const canonical = canonicalPermissionTarget(target); if (canonical.kind === 'business_permission') { const business = canonical.businessPermission.target; + if (business.kind === 'inventory_resource') { + return { + targetModuleKey: business.resource.moduleId, + targetResourceId: business.resource.resourceId, + targetResourceType: business.resource.resourceType, + }; + } return { targetModuleKey: canonical.businessPermission.permission, targetResourceId: readBusinessTargetResourceId(business), @@ -564,17 +580,23 @@ const checkBusinessPermissionTarget = ((payload) => ({ + permission, + target: { + kind: 'inventory_resource', + resource: { + moduleId: 'commerce.inventory', + resourceId: payload.resourceId, + resourceType: 'commerce.inventory.stock-position', + }, + tenantId: payload.targetTenantId, + }, + })), + domainErrorSchema: Schema.Never, + domainEvents: {}, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: 'commerce.inventory.correct-stock-position', + moduleKey: 'commerce.inventory', + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'optional', + owningModuleKey: 'commerce.inventory', + payloadSchema: InputSchema, + policies: [], + resultSchema: Schema.Void, + schemaVersion: '1', + }, + () => { + handlerCalls += 1; + return Effect.void; + }, + ); + const resourceId = '70000000-0000-4000-8000-000000000001'; + const payload = { resourceId, targetTenantId: principal.tenantId }; + const run = (harness: Effect.Success>, input = payload) => + harness.runtime.runAction({ + payload: input, + principal, + registration: action, + transport: transport('inventory-resource-target'), + }); + + const allowed = yield* makeHarness({ businessPermissionDecision: 'allowed' }); + yield* run(allowed); + expect(allowed.businessPermissionChecks).toEqual([ + { + principal: { principalId: principal.principalId, tenantId: principal.tenantId }, + targets: [ + { + permission, + target: { + kind: 'inventory_resource', + resource: { + moduleId: 'commerce.inventory', + resourceId, + resourceType: 'commerce.inventory.stock-position', + }, + tenantId: principal.tenantId, + }, + }, + ], + }, + ]); + expect(allowed.flushed[0]?.transport).toEqual({ + correlationId: 'correlation-inventory-resource-target', + idempotencyKey: 'inventory-resource-target', + targetModuleKey: 'commerce.inventory', + targetResourceId: resourceId, + targetResourceType: 'commerce.inventory.stock-position', + }); + + const denied = yield* makeHarness({ businessPermissionDecision: 'denied' }); + expect(Predicate.isTagged(yield* Effect.flip(run(denied)), 'ActionPermissionDenied')).toBe(true); + + for (const [invalidPayload, expectedTag] of [ + [{ ...payload, targetTenantId: '00000000-0000-4000-8000-000000000099' }, 'ActionPermissionCheckError'], + [{ ...payload, resourceId: 'position-by-item-and-location' }, 'ActionPayloadValidationError'], + ] as const) { + const invalid = yield* makeHarness({ businessPermissionDecision: 'allowed' }); + expect(Predicate.isTagged(yield* Effect.flip(run(invalid, invalidPayload)), expectedTag)).toBe(true); + expect(invalid.businessPermissionChecks).toHaveLength(0); + } + expect(handlerCalls).toBe(1); + }), +); + it.effect( 'rejects a Pricing permission resolved onto a Counterparty target before checks, persistence, or handler code', Effect.fn(function* rejectMismatchedBusinessPermissionTarget() { diff --git a/app/packages/core-runtime/tests/unit/authorization-mutation-saga.test.ts b/app/packages/core-runtime/tests/unit/authorization-mutation-saga.test.ts index 58ae9b8e7..376213943 100644 --- a/app/packages/core-runtime/tests/unit/authorization-mutation-saga.test.ts +++ b/app/packages/core-runtime/tests/unit/authorization-mutation-saga.test.ts @@ -16,6 +16,7 @@ const principalId = '40000000-0000-4000-8000-000000000001'; const pricingCatalogId = '50000000-0000-4000-8000-000000000001'; const priceGroupId = '60000000-0000-4000-8000-000000000001'; const otherPriceGroupId = '60000000-0000-4000-8000-000000000002'; +const inventoryResourceId = '70000000-0000-4000-8000-000000000001'; const intent = ( operation: 'grant' | 'revoke' = 'grant', @@ -306,6 +307,65 @@ it.effect('reconciles the exact tenant-only Price Group target and rejects a dif }), ); +it.effect('reconciles only the exact durable Inventory Resource intent', () => + Effect.gen(function* reconcileInventoryResource() { + const inventoryPermission = yield* Schema.decodeEffect(BusinessPermissionCodeSchema)('inventory.stock.correct'); + const inventoryTarget = { + kind: 'inventory_resource' as const, + resource: { + moduleId: 'commerce.inventory' as const, + resourceId: inventoryResourceId, + resourceType: 'commerce.inventory.stock-position', + }, + tenantId, + }; + const inventoryIntent: AuthorizationMutationJournalEntry = { + ...intent(), + businessTarget: inventoryTarget, + permission: inventoryPermission, + }; + const writes: unknown[] = []; + const result = yield* reconcileCommittedAuthorizationMutation( + inventoryIntent, + { + mutate: (input) => + Effect.sync(() => { + writes.push(input); + }), + }, + { finalize: () => Effect.succeed({ ...inventoryIntent, state: 'ACTIVE' }) }, + ); + expect(result.outcome).toBe('FINALIZED'); + expect(writes).toEqual([ + { + operation: 'grant', + permission: inventoryPermission, + principal: { principalId, tenantId }, + target: inventoryIntent.businessTarget, + }, + ]); + + const mismatch = yield* Effect.flip( + reconcileCommittedAuthorizationMutation( + inventoryIntent, + { mutate: () => Effect.void }, + { + finalize: () => + Effect.succeed({ + ...inventoryIntent, + businessTarget: { + ...inventoryTarget, + resource: { ...inventoryTarget.resource, resourceId: otherPriceGroupId }, + }, + state: 'ACTIVE', + }), + }, + ), + ); + expect(mismatch.code).toBe('authorization_mutation_final_state_invalid'); + }), +); + it.effect('rejects incompatible or noncanonical Pricing intents before relationship mutation and finalization', () => Effect.gen(function* rejectInvalidPricingIntents() { const pricingPermission = yield* Schema.decodeEffect(BusinessPermissionCodeSchema)('pricing.price_group.read'); diff --git a/app/packages/core-runtime/tests/unit/business-permission-mutation.test.ts b/app/packages/core-runtime/tests/unit/business-permission-mutation.test.ts index af0c26275..a15c13ec1 100644 --- a/app/packages/core-runtime/tests/unit/business-permission-mutation.test.ts +++ b/app/packages/core-runtime/tests/unit/business-permission-mutation.test.ts @@ -14,6 +14,7 @@ const legalEntityId = '30000000-0000-4000-8000-000000000001'; const principalId = '40000000-0000-4000-8000-000000000001'; const pricingCatalogId = '50000000-0000-4000-8000-000000000001'; const priceGroupId = '60000000-0000-4000-8000-000000000001'; +const inventoryResourceId = '70000000-0000-4000-8000-000000000001'; it.effect('writes the exact legal-entity and grantee relationships idempotently for a grant', () => Effect.gen(function* grantBusinessPermission() { @@ -141,6 +142,35 @@ it.effect('writes only the tenant scope and grantee for an exact Pricing Catalog }), ); +it.effect('writes tenant and grantee relationships for one exact Inventory Resource grant', () => + Effect.gen(function* grantInventoryResourcePermission() { + const requests: v1.WriteRelationshipsRequest[] = []; + const service = makeBusinessPermissionRelationshipMutation({ + writeRelationships: (request) => + Effect.sync(() => { + requests.push(request); + return v1.WriteRelationshipsResponse.create({}); + }), + }); + yield* service.mutate({ + operation: 'grant', + permission: yield* Schema.decodeEffect(BusinessPermissionCodeSchema)('inventory.stock.correct'), + principal: { principalId, tenantId }, + target: { + kind: 'inventory_resource', + resource: { + moduleId: 'commerce.inventory', + resourceId: inventoryResourceId, + resourceType: 'commerce.inventory.stock-position', + }, + tenantId, + }, + }); + + expect(requests[0]?.updates.map(({ relationship }) => relationship?.relation)).toEqual(['tenant', 'grantee']); + }), +); + it.effect('fails closed before transport for cross-tenant or untrusted storefront input', () => Effect.gen(function* rejectUntrustedScope() { let calls = 0; @@ -218,6 +248,20 @@ it.effect('rejects incompatible permission targets and noncanonical Pricing iden principal: { principalId, tenantId }, target: { kind: 'pricing_catalog' as const, pricingCatalogId: 'DEALER', tenantId }, }, + { + operation: 'grant' as const, + permission: yield* Schema.decodeEffect(BusinessPermissionCodeSchema)('inventory.stock.correct'), + principal: { principalId, tenantId }, + target: { + kind: 'inventory_resource' as const, + resource: { + moduleId: 'commerce.inventory' as const, + resourceId: inventoryResourceId, + resourceType: 'commerce.catalog.stock-position', + }, + tenantId, + }, + }, ]; const failures: BusinessPermissionMutationUnavailable[] = []; diff --git a/app/packages/core-runtime/tests/unit/business-permission.test.ts b/app/packages/core-runtime/tests/unit/business-permission.test.ts index be164416c..1e1e125d5 100644 --- a/app/packages/core-runtime/tests/unit/business-permission.test.ts +++ b/app/packages/core-runtime/tests/unit/business-permission.test.ts @@ -87,6 +87,30 @@ it('accepts only the canonical tenant-only Pricing target kinds', () => { ).toThrow(/incompatible target scope/u); }); +it('accepts Inventory permissions only for exact Inventory Resource scope', () => { + expect(Schema.decodeSync(BusinessPermissionCodeSchema)('inventory.stock.correct')).toBe('inventory.stock.correct'); + expect( + defineBusinessPermission({ + ...readPermission, + allowedScopeKinds: ['inventory_resource'], + key: 'inventory.stock.correct', + }).allowedScopeKinds, + ).toEqual(['inventory_resource']); + expect(() => + defineBusinessPermission({ + ...readPermission, + allowedScopeKinds: ['counterparty'], + key: 'inventory.stock.correct', + }), + ).toThrow(/incompatible target scope/u); + expect(() => + defineBusinessPermission({ + ...readPermission, + allowedScopeKinds: ['inventory_resource'], + }), + ).toThrow(/incompatible target scope/u); +}); + it('allows only explicit authorization projection state transitions', () => { expect(canTransitionAuthorizationMutation('PENDING_GRANT', 'ACTIVE')).toBe(true); expect(canTransitionAuthorizationMutation('ACTIVE', 'REVOKED')).toBe(false); diff --git a/app/packages/core-runtime/tests/unit/context-access.test.ts b/app/packages/core-runtime/tests/unit/context-access.test.ts index bdaf85263..5c389f1b3 100644 --- a/app/packages/core-runtime/tests/unit/context-access.test.ts +++ b/app/packages/core-runtime/tests/unit/context-access.test.ts @@ -26,6 +26,7 @@ const principalId = '30000000-0000-4000-8000-000000000001'; const pricingCatalogId = '50000000-0000-4000-8000-000000000001'; const priceGroupId = '60000000-0000-4000-8000-000000000001'; const otherPriceGroupId = '60000000-0000-4000-8000-000000000002'; +const inventoryResourceId = '70000000-0000-4000-8000-000000000001'; const assortmentEndTarget = { binding: { @@ -535,6 +536,58 @@ it.effect('checks exact business permissions and rejects untrusted storefront sc }), ); +it.effect('checks one exact tenant-qualified Inventory Resource and rejects another owner or identity', () => + Effect.gen(function* checksInventoryResourcePermission() { + const requests: v1.CheckBulkPermissionsRequest[] = []; + const access = makeContextAccess( + makeClient((request) => + Effect.sync(() => { + requests.push(request); + return responseFor(request, [v1.CheckPermissionResponse_Permissionship.HAS_PERMISSION]); + }), + ), + ); + const permission = yield* Schema.decodeEffect(BusinessPermissionCodeSchema)('inventory.stock.correct'); + const target = { + permission, + target: { + kind: 'inventory_resource' as const, + resource: { + moduleId: 'commerce.inventory' as const, + resourceId: inventoryResourceId, + resourceType: 'commerce.inventory.stock-position', + }, + tenantId, + }, + }; + const check = requireBusinessPermissions(access); + expect(yield* check({ principal: { principalId, tenantId }, targets: [target] })).toEqual([ + { decision: 'allowed', key: toBusinessPermissionAccessKey(target) }, + ]); + expect(requests[0]?.items[0]?.resource?.objectId).toBe( + toBusinessPermissionAccessObjectId(permission, target.target), + ); + + for (const invalidTarget of [ + { + ...target.target, + resource: { ...target.target.resource, resourceType: 'commerce.catalog.stock-position' }, + }, + { ...target.target, resource: { ...target.target.resource, resourceId: 'position-by-location' } }, + ]) { + expect( + yield* check({ principal: { principalId, tenantId }, targets: [{ permission, target: invalidTarget }] }), + ).toEqual([ + { + decision: 'unavailable', + key: toBusinessPermissionAccessKey({ permission, target: invalidTarget }), + }, + ]); + } + expect(requests).toHaveLength(1); + }), +); + it.effect('accepts either an exact Storefront or exact Counterparty-wide positive grant', () => Effect.gen(function* acceptsBusinessPermissionAlternatives() { const observedObjectIds: string[][] = []; diff --git a/app/packages/core-runtime/tests/unit/read-runtime.test.ts b/app/packages/core-runtime/tests/unit/read-runtime.test.ts index 34c743b1c..882f70e43 100644 --- a/app/packages/core-runtime/tests/unit/read-runtime.test.ts +++ b/app/packages/core-runtime/tests/unit/read-runtime.test.ts @@ -1429,6 +1429,91 @@ it.effect('governs tenant-only Price Group reads with stable target evidence and }), ); +it.effect('governs one exact Inventory Resource read without deriving authority from selected context', () => + Effect.gen(function* governsInventoryResourceRead() { + const permission = yield* Schema.decodeEffect(BusinessPermissionCodeSchema)('inventory.resource.read'); + const InventoryResourceIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('InventoryResourceId')); + const TenantIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('InventoryReadTenantId')); + const InputSchema = Schema.Struct({ + resourceId: InventoryResourceIdSchema, + tenantId: TenantIdSchema, + }); + let handlerCalls = 0; + const read = defineRead( + { + accessKind: 'detail', + entrypoint: defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.stock-position.read', + moduleKey: 'commerce.inventory', + role: 'api', + }), + evidencePolicy: { captureMode: 'metadata_only', policyKey: 'inventory.resource.read.v1' }, + inputSchema: InputSchema, + legalEntityScope: 'optional', + owningModuleKey: 'commerce.inventory', + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.stock-position.read', + resultSchema: Schema.String, + schemaVersion: '1', + }, + ({ resourceId }) => { + handlerCalls += 1; + return Effect.succeed({ evidence: { resultCount: 1 }, result: resourceId }); + }, + () => Effect.succeed(Object.freeze({})), + (input) => ({ + businessPermission: { + permission, + target: { + kind: 'inventory_resource', + resource: { + moduleId: 'commerce.inventory', + resourceId: input.resourceId, + resourceType: 'commerce.inventory.stock-position', + }, + tenantId: input.tenantId, + }, + }, + kind: 'business_permission', + }), + ); + const resourceId = '70000000-0000-4000-8000-000000000001'; + const input = { resourceId, tenantId: scope.tenantId }; + const run = (harness: Effect.Success>, nextInput?: typeof input) => + harness.runtime.runRead({ + input: nextInput ?? input, + principal: scope, + registration: read, + transport: { correlationId: scope.correlationId }, + }); + + const allowed = yield* makeHarness({ + businessPermissionDecision: 'allowed', + contextPermissionDecision: 'allowed', + }); + expect(yield* run(allowed)).toBe(resourceId); + const evidenceValues = allowed.evidenceParameterRows()[0] ?? []; + expect(evidenceValues).toContain(resourceId); + expect(evidenceValues).toContain('commerce.inventory.stock-position'); + + const crossTenant = yield* makeHarness({ + businessPermissionDecision: 'allowed', + contextPermissionDecision: 'allowed', + }); + expect( + Predicate.isTagged( + yield* Effect.flip(run(crossTenant, { ...input, tenantId: '00000000-0000-4000-8000-000000000099' })), + 'ReadPermissionUnavailable', + ), + ).toBe(true); + expect(crossTenant.permissionChecks().businessPermissionChecks).toBe(0); + expect(handlerCalls).toBe(1); + }), +); + it.effect('persists sanitized permission denial and never invokes the private handler', () => Effect.gen(function* migratedTest11() { const legalEntityId = '00000000-0000-4000-8000-000000000004'; diff --git a/app/packages/shared-contracts/src/index.ts b/app/packages/shared-contracts/src/index.ts index fb8cccd86..8513c88d0 100644 --- a/app/packages/shared-contracts/src/index.ts +++ b/app/packages/shared-contracts/src/index.ts @@ -15,6 +15,47 @@ export type { OwnerVerifiableSetCompletenessScope, } from './owner-verifiable-set-completeness.ts'; +export { + AntiResurrectionProtectionKindSchema, + AntiResurrectionProtectionSchema, + PrivacyMeasureIntendedOutcomeSchema, + PrivacyMeasureSchema, + PrivacyOwnerContentStatusSchema, + PrivacyOwnerCoveragePartSchema, + PrivacyOwnerCoverageResultSchema, + PrivacyOwnerCoverageStatusSchema, + PrivacyOwnerExecutionOutcomeSchema, + PrivacyOwnerExecutionStatusSchema, + PrivacyOwnerReconciliationResultSchema, + PrivacyOwnerReconciliationStatusSchema, + PrivacyOwnerScopeSchema, + PrivacySubjectSchema, +} from './privacy-owner-contract.ts'; +export type { + AntiResurrectionProtection, + AntiResurrectionProtectionEncoded, + AntiResurrectionProtectionKind, + PrivacyMeasure, + PrivacyMeasureEncoded, + PrivacyMeasureIntendedOutcome, + PrivacyOwnerContentStatus, + PrivacyOwnerCoveragePart, + PrivacyOwnerCoveragePartEncoded, + PrivacyOwnerCoverageResult, + PrivacyOwnerCoverageResultEncoded, + PrivacyOwnerCoverageStatus, + PrivacyOwnerExecutionOutcome, + PrivacyOwnerExecutionOutcomeEncoded, + PrivacyOwnerExecutionStatus, + PrivacyOwnerReconciliationResult, + PrivacyOwnerReconciliationResultEncoded, + PrivacyOwnerReconciliationStatus, + PrivacyOwnerScope, + PrivacyOwnerScopeEncoded, + PrivacySubject, + PrivacySubjectEncoded, +} from './privacy-owner-contract.ts'; + export { EXTERNAL_GATEWAY_ASSERTION_VERSION, GATEWAY_ASSERTION_CLOCK_SKEW_SECONDS, diff --git a/app/packages/shared-contracts/src/privacy-owner-contract.ts b/app/packages/shared-contracts/src/privacy-owner-contract.ts new file mode 100644 index 000000000..896cfe129 --- /dev/null +++ b/app/packages/shared-contracts/src/privacy-owner-contract.ts @@ -0,0 +1,321 @@ +import { DateTime, Schema } from 'effect'; + +const OpaquePrivacyReferenceSchema = Schema.String.check( + Schema.isMinLength(1), + Schema.isMaxLength(1000), + Schema.isTrimmed(), +); +const IdempotencyKeySchema = OpaquePrivacyReferenceSchema.pipe(Schema.brand('PrivacyIdempotencyKey')); +const TenantIdSchema = OpaquePrivacyReferenceSchema.pipe(Schema.brand('PrivacyTenantId')); + +const PrivacyReferenceListSchema = Schema.Array(OpaquePrivacyReferenceSchema); + +const hasUniqueReferences = (references: readonly string[]): boolean => new Set(references).size === references.length; + +export const PrivacySubjectSchema = Schema.Union([ + Schema.TaggedStruct('RESOLVED_DATA_SUBJECT', { + subjectRef: OpaquePrivacyReferenceSchema, + }), + Schema.TaggedStruct('ANONYMOUS_PRIVACY_CONTEXT', { + contextRef: OpaquePrivacyReferenceSchema, + }), +]); +export type PrivacySubject = typeof PrivacySubjectSchema.Type; +export type PrivacySubjectEncoded = typeof PrivacySubjectSchema.Encoded; + +/** + * Exact authorized owner scope. The owner receives a confirmed subject/context and does not + * perform Party Matching or infer authority from the lookup references. + */ +export const PrivacyOwnerScopeSchema = Schema.Struct({ + controllerRef: OpaquePrivacyReferenceSchema, + dsrControllerObligationRef: Schema.optionalKey(OpaquePrivacyReferenceSchema), + ownerCapability: OpaquePrivacyReferenceSchema, + requestedScopePartRefs: PrivacyReferenceListSchema, + requestedScopeRef: OpaquePrivacyReferenceSchema, + subject: PrivacySubjectSchema, + tenantId: TenantIdSchema, + trustedLookupRefs: PrivacyReferenceListSchema, +}).check( + Schema.makeFilter((scope) => + scope.requestedScopePartRefs.length > 0 && + hasUniqueReferences(scope.requestedScopePartRefs) && + hasUniqueReferences(scope.trustedLookupRefs) + ? undefined + : { + issue: 'requested owner scope parts must be non-empty and all scope references must be unique', + path: ['requestedScopePartRefs'], + }, + ), +); +export type PrivacyOwnerScope = typeof PrivacyOwnerScopeSchema.Type; +export type PrivacyOwnerScopeEncoded = typeof PrivacyOwnerScopeSchema.Encoded; + +export const PrivacyOwnerCoverageStatusSchema = Schema.Literals([ + 'COMPLETE', + 'PARTIAL', + 'UNAVAILABLE', + 'INDETERMINATE', +]); +export type PrivacyOwnerCoverageStatus = typeof PrivacyOwnerCoverageStatusSchema.Type; + +export const PrivacyOwnerContentStatusSchema = Schema.Literals(['FOUND', 'NO_DATA', 'UNKNOWN']); +export type PrivacyOwnerContentStatus = typeof PrivacyOwnerContentStatusSchema.Type; + +export const PrivacyOwnerCoveragePartSchema = Schema.Struct({ + coverageStatus: PrivacyOwnerCoverageStatusSchema, + evidenceRefs: PrivacyReferenceListSchema, + foundContentRefs: PrivacyReferenceListSchema, + observedAt: Schema.DateTimeUtcFromString, + scopeRef: OpaquePrivacyReferenceSchema, + unresolvedReason: Schema.optionalKey(OpaquePrivacyReferenceSchema), +}).check( + Schema.makeFilter((part) => { + if (part.coverageStatus === 'COMPLETE' && part.unresolvedReason !== undefined) { + return { + issue: 'complete coverage must not retain an unresolved reason', + path: ['unresolvedReason'], + }; + } + if (part.coverageStatus !== 'COMPLETE' && part.unresolvedReason === undefined) { + return { + issue: 'incomplete coverage must explain its unresolved scope', + path: ['unresolvedReason'], + }; + } + return true; + }), +); +export type PrivacyOwnerCoveragePart = typeof PrivacyOwnerCoveragePartSchema.Type; +export type PrivacyOwnerCoveragePartEncoded = typeof PrivacyOwnerCoveragePartSchema.Encoded; + +/** + * Owner-local coverage evidence. Content presence and coverage completeness remain independent: + * NO_DATA is valid only after every requested owner-scope part is completely examined. + */ +export const PrivacyOwnerCoverageResultSchema = Schema.Struct({ + assessedAt: Schema.DateTimeUtcFromString, + contentStatus: PrivacyOwnerContentStatusSchema, + coverageParts: Schema.Array(PrivacyOwnerCoveragePartSchema), + coverageStatus: PrivacyOwnerCoverageStatusSchema, + evidenceRefs: PrivacyReferenceListSchema, + scope: PrivacyOwnerScopeSchema, +}).check( + Schema.makeFilter((result) => { + const coveredScopeRefs = result.coverageParts.map(({ scopeRef }) => scopeRef); + const uniqueCoveredScopeRefs = new Set(coveredScopeRefs); + const exactRequestedScopeCovered = + uniqueCoveredScopeRefs.size === coveredScopeRefs.length && + uniqueCoveredScopeRefs.size === result.scope.requestedScopePartRefs.length && + result.scope.requestedScopePartRefs.every((scopeRef) => uniqueCoveredScopeRefs.has(scopeRef)); + const allPartsComplete = + exactRequestedScopeCovered && result.coverageParts.every((part) => part.coverageStatus === 'COMPLETE'); + const anyContentFound = result.coverageParts.some((part) => part.foundContentRefs.length > 0); + + if ((result.coverageStatus === 'COMPLETE') !== allPartsComplete) { + return { + issue: 'COMPLETE requires every requested owner-scope part to be present and complete', + path: ['coverageStatus'], + }; + } + if (result.contentStatus === 'NO_DATA' && (!allPartsComplete || anyContentFound)) { + return { + issue: 'NO_DATA requires complete owner-scope coverage with no found content', + path: ['contentStatus'], + }; + } + if (result.contentStatus === 'FOUND' && !anyContentFound) { + return { + issue: 'FOUND requires at least one found owner content reference', + path: ['contentStatus'], + }; + } + if (result.contentStatus === 'UNKNOWN' && allPartsComplete) { + return { + issue: 'complete coverage must resolve content presence to FOUND or NO_DATA', + path: ['contentStatus'], + }; + } + return true; + }), +); +export type PrivacyOwnerCoverageResult = typeof PrivacyOwnerCoverageResultSchema.Type; +export type PrivacyOwnerCoverageResultEncoded = typeof PrivacyOwnerCoverageResultSchema.Encoded; + +export const PrivacyMeasureIntendedOutcomeSchema = Schema.Literals([ + 'RECTIFY', + 'ENFORCE_DISPOSITION_RESTRICTION', + 'ENFORCE_PROCESSING_RESTRICTION', + 'ANONYMIZE', + 'DELETE', +]); +export type PrivacyMeasureIntendedOutcome = typeof PrivacyMeasureIntendedOutcomeSchema.Type; + +/** Approved exact-scope owner work. It is not permission to bypass the owner's public Actions. */ +export const PrivacyMeasureSchema = Schema.Struct({ + expectedEvidenceRefs: PrivacyReferenceListSchema, + idempotencyKey: IdempotencyKeySchema, + intendedOutcome: PrivacyMeasureIntendedOutcomeSchema, + measureRef: OpaquePrivacyReferenceSchema, + preconditionRefs: PrivacyReferenceListSchema, + requestedAt: Schema.DateTimeUtcFromString, + scope: PrivacyOwnerScopeSchema, + sourceDecisionRef: OpaquePrivacyReferenceSchema, + sourceDecisionRevision: OpaquePrivacyReferenceSchema, + targetContentRefs: PrivacyReferenceListSchema, +}).check( + Schema.makeFilter((measure) => + measure.targetContentRefs.length > 0 && + hasUniqueReferences(measure.targetContentRefs) && + hasUniqueReferences(measure.preconditionRefs) && + hasUniqueReferences(measure.expectedEvidenceRefs) + ? undefined + : { + issue: 'a Privacy Measure must identify non-empty unique targets and unique evidence/precondition references', + path: ['targetContentRefs'], + }, + ), +); +export type PrivacyMeasure = typeof PrivacyMeasureSchema.Type; +export type PrivacyMeasureEncoded = typeof PrivacyMeasureSchema.Encoded; + +export const PrivacyOwnerExecutionStatusSchema = Schema.Literals([ + 'RECEIVED', + 'IN_PROGRESS', + 'ACHIEVED', + 'PARTIAL', + 'BUSINESS_REJECTED', + 'NOT_APPLICABLE', + 'TECHNICAL_FAILED', + 'BLOCKED', + 'PENDING', + 'INDETERMINATE', +]); +export type PrivacyOwnerExecutionStatus = typeof PrivacyOwnerExecutionStatusSchema.Type; + +/** Authoritative owner result; transport acknowledgement is never represented as ACHIEVED. */ +export const PrivacyOwnerExecutionOutcomeSchema = Schema.Struct({ + affectedContentRefs: PrivacyReferenceListSchema, + confirmedAt: Schema.DateTimeUtcFromString, + evidenceRefs: PrivacyReferenceListSchema, + measureRef: OpaquePrivacyReferenceSchema, + outcomeRef: OpaquePrivacyReferenceSchema, + reason: OpaquePrivacyReferenceSchema, + reconciliationRequired: Schema.Boolean, + remainingContentRefs: PrivacyReferenceListSchema, + scope: PrivacyOwnerScopeSchema, + sourceDecisionRef: OpaquePrivacyReferenceSchema, + sourceDecisionRevision: OpaquePrivacyReferenceSchema, + status: PrivacyOwnerExecutionStatusSchema, +}).check( + Schema.makeFilter((outcome) => { + if (outcome.status === 'ACHIEVED' && outcome.remainingContentRefs.length > 0) { + return { + issue: 'ACHIEVED cannot leave unresolved target content', + path: ['remainingContentRefs'], + }; + } + if ( + outcome.status === 'PARTIAL' && + (outcome.affectedContentRefs.length === 0 || outcome.remainingContentRefs.length === 0) + ) { + return { + issue: 'PARTIAL must identify both completed and remaining content', + path: ['remainingContentRefs'], + }; + } + if (outcome.status === 'INDETERMINATE' && !outcome.reconciliationRequired) { + return { + issue: 'INDETERMINATE requires owner reconciliation before retry', + path: ['reconciliationRequired'], + }; + } + return true; + }), +); +export type PrivacyOwnerExecutionOutcome = typeof PrivacyOwnerExecutionOutcomeSchema.Type; +export type PrivacyOwnerExecutionOutcomeEncoded = typeof PrivacyOwnerExecutionOutcomeSchema.Encoded; + +export const PrivacyOwnerReconciliationStatusSchema = Schema.Literals([ + 'EXECUTION_CONFIRMED', + 'NOT_EXECUTED', + 'PARTIAL_CONFIRMED', + 'STILL_INDETERMINATE', +]); +export type PrivacyOwnerReconciliationStatus = typeof PrivacyOwnerReconciliationStatusSchema.Type; + +export const PrivacyOwnerReconciliationResultSchema = Schema.Struct({ + evidenceRefs: PrivacyReferenceListSchema, + measureRef: OpaquePrivacyReferenceSchema, + observedAt: Schema.DateTimeUtcFromString, + preconditionsRecheckedAt: Schema.optionalKey(Schema.DateTimeUtcFromString), + retryAllowed: Schema.Boolean, + sourceDecisionRevision: OpaquePrivacyReferenceSchema, + status: PrivacyOwnerReconciliationStatusSchema, +}).check( + Schema.makeFilter((result) => { + if (result.retryAllowed && result.status !== 'NOT_EXECUTED') { + return { + issue: 'retry is allowed only after authoritative confirmation that execution did not occur', + path: ['retryAllowed'], + }; + } + if (result.retryAllowed && result.preconditionsRecheckedAt === undefined) { + return { + issue: 'retry requires Current preconditions to be rechecked after reconciliation', + path: ['preconditionsRecheckedAt'], + }; + } + if ( + result.preconditionsRecheckedAt !== undefined && + DateTime.toEpochMillis(result.preconditionsRecheckedAt) < DateTime.toEpochMillis(result.observedAt) + ) { + return { + issue: 'preconditions must be rechecked at or after the reconciliation observation', + path: ['preconditionsRecheckedAt'], + }; + } + return true; + }), +); +export type PrivacyOwnerReconciliationResult = typeof PrivacyOwnerReconciliationResultSchema.Type; +export type PrivacyOwnerReconciliationResultEncoded = typeof PrivacyOwnerReconciliationResultSchema.Encoded; + +export const AntiResurrectionProtectionKindSchema = Schema.Literals([ + 'DELETED_SCOPE', + 'ANONYMIZED_SCOPE', + 'OWNER_ENFORCED_DISPOSITION_RESTRICTION', + 'OWNER_ENFORCED_PROCESSING_RESTRICTION', +]); +export type AntiResurrectionProtectionKind = typeof AntiResurrectionProtectionKindSchema.Type; + +/** Minimal proof for stale-source rejection. It deliberately cannot carry the removed payload. */ +export const AntiResurrectionProtectionSchema = Schema.Struct({ + enforcedAt: Schema.DateTimeUtcFromString, + evidenceRefs: PrivacyReferenceListSchema, + kind: AntiResurrectionProtectionKindSchema, + protectedContentRefs: PrivacyReferenceListSchema, + protectionRef: OpaquePrivacyReferenceSchema, + retainsRemovedPayload: Schema.Literal(false), + scope: PrivacyOwnerScopeSchema, + sourceDecisionRef: OpaquePrivacyReferenceSchema, + sourceDecisionRevision: OpaquePrivacyReferenceSchema, + sourceOutcomeRef: OpaquePrivacyReferenceSchema, + staleSourceResponsibilities: Schema.Array( + Schema.Literals(['IMPORT', 'REPLAY', 'PROJECTION_REBUILD', 'BACKUP_RECOVERY']), + ), +}).check( + Schema.makeFilter((protection) => + protection.protectedContentRefs.length > 0 && + protection.staleSourceResponsibilities.length > 0 && + hasUniqueReferences(protection.protectedContentRefs) && + new Set(protection.staleSourceResponsibilities).size === protection.staleSourceResponsibilities.length + ? undefined + : { + issue: 'anti-resurrection protection requires unique exact content and stale-source responsibilities', + path: ['protectedContentRefs'], + }, + ), +); +export type AntiResurrectionProtection = typeof AntiResurrectionProtectionSchema.Type; +export type AntiResurrectionProtectionEncoded = typeof AntiResurrectionProtectionSchema.Encoded; diff --git a/app/packages/shared-contracts/tests/unit/privacy-owner-contract.test.ts b/app/packages/shared-contracts/tests/unit/privacy-owner-contract.test.ts new file mode 100644 index 000000000..8fa8c8d3e --- /dev/null +++ b/app/packages/shared-contracts/tests/unit/privacy-owner-contract.test.ts @@ -0,0 +1,230 @@ +import { Schema } from 'effect'; +import { expect, it } from 'effect-rstest'; + +import { + AntiResurrectionProtectionSchema, + PrivacyMeasureSchema, + PrivacyOwnerCoverageResultSchema, + PrivacyOwnerExecutionOutcomeSchema, + PrivacyOwnerReconciliationResultSchema, +} from '../../src/index.ts'; +import type { + PrivacyMeasureEncoded, + PrivacyOwnerCoverageResultEncoded, + PrivacyOwnerExecutionOutcomeEncoded, +} from '../../src/index.ts'; + +const decodeCoverage = Schema.decodeUnknownSync(PrivacyOwnerCoverageResultSchema, { + onExcessProperty: 'error', +}); +const decodeMeasure = Schema.decodeUnknownSync(PrivacyMeasureSchema, { onExcessProperty: 'error' }); +const decodeOutcome = Schema.decodeUnknownSync(PrivacyOwnerExecutionOutcomeSchema, { + onExcessProperty: 'error', +}); + +const scope = { + controllerRef: 'legal-entity:controller-a', + dsrControllerObligationRef: 'privacy:dsr-obligation-7', + ownerCapability: 'commerce.inventory', + requestedScopePartRefs: [ + 'inventory-privacy-scope:reservation-history', + 'inventory-privacy-scope:recovery-responsibilities', + ], + requestedScopeRef: 'privacy-owner-scope:inventory/7', + subject: { _tag: 'RESOLVED_DATA_SUBJECT', subjectRef: 'party:subject-7' }, + tenantId: 'tenant-a', + trustedLookupRefs: ['reservation:opaque-correlation-7'], +} as const; + +const completeNoData = { + assessedAt: '2026-09-28T12:00:00.000Z', + contentStatus: 'NO_DATA', + coverageParts: [ + { + coverageStatus: 'COMPLETE', + evidenceRefs: ['inventory-evidence:reservation-history-empty-7'], + foundContentRefs: [], + observedAt: '2026-09-28T11:59:00.000Z', + scopeRef: 'inventory-privacy-scope:reservation-history', + }, + { + coverageStatus: 'COMPLETE', + evidenceRefs: ['inventory-evidence:recovery-responsibility-checked-7'], + foundContentRefs: [], + observedAt: '2026-09-28T11:58:00.000Z', + scopeRef: 'inventory-privacy-scope:recovery-responsibilities', + }, + ], + coverageStatus: 'COMPLETE', + evidenceRefs: ['inventory-evidence:coverage-7'], + scope, +} as const satisfies PrivacyOwnerCoverageResultEncoded; + +const measure = { + expectedEvidenceRefs: ['privacy:expected-outcome-7'], + idempotencyKey: 'privacy-measure:7/revision-3', + intendedOutcome: 'DELETE', + measureRef: 'privacy-measure:7', + preconditionRefs: ['privacy:current-blocker-check-7'], + requestedAt: '2026-09-28T12:01:00.000Z', + scope, + sourceDecisionRef: 'privacy-disposition-decision:7', + sourceDecisionRevision: 'revision-3', + targetContentRefs: ['inventory-evidence:opaque-correlation-7'], +} as const satisfies PrivacyMeasureEncoded; + +it('accepts NO_DATA only with complete evidence for every requested owner-scope part', () => { + expect(decodeCoverage(completeNoData)).toBeDefined(); + + for (const invalid of [ + { + ...completeNoData, + coverageParts: [ + completeNoData.coverageParts[0], + { + ...completeNoData.coverageParts[1], + coverageStatus: 'INDETERMINATE', + unresolvedReason: 'backup coverage has not been reconciled', + }, + ], + }, + { + ...completeNoData, + coverageParts: [ + { + ...completeNoData.coverageParts[0], + foundContentRefs: ['reservation-history:found-7'], + }, + completeNoData.coverageParts[1], + ], + }, + { ...completeNoData, coverageParts: [] }, + { + ...completeNoData, + coverageParts: [completeNoData.coverageParts[0], completeNoData.coverageParts[0]], + }, + ]) { + expect(() => decodeCoverage(invalid)).toThrow(); + } +}); + +it('keeps found content separate from partial or indeterminate coverage', () => { + expect( + decodeCoverage({ + ...completeNoData, + contentStatus: 'FOUND', + coverageParts: [ + { + ...completeNoData.coverageParts[0], + foundContentRefs: ['reservation-history:found-7'], + }, + { + ...completeNoData.coverageParts[1], + coverageStatus: 'INDETERMINATE', + unresolvedReason: 'recovery responsibilities are not verified', + }, + ], + coverageStatus: 'INDETERMINATE', + }), + ).toBeDefined(); +}); + +it('binds a Privacy Measure to an exact subject, scope, source decision, revision and stable identity', () => { + expect(decodeMeasure(measure)).toBeDefined(); + expect(() => decodeMeasure({ ...measure, targetContentRefs: [] })).toThrow(); + expect(() => decodeMeasure({ ...measure, sourceDecisionRevision: '' })).toThrow(); + expect(() => decodeMeasure({ ...measure, privateOwnerTable: 'inventory_reservations' })).toThrow(); +}); + +it('distinguishes truthful owner outcomes and requires reconciliation for indeterminate execution', () => { + const indeterminate = { + affectedContentRefs: [], + confirmedAt: '2026-09-28T12:02:00.000Z', + evidenceRefs: ['inventory-effect:7'], + measureRef: measure.measureRef, + outcomeRef: 'privacy-owner-outcome:7', + reason: 'the owner mutation may have committed before the response was lost', + reconciliationRequired: true, + remainingContentRefs: measure.targetContentRefs, + scope, + sourceDecisionRef: measure.sourceDecisionRef, + sourceDecisionRevision: measure.sourceDecisionRevision, + status: 'INDETERMINATE', + } as const satisfies PrivacyOwnerExecutionOutcomeEncoded; + + expect(decodeOutcome(indeterminate)).toBeDefined(); + expect(() => decodeOutcome({ ...indeterminate, reconciliationRequired: false })).toThrow(); + expect(() => + decodeOutcome({ + ...indeterminate, + affectedContentRefs: ['inventory-evidence:removed-7'], + reconciliationRequired: false, + remainingContentRefs: [], + status: 'PARTIAL', + }), + ).toThrow(); +}); + +it('allows retry only after reconciliation proves non-execution and Current preconditions are rechecked', () => { + const decodeReconciliation = Schema.decodeUnknownSync(PrivacyOwnerReconciliationResultSchema, { + onExcessProperty: 'error', + }); + + expect( + decodeReconciliation({ + evidenceRefs: ['inventory-effect:7/not-executed'], + measureRef: measure.measureRef, + observedAt: '2026-09-28T12:03:00.000Z', + preconditionsRecheckedAt: '2026-09-28T12:04:00.000Z', + retryAllowed: true, + sourceDecisionRevision: measure.sourceDecisionRevision, + status: 'NOT_EXECUTED', + }), + ).toBeDefined(); + expect(() => + decodeReconciliation({ + evidenceRefs: ['inventory-effect:7/unknown'], + measureRef: measure.measureRef, + observedAt: '2026-09-28T12:03:00.000Z', + preconditionsRecheckedAt: '2026-09-28T12:04:00.000Z', + retryAllowed: true, + sourceDecisionRevision: measure.sourceDecisionRevision, + status: 'STILL_INDETERMINATE', + }), + ).toThrow(); +}); + +it('requires exact anti-resurrection scope without retaining the removed payload', () => { + const decodeProtection = Schema.decodeUnknownSync(AntiResurrectionProtectionSchema, { + onExcessProperty: 'error', + }); + + const protection = { + enforcedAt: '2026-09-28T12:05:00.000Z', + evidenceRefs: ['inventory-evidence:delete-proof-7'], + kind: 'DELETED_SCOPE', + protectedContentRefs: measure.targetContentRefs, + protectionRef: 'anti-resurrection:inventory/7', + retainsRemovedPayload: false, + scope, + sourceDecisionRef: measure.sourceDecisionRef, + sourceDecisionRevision: measure.sourceDecisionRevision, + sourceOutcomeRef: 'privacy-owner-outcome:7', + staleSourceResponsibilities: ['IMPORT', 'REPLAY', 'PROJECTION_REBUILD', 'BACKUP_RECOVERY'], + } as const; + + expect(decodeProtection(protection)).toBeDefined(); + expect(() => decodeProtection({ ...protection, sourceDecisionRevision: '' })).toThrow(); + expect(() => + decodeProtection({ + ...protection, + protectedContentRefs: [measure.targetContentRefs[0], measure.targetContentRefs[0]], + }), + ).toThrow(); + expect(() => + decodeProtection({ + ...protection, + removedPayload: { email: 'must-not-be-retained@example.test' }, + }), + ).toThrow(); +}); diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml index 9d71ad4f0..f82252d21 100644 --- a/app/pnpm-lock.yaml +++ b/app/pnpm-lock.yaml @@ -242,6 +242,9 @@ importers: '@app/core-runtime': specifier: workspace:* version: link:packages/core-runtime + '@app/inventory': + specifier: workspace:* + version: link:verticals/inventory '@app/party-registry': specifier: workspace:* version: link:verticals/party-registry @@ -396,6 +399,9 @@ importers: '@app/core-runtime': specifier: workspace:* version: link:../../packages/core-runtime + '@app/inventory': + specifier: workspace:* + version: link:../../verticals/inventory '@app/party-registry': specifier: workspace:* version: link:../../verticals/party-registry @@ -1354,6 +1360,145 @@ importers: specifier: 1.2.4 version: 1.2.4(@rspack/core@2.2.7(@swc/helpers@0.5.23))(supports-color@10.2.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0)) + verticals/inventory: + dependencies: + '@app/catalog': + specifier: workspace:* + version: link:../catalog + '@app/core-runtime': + specifier: workspace:* + version: link:../../packages/core-runtime + '@app/gateway-principal-verifier': + specifier: workspace:* + version: link:../../packages/gateway-principal-verifier + '@app/shared-contracts': + specifier: workspace:* + version: link:../../packages/shared-contracts + '@app/shared-design-tokens': + specifier: workspace:* + version: link:../../packages/shared-design-tokens + '@effect/opentelemetry': + specifier: 4.0.0-rc.117 + version: 4.0.0-rc.117(@opentelemetry/api-logs@0.222.0)(@opentelemetry/api@1.9.1)(@opentelemetry/resources@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-logs@0.222.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-metrics@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-node@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-web@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/semantic-conventions@1.43.0)(effect@4.0.0-rc.117) + '@effect/sql-pg': + specifier: 4.0.0-rc.117 + version: 4.0.0-rc.117(effect@4.0.0-rc.117) + '@modern-js/bff-effect': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-bff-effect@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@effect/opentelemetry@4.0.0-rc.117(@opentelemetry/api-logs@0.222.0)(@opentelemetry/api@1.9.1)(@opentelemetry/resources@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-logs@0.222.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-metrics@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-node@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-web@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/semantic-conventions@1.43.0)(effect@4.0.0-rc.117))(core-js@3.50.0)(effect@4.0.0-rc.117)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(zod@4.6.5)' + '@modern-js/federation-runtime': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-federation-runtime@3.9.0-ultramodern.25(@bleedingdev/modern-js-runtime@3.9.0-ultramodern.25(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(react@19.2.8)' + '@modern-js/i18n-integration': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-i18n-integration@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@rspack/core@2.2.7(@bleedingdev/mf-runtime-tools@2.9.2)(@swc/helpers@0.5.23))(@typescript/native-preview@7.0.0-dev.20260707.2)(clean-css@5.3.3)(core-js@3.50.0)(csso@5.0.5)(lightningcss@1.33.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(supports-color@10.2.2)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))(zod@4.6.5))(@bleedingdev/modern-js-runtime@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(core-js@3.50.0)(i18next@26.4.2(typescript@7.0.2))(react-dom@19.2.8(react@19.2.8))(react@19.2.8)' + '@modern-js/plugin-bff': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-plugin-bff@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@rspack/core@2.2.7(@bleedingdev/mf-runtime-tools@2.9.2)(@swc/helpers@0.5.23))(@typescript/native-preview@7.0.0-dev.20260707.2)(clean-css@5.3.3)(core-js@3.50.0)(csso@5.0.5)(lightningcss@1.33.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(supports-color@10.2.2)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))(zod@4.6.5))(@swc/helpers@0.5.23)(@typescript/native-preview@7.0.0-dev.20260707.2)(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(typescript@7.0.2)(zod@4.6.5)' + '@modern-js/plugin-bff-extensions': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-plugin-bff-extensions@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@effect/opentelemetry@4.0.0-rc.117(@opentelemetry/api-logs@0.222.0)(@opentelemetry/api@1.9.1)(@opentelemetry/resources@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-logs@0.222.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-metrics@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-base@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-node@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/sdk-trace-web@2.11.0(@opentelemetry/api@1.9.1))(@opentelemetry/semantic-conventions@1.43.0)(effect@4.0.0-rc.117))(@swc/helpers@0.5.23)(core-js@3.50.0)(effect@4.0.0-rc.117)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(zod@4.6.5)' + '@modern-js/plugin-i18n': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-plugin-i18n@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@bleedingdev/modern-js-runtime@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(core-js@3.50.0)(i18next@26.4.2(typescript@7.0.2))(react-dom@19.2.8(react@19.2.8))(react@19.2.8)' + '@modern-js/plugin-tanstack': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-plugin-tanstack@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@rspack/core@2.2.7(@bleedingdev/mf-runtime-tools@2.9.2)(@swc/helpers@0.5.23))(@typescript/native-preview@7.0.0-dev.20260707.2)(clean-css@5.3.3)(core-js@3.50.0)(csso@5.0.5)(lightningcss@1.33.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(supports-color@10.2.2)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))(zod@4.6.5))(@bleedingdev/modern-js-runtime@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)' + '@modern-js/runtime': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-runtime@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)' + '@modern-js/runtime-extensions': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.25(react-dom@19.2.8(react@19.2.8))(react@19.2.8)' + '@modern-js/runtime-renderer-extensions': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-runtime-renderer-extensions@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)' + '@module-federation/modern-js-v3': + specifier: npm:@bleedingdev/mf-modern-js-v3@2.9.3 + version: '@bleedingdev/mf-modern-js-v3@2.9.3(@rsbuild/core@2.2.9(core-js@3.50.0))(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-dom@19.2.8(react@19.2.8))(react-router@7.18.4(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(react@19.2.8)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))' + '@module-federation/runtime': + specifier: npm:@bleedingdev/mf-runtime@2.9.2 + version: '@bleedingdev/mf-runtime@2.9.2' + '@tanstack/react-router': + specifier: 1.170.39 + version: 1.170.39(react-dom@19.2.8(react@19.2.8))(react@19.2.8) + drizzle-orm: + specifier: 1.0.0-rc.5-ab785fc + version: 1.0.0-rc.5-ab785fc(patch_hash=b99614c9074d41f359743addc0f2a131dbd9c9c479d57cc0f0bb2bb1344bf5fe)(@cloudflare/workers-types@5.20260923.1)(@effect/sql-pg@4.0.0-rc.117(effect@4.0.0-rc.117))(@opentelemetry/api@1.9.1)(@sinclair/typebox@0.34.52)(@types/pg@8.20.0)(bun-types@1.4.0)(effect@4.0.0-rc.117)(pg@8.22.0)(zod@4.6.5) + effect: + specifier: 4.0.0-rc.117 + version: 4.0.0-rc.117 + i18next: + specifier: 26.4.2 + version: 26.4.2(typescript@7.0.2) + pg: + specifier: 8.22.0 + version: 8.22.0 + react: + specifier: 19.2.8 + version: 19.2.8 + react-dom: + specifier: 19.2.8 + version: 19.2.8(react@19.2.8) + devDependencies: + '@effect/tsgo': + specifier: 0.41.0 + version: 0.41.0 + '@modern-js/app-tools': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@rspack/core@2.2.7(@bleedingdev/mf-runtime-tools@2.9.2)(@swc/helpers@0.5.23))(@typescript/native-preview@7.0.0-dev.20260707.2)(clean-css@5.3.3)(core-js@3.50.0)(csso@5.0.5)(lightningcss@1.33.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(supports-color@10.2.2)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))(zod@4.6.5)' + '@modern-js/app-tools-extensions': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-app-tools-extensions@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@rsbuild/core@2.2.9(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0))(@rspack/core@2.2.7(@bleedingdev/mf-runtime-tools@2.9.2)(@swc/helpers@0.5.23))(@typescript/native-preview@7.0.0-dev.20260707.2)(clean-css@5.3.3)(core-js@3.50.0)(csso@5.0.5)(lightningcss@1.33.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(supports-color@10.2.2)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))(zod@4.6.5)' + '@modern-js/plugin-bff-build-extensions': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-plugin-bff-build-extensions@3.9.0-ultramodern.25(e135e8d23a2194559165ce6de6c4d8a3)' + '@modern-js/ultramodern-app-tools': + specifier: catalog:ultramodern + version: '@bleedingdev/modern-js-ultramodern-app-tools@3.9.0-ultramodern.25(@bleedingdev/mf-runtime-tools@2.9.2)(@rspack/core@2.2.7(@bleedingdev/mf-runtime-tools@2.9.2)(@swc/helpers@0.5.23))(@typescript/native-preview@7.0.0-dev.20260707.2)(clean-css@5.3.3)(core-js@3.50.0)(csso@5.0.5)(i18next@26.4.2(typescript@7.0.2))(lightningcss@1.33.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)(supports-color@10.2.2)(typescript@7.0.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0))(zod@4.6.5)' + '@rsbuild/plugin-tailwindcss': + specifier: ^2.0.3 + version: 2.0.3(@rsbuild/core@2.2.9(core-js@3.50.0))(@rspack/core@2.2.7(@swc/helpers@0.5.23))(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0)) + '@rstest/core': + specifier: 0.11.12 + version: 0.11.12(@bleedingdev/mf-runtime-tools@2.9.2)(core-js@3.50.0)(happy-dom@20.8.3) + '@types/node': + specifier: ^26.4.1 + version: 26.6.3 + '@types/pg': + specifier: 8.20.0 + version: 8.20.0 + '@types/react': + specifier: ^19.2.18 + version: 19.3.0 + '@types/react-dom': + specifier: ^19.2.7 + version: 19.3.0(@types/react@19.3.0) + '@typescript/native': + specifier: npm:typescript@7.0.2 + version: typescript@7.0.2 + cross-env: + specifier: 10.1.0 + version: 10.1.0 + drizzle-kit: + specifier: 1.0.0-rc.5-ab785fc + version: 1.0.0-rc.5-ab785fc + effect-rstest: + specifier: https://pkg.pr.new/ScriptedAlchemy/effect-rstest@cbbf87e05c7517a85eb412d33421cd2ab5234597 + version: https://pkg.pr.new/ScriptedAlchemy/effect-rstest@cbbf87e05c7517a85eb412d33421cd2ab5234597(@rstest/core@0.11.12(core-js@3.50.0)(happy-dom@20.8.3))(effect@4.0.0-rc.117) + tailwindcss: + specifier: ^4.3.3 + version: 4.3.3 + typescript: + specifier: 7.0.2 + version: 7.0.2 + wrangler: + specifier: 4.137.0 + version: 4.137.0(@cloudflare/workers-types@5.20260923.1)(@types/node@26.6.3) + zephyr-rspack-plugin: + specifier: 1.2.4 + version: 1.2.4(@rspack/core@2.2.7(@swc/helpers@0.5.23))(supports-color@10.2.2)(webpack@5.111.1(@swc/core@1.16.2(@swc/helpers@0.5.23))(clean-css@5.3.3)(cssnano@9.0.5(postcss@8.5.28))(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@7.2.0)(lightningcss@1.33.0)(postcss@8.5.28)(sharp@0.35.4(@types/node@26.6.3))(svgo@4.1.0)) + verticals/party-registry: dependencies: '@app/core-runtime': @@ -2767,6 +2912,9 @@ packages: '@emnapi/wasi-threads@1.2.3': resolution: {integrity: sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==} + '@epic-web/invariant@1.0.0': + resolution: {integrity: sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==} + '@esbuild/aix-ppc64@0.25.12': resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} engines: {node: '>=18'} @@ -6451,6 +6599,11 @@ packages: typescript: optional: true + cross-env@10.1.0: + resolution: {integrity: sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==} + engines: {node: '>=20'} + hasBin: true + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -11959,6 +12112,8 @@ snapshots: tslib: 2.8.1 optional: true + '@epic-web/invariant@1.0.0': {} + '@esbuild/aix-ppc64@0.25.12': optional: true @@ -15142,6 +15297,11 @@ snapshots: optionalDependencies: typescript: 7.0.2 + cross-env@10.1.0: + dependencies: + '@epic-web/invariant': 1.0.0 + cross-spawn: 7.0.6 + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 diff --git a/app/quality-audit/knip-model.mts b/app/quality-audit/knip-model.mts index 2dc107b1f..b6be40cb4 100644 --- a/app/quality-audit/knip-model.mts +++ b/app/quality-audit/knip-model.mts @@ -1132,54 +1132,138 @@ const drizzleFactories = (facts: SourceFacts): ReadonlySet => { ); }; +const drizzleTableReceiver = (callee: Extract): Node | undefined => { + if (propertyName(callee.property) === 'table') { + return callee.object; + } + if ( + propertyName(callee.property) === 'withRLS' && + callee.object.type === 'MemberExpression' && + propertyName(callee.object.property) === 'table' + ) { + return callee.object.object; + } + return undefined; +}; + +const importedDrizzleDeclaration = ( + facts: SourceFacts, + localName: string, + factsByPath: ReadonlyMap, + path: Path.Path, +): { readonly facts: SourceFacts; readonly node: Node | undefined } | undefined => { + const statement = facts.program.body.find( + (candidate) => + candidate.type === 'ImportDeclaration' && + candidate.source.value.startsWith('.') && + candidate.specifiers.some( + (specifier) => specifier.type === 'ImportSpecifier' && specifier.local.name === localName, + ), + ); + if (statement?.type !== 'ImportDeclaration') { + return undefined; + } + const imported = statement.specifiers.find( + (specifier) => specifier.type === 'ImportSpecifier' && specifier.local.name === localName, + ); + if (imported?.type !== 'ImportSpecifier') { + return undefined; + } + const targetPath = path.normalize(path.join(path.dirname(facts.file), statement.source.value)).replaceAll('\\', '/'); + const target = factsByPath.get(targetPath); + const importedName = propertyName(imported.imported); + return target === undefined || importedName === undefined + ? undefined + : { facts: target, node: target.variables.get(importedName) }; +}; + const isDrizzleDeclaration = ( node: Node | undefined, - variables: ReadonlyMap, - factories: ReadonlySet, + facts: SourceFacts, + factsByPath: ReadonlyMap, + path: Path.Path, depth = 0, ): boolean => { - const expression = unwrap(node, variables); + const expression = unwrap(node, facts.variables); if (expression?.type !== 'CallExpression' || depth > 5) { return false; } if (expression.callee.type === 'Identifier') { - return factories.has(expression.callee.name); + return drizzleFactories(facts).has(expression.callee.name); + } + if (expression.callee.type !== 'MemberExpression') { + return false; + } + const receiver = drizzleTableReceiver(expression.callee); + if (receiver === undefined) { + return false; + } + const schema = + receiver.type === 'Identifier' && !facts.variables.has(receiver.name) + ? receiver + : unwrap(receiver, facts.variables); + if (schema?.type === 'CallExpression') { + return isDrizzleDeclaration(schema, facts, factsByPath, path, depth + 1); } - if (expression.callee.type === 'MemberExpression' && propertyName(expression.callee.property) === 'table') { - return isDrizzleDeclaration(expression.callee.object, variables, factories, depth + 1); + if (schema?.type !== 'Identifier') { + return false; } - return false; + const imported = importedDrizzleDeclaration(facts, schema.name, factsByPath, path); + return imported !== undefined && isDrizzleDeclaration(imported.node, imported.facts, factsByPath, path, depth + 1); }; -const reflectedDrizzleExports = (facts: SourceFacts, workspace: string, configSource: string): KnipModelEvidence[] => { - const factories = drizzleFactories(facts); - const result: KnipModelEvidence[] = []; - for (const node of facts.program.body) { - if (node.type !== 'ExportNamedDeclaration' || node.declaration?.type !== 'VariableDeclaration') { - continue; - } - for (const declaration of node.declaration.declarations) { - if ( - declaration.id.type === 'Identifier' && - declaration.init !== null && - isDrizzleDeclaration(declaration.init, facts.variables, factories) - ) { - result.push( - evidenceAt( - facts, - workspace, - 'export', - `${facts.file}#${declaration.id.name}`, - declaration.start, - `Drizzle reflective schema consumer configured by ${configSource}`, - ), - ); - } - } +const reflectedDrizzleExport = ( + facts: SourceFacts, + node: Node, + factsByPath: ReadonlyMap, + workspace: string, + configSource: string, + path: Path.Path, +): KnipModelEvidence[] => { + if (node.type !== 'ExportNamedDeclaration') { + return []; } - return result; + const reason = `Drizzle reflective schema consumer configured by ${configSource}`; + if (node.declaration?.type === 'VariableDeclaration') { + return node.declaration.declarations.flatMap((declaration) => + declaration.id.type === 'Identifier' && + declaration.init !== null && + isDrizzleDeclaration(declaration.init, facts, factsByPath, path) + ? [evidenceAt(facts, workspace, 'export', `${facts.file}#${declaration.id.name}`, declaration.start, reason)] + : [], + ); + } + if (node.source?.type !== 'Literal' || !isString(node.source.value) || !node.source.value.startsWith('.')) { + return []; + } + const targetPath = path.normalize(path.join(path.dirname(facts.file), node.source.value)).replaceAll('\\', '/'); + const target = factsByPath.get(targetPath); + if (target === undefined) { + return []; + } + return node.specifiers.flatMap((specifier) => { + const importedName = propertyName(specifier.local); + const exportedName = propertyName(specifier.exported); + return specifier.type === 'ExportSpecifier' && + node.exportKind !== 'type' && + specifier.exportKind !== 'type' && + importedName !== undefined && + exportedName !== undefined && + isDrizzleDeclaration(target.variables.get(importedName), target, factsByPath, path) + ? [evidenceAt(facts, workspace, 'export', `${facts.file}#${exportedName}`, specifier.start, reason)] + : []; + }); }; +const reflectedDrizzleExports = ( + facts: SourceFacts, + factsByPath: ReadonlyMap, + workspace: string, + configSource: string, + path: Path.Path, +): KnipModelEvidence[] => + facts.program.body.flatMap((node) => reflectedDrizzleExport(facts, node, factsByPath, workspace, configSource, path)); + const resolver = createRequire(import.meta.url); const packageName = (specifier: string): string => specifier.startsWith('@') ? specifier.split('/').slice(0, 2).join('/') : (specifier.split('/')[0] ?? specifier); @@ -1351,6 +1435,7 @@ const drizzleEvidence = ( factsByPath: ReadonlyMap, prefix: string, workspace: string, + path: Path.Path, ): KnipModelEvidence[] => { const evidence: KnipModelEvidence[] = []; for (const facts of factsByPath.values()) { @@ -1360,7 +1445,7 @@ const drizzleEvidence = ( const schema = staticString(objectValue(exportedObject(facts), 'schema'), facts.variables); const target = schema === undefined ? undefined : factsByPath.get(`${prefix}${schema.replace(/^\.\//u, '')}`); if (target !== undefined) { - evidence.push(...reflectedDrizzleExports(target, workspace, facts.file)); + evidence.push(...reflectedDrizzleExports(target, factsByPath, workspace, facts.file, path)); } } return evidence; @@ -1543,7 +1628,7 @@ const workspaceModel = Effect.fn('QualityAudit.knipWorkspaceModel')(function* bu evidence.push(...catalogAliasEvidence(factsByPath, manifest, prefix, workspace, path)); evidence.push(...generatedModuleApiEvidence(factsByPath, prefix, workspace)); evidence.push(...generatedOutboxMessageEvidence(factsByPath, manifest, prefix, workspace)); - evidence.push(...drizzleEvidence(factsByPath, prefix, workspace)); + evidence.push(...drizzleEvidence(factsByPath, prefix, workspace, path)); const aliasFiles = new Set( evidence .filter((fact) => fact.kind === 'alias') diff --git a/app/quality-audit/lint-suppressions.json b/app/quality-audit/lint-suppressions.json index 27252f30e..5507439c1 100644 --- a/app/quality-audit/lint-suppressions.json +++ b/app/quality-audit/lint-suppressions.json @@ -1,51 +1,52 @@ { "rules": { - "anti-slop-effect/no-service-constructor-imports": 21, + "anti-slop-effect/no-service-constructor-imports": 71, "anti-slop/no-chained-type-assertions": 13, "anti-slop/no-conditional-empty-object-spread": 13, "anti-slop/no-known-value-widening": 6, "anti-slop/no-object-parameters": 3, "anti-slop/no-reflect-get": 1, "anti-slop/no-runtime-typeof": 9, - "anti-slop/no-unknown-parameters": 48, + "anti-slop/no-unknown-parameters": 51, "anti-slop/no-unknown-returns": 4, "anti-slop/no-unsafe-dictionary-type": 12, "anti-slop/require-safety-comment-for-type-assertion": 4, - "complexity": 5, - "effect-native/no-dependency-parameters": 49, + "complexity": 6, + "effect-native/no-dependency-parameters": 74, "effect-native/no-driver-failure-inspection": 3, "effect-native/no-duplicate-literal-vocabulary": 1, - "effect-native/no-effect-provide-in-library": 8, + "effect-native/no-effect-provide-in-library": 9, "effect-native/no-failure-discarding-error-callback": 12, - "effect-native/no-hand-built-problem-details": 8, - "effect-native/no-hand-rolled-tagged-union": 3, + "effect-native/no-hand-built-problem-details": 28, + "effect-native/no-hand-rolled-tagged-union": 4, "effect-native/no-imperative-loop-in-effect-gen": 2, "effect-native/no-json-schema-as-document-contract": 3, - "effect-native/no-layer-provide-in-library": 1, + "effect-native/no-layer-provide-in-library": 3, "effect-native/no-literal-union-type-alias": 5, "effect-native/no-local-defect-seam": 2, - "effect-native/no-manual-tag-comparison": 34, + "effect-native/no-manual-tag-comparison": 35, "effect-native/no-native-error-construction": 8, - "effect-native/no-nullable-schema-field": 43, + "effect-native/no-native-json-stringify": 1, + "effect-native/no-nullable-schema-field": 50, "effect-native/no-nullable-service-outcome": 3, - "effect-native/no-per-operation-http-api-client": 15, + "effect-native/no-per-operation-http-api-client": 17, "effect-native/no-promise-shaped-port": 3, - "effect-native/no-refinement-outside-schema": 18, - "effect-native/no-scattered-browser-effect-run": 5, - "effect-native/no-sequential-independent-yields": 14, + "effect-native/no-refinement-outside-schema": 19, + "effect-native/no-scattered-browser-effect-run": 6, + "effect-native/no-sequential-independent-yields": 17, "effect-native/no-string-timestamp-schema": 5, "effect-native/no-structural-document-walking": 2, - "effect-native/no-sync-schema-codec": 1, - "effect-native/no-threaded-correlation-parameter": 13, + "effect-native/no-sync-schema-codec": 3, + "effect-native/no-threaded-correlation-parameter": 14, "effect-native/no-throw-in-effect-callback": 1, "effect-native/no-unbranded-identifier-schema": 18, "effect-native/no-unmanaged-mutable-state": 2, - "effect-native/no-wide-factory-signature": 9, - "effect-native/prefer-effect-fn-for-operations": 2, + "effect-native/no-wide-factory-signature": 21, + "effect-native/prefer-effect-fn-for-operations": 3, "effect-native/prefer-match-over-tag-switch": 9, - "effect-native/require-context-service-for-service-interface": 17, + "effect-native/require-context-service-for-service-interface": 35, "effect-native/require-timeout-on-external-effect": 2, - "eslint/complexity": 9, + "eslint/complexity": 15, "eslint/default-case": 2, "eslint/func-style": 2, "eslint/max-classes-per-file": 8, @@ -58,26 +59,27 @@ "github/filenames-match-regex": 19, "github/js-class-name": 1, "import/no-duplicates": 1, + "import/no-namespace": 1, "max-classes-per-file": 5, "no-duplicate-imports": 1, "no-negated-condition": 2, "no-nested-ternary": 2, "no-unused-vars": 19, "no-use-before-define": 1, - "oxc/no-barrel-file": 20, + "oxc/no-barrel-file": 21, "perfectionist/sort-object-types": 1, - "perfectionist/sort-objects": 9, + "perfectionist/sort-objects": 29, "prefer-destructuring": 1, "prefer-object-spread": 1, - "promise/prefer-await-to-callbacks": 7, + "promise/prefer-await-to-callbacks": 8, "promise/prefer-await-to-then": 4, "react-doctor/js-cache-property-access": 1, "react-doctor/js-combine-iterations": 1, "sonarjs/no-built-in-override": 1, "sonarjs/no-duplicate-string": 26, - "sonarjs/no-nested-functions": 26, + "sonarjs/no-nested-functions": 44, "sonarjs/no-undefined-assignment": 5, - "sonarjs/no-wildcard-import": 16, + "sonarjs/no-wildcard-import": 18, "sonarjs/too-many-break-or-continue-in-loop": 2, "sonarjs/use-type-alias": 1, "typescript/array-type": 1, @@ -92,12 +94,13 @@ "typescript/promise-function-async": 10, "typescript/switch-exhaustiveness-check": 7, "unicorn/consistent-function-scoping": 3, - "unicorn/no-array-method-this-argument": 4, + "unicorn/no-array-method-this-argument": 8, "unicorn/no-array-reduce": 2, "unicorn/no-array-sort": 2, "unicorn/no-negated-condition": 2, "unicorn/no-nested-ternary": 2, - "unicorn/no-useless-undefined": 25, + "unicorn/no-useless-undefined": 26, + "unicorn/prefer-export-from": 8, "unicorn/prefer-number-coercion": 1, "unicorn/prefer-ternary": 1, "unicorn/switch-case-braces": 1 diff --git a/app/scripts/check-module-entrypoint-boundaries.mts b/app/scripts/check-module-entrypoint-boundaries.mts index 0b91c2c68..37570ec4b 100644 --- a/app/scripts/check-module-entrypoint-boundaries.mts +++ b/app/scripts/check-module-entrypoint-boundaries.mts @@ -1148,7 +1148,10 @@ const validateManifestImports = ( const manifestImports = new Set( readImportedModuleSpecifiers(sourceOrEmpty(state.sourceMap, normalizedFile)) .filter((specifier) => specifier.startsWith('./')) - .map((specifier) => `${path.join(manifestDirectory, specifier).replaceAll('\\', '/')}.ts`), + .map((specifier) => { + const importedFile = path.join(manifestDirectory, specifier).replaceAll('\\', '/'); + return importedFile.endsWith('.ts') ? importedFile : `${importedFile}.ts`; + }), ); const missing = [...sourceFiles].filter((file) => !manifestImports.has(file)); const stale = [...manifestImports].filter((file) => !sourceFiles.has(file)); diff --git a/app/scripts/generated-governed-http-boundary.mts b/app/scripts/generated-governed-http-boundary.mts index ddecf73b6..294ce1845 100644 --- a/app/scripts/generated-governed-http-boundary.mts +++ b/app/scripts/generated-governed-http-boundary.mts @@ -1250,7 +1250,9 @@ const thinServerImportSpans = (source: string, allowedImports: ReadonlySet [ /const problems\s*=\s*/u, new RegExp(`export const ${escapeRegExp(exportedName)}\\s*=\\s*`, 'u'), - ...(domainMapperName === undefined ? [] : [new RegExp(`const ${escapeRegExp(domainMapperName)}\\s*=\\s*`, 'u')]), + ...(domainMapperName === undefined + ? [] + : [new RegExp(`(?:export\\s+)?const ${escapeRegExp(domainMapperName)}\\s*=\\s*`, 'u')]), ]; const removeSourceSpans = (source: string, spans: readonly SourceSpan[]): string => @@ -1811,7 +1813,7 @@ export const hasGeneratedActionRegistrationBinding = ( const actionName = escapeRegExp(`${camel}Action`); const direct = new RegExp(`^export const ${actionName} = defineAction\\(`, 'mu'); const typed = new RegExp( - `^export const ${actionName}\\s*:\\s*ActionRegistration<\\s*typeof ${escapeRegExp(type)}PayloadSchema\\s*,\\s*typeof ${escapeRegExp(type)}ResultSchema\\s*,\\s*typeof (?[A-Z][A-Za-z0-9]*ErrorSchema)\\s*,\\s*Readonly>\\s*,\\s*['"]${escapeRegExp(moduleId)}['"]\\s*,\\s*(?[A-Z][A-Za-z0-9]*Services)\\s*>\\s*=\\s*defineAction\\(`, + `^export const ${actionName}\\s*:\\s*ActionRegistration<\\s*typeof ${escapeRegExp(type)}PayloadSchema\\s*,\\s*typeof ${escapeRegExp(type)}ResultSchema\\s*,\\s*typeof (?[A-Z][A-Za-z0-9]*ErrorSchema)\\s*,\\s*(?Readonly>|typeof domainEvents)\\s*,\\s*['"]${escapeRegExp(moduleId)}['"]\\s*,\\s*(?[A-Z][A-Za-z0-9]*Services)(?:\\s*,\\s*(?[A-Z][A-Za-z0-9]*))?\\s*>\\s*=\\s*defineAction\\(`, 'mu', ); const directMatch = direct.exec(source); @@ -1823,6 +1825,7 @@ export const hasGeneratedActionRegistrationBinding = ( typedMatch !== null && isCodePosition(source, typedMatch.index) && source.includes(`domainErrorSchema: ${typedMatch.groups?.error},`) && + (typedMatch.groups?.events !== 'typeof domainEvents' || source.includes('domainEvents,')) && source.includes(`payloadSchema: ${type}PayloadSchema,`) && source.includes(`resultSchema: ${type}ResultSchema,`) ); diff --git a/app/scripts/ops/stage-zerops-services.mts b/app/scripts/ops/stage-zerops-services.mts index d34c70666..ef725400d 100644 --- a/app/scripts/ops/stage-zerops-services.mts +++ b/app/scripts/ops/stage-zerops-services.mts @@ -78,6 +78,7 @@ export const RETIRED_STAGE_SERVICES = [ { hostname: 'pricing', setup: 'pricing' }, { hostname: 'storefrontregistry', setup: 'storefront-registry' }, { hostname: 'pricegroupcatalog', setup: 'price-group-catalog' }, + { hostname: 'inventory', setup: 'inventory' }, ] as const; const EnvironmentKeySchema = Schema.NonEmptyString.pipe(Schema.brand('ZeropsEnvironmentKey')); diff --git a/app/scripts/outbox-worker-host.generated.mts b/app/scripts/outbox-worker-host.generated.mts index de7325bd3..bd3653cb0 100644 --- a/app/scripts/outbox-worker-host.generated.mts +++ b/app/scripts/outbox-worker-host.generated.mts @@ -3,12 +3,14 @@ import { startOutboxWorkerHost } from '@app/core-runtime/outbox/worker'; import { outboxWorkerEntry as partyRegistryOutboxWorkerEntry } from '@app/party-registry/outbox-worker-host'; import { outboxWorkerEntry as commerceCustomerContextOutboxWorkerEntry } from '@app/commerce-customer-context/outbox-worker-host'; import { outboxWorkerEntry as priceGroupCatalogOutboxWorkerEntry } from '@app/price-group-catalog/outbox-worker-host'; +import { outboxWorkerEntry as inventoryOutboxWorkerEntry } from '@app/inventory/outbox-worker-host'; startOutboxWorkerHost({ entries: [ partyRegistryOutboxWorkerEntry, commerceCustomerContextOutboxWorkerEntry, priceGroupCatalogOutboxWorkerEntry, + inventoryOutboxWorkerEntry, ], health: true, }); diff --git a/app/scripts/postgres/bootstrap-runtime-role.mts b/app/scripts/postgres/bootstrap-runtime-role.mts index cb0b441cb..daa87bbe4 100644 --- a/app/scripts/postgres/bootstrap-runtime-role.mts +++ b/app/scripts/postgres/bootstrap-runtime-role.mts @@ -56,7 +56,7 @@ const bootstrapRuntimeRole = ( ); yield* query(client, `grant connect on database ${quoteIdentifier(database)} to ontos_runtime`); yield* Effect.forEach( - ['core', 'auth', 'contacts', 'party', 'catalog'], + ['core', 'auth', 'contacts', 'party', 'catalog', 'inventory'], (schema) => Effect.gen(function* grantSchemaPrivilegesEffect() { const schemaExists = yield* query<{ exists: boolean }>( diff --git a/app/scripts/run-zerops-migrator.mjs b/app/scripts/run-zerops-migrator.mjs index 0fbc38416..f5b8be7c2 100644 --- a/app/scripts/run-zerops-migrator.mjs +++ b/app/scripts/run-zerops-migrator.mjs @@ -162,6 +162,7 @@ const main = Effect.scoped( yield* migrate('verticals/commerce-customer-context', 'drizzle.config.ts'); yield* migrate('verticals/commerce-market-catalog', 'drizzle.config.ts'); yield* migrate('verticals/catalog', 'drizzle.config.ts'); + yield* migrate('verticals/inventory', 'drizzle.config.ts'); yield* migrate('verticals/pricing', 'drizzle.config.ts'); yield* migrate('verticals/storefront-registry', 'drizzle.config.ts'); yield* runAppScript('scripts/postgres/bootstrap-runtime-role.mts'); diff --git a/app/scripts/scaffolding/cli.mts b/app/scripts/scaffolding/cli.mts index dc8f06208..7732dea61 100644 --- a/app/scripts/scaffolding/cli.mts +++ b/app/scripts/scaffolding/cli.mts @@ -672,14 +672,14 @@ Options: permission: defineCommand({ flags: ['permission', 'scope', 'vertical'], generator: permissionGenerator, - help: `Usage: pnpm scaffold:permission -- --vertical --permission --scope + help: `Usage: pnpm scaffold:permission -- --vertical --permission --scope Generate one versioned, fail-closed business Permission declaration and register it in the module manifest. Generated Permissions start non-delegable and with no authority-group or protected-entrypoint membership. Required flags: --vertical Existing generated vertical folder (lower-kebab-case) - --permission Stable lowercase retail.*, counterparty.*, pricing.price_group.*, or one of the approved assortment.* codes + --permission Stable lowercase retail.*, counterparty.*, inventory.*, pricing.price_group.*, or one of the approved assortment.* codes --scope Exact business target scope Options: @@ -693,6 +693,7 @@ Options: scope !== 'retail_profile' && scope !== 'counterparty' && scope !== 'counterparty_storefront' && + scope !== 'inventory_resource' && scope !== 'pricing_catalog' && scope !== 'price_group' && scope !== 'assortment_configuration' && @@ -702,7 +703,7 @@ Options: scope !== 'assortment_boundary' ) { return yield* failScaffolding( - '--scope must be retail_profile, counterparty, counterparty_storefront, pricing_catalog, price_group, assortment_configuration, assortment_decision, assortment_rule, assortment_binding, or assortment_boundary', + '--scope must be retail_profile, counterparty, counterparty_storefront, inventory_resource, pricing_catalog, price_group, assortment_configuration, assortment_decision, assortment_rule, assortment_binding, or assortment_boundary', ); } return { diff --git a/app/scripts/scaffolding/permission/scaffold.mts b/app/scripts/scaffolding/permission/scaffold.mts index 4cde9226a..cdd997a81 100644 --- a/app/scripts/scaffolding/permission/scaffold.mts +++ b/app/scripts/scaffolding/permission/scaffold.mts @@ -24,7 +24,7 @@ import type { OntosVerticalMetadata, PermissionScaffoldConfig } from '../shared. const PERMISSION_GENERATOR_HEADER = '// @generated by OntOS Codesmith Business Permission v1'; const permissionCodePattern = - /^(?:(?:retail|counterparty)(?:\.[a-z][a-z0-9_]*)+|pricing\.price_group(?:\.[a-z][a-z0-9_]*)+|assortment(?:\.[a-z][a-z0-9_]*)+)$/u; + /^(?:(?:retail|counterparty|inventory)(?:\.[a-z][a-z0-9_]*)+|pricing\.price_group(?:\.[a-z][a-z0-9_]*)+|assortment(?:\.[a-z][a-z0-9_]*)+)$/u; const assortmentPermissionScopes = { 'assortment.binding.create': 'assortment_binding', 'assortment.binding.end': 'assortment_binding', @@ -40,7 +40,7 @@ const assortmentPermissionScopes = { const requirePermissionCode = (value: string): string => { if (!permissionCodePattern.test(value)) { return raiseScaffoldFailure( - 'permission must be a stable retail.*, counterparty.*, pricing.price_group.*, or one of the approved assortment.* lowercase dotted codes', + 'permission must be a stable retail.*, counterparty.*, inventory.*, pricing.price_group.*, or one of the approved assortment.* lowercase dotted codes', ); } if (value.startsWith('assortment.') && !Object.hasOwn(assortmentPermissionScopes, value)) { @@ -54,12 +54,18 @@ const requireCompatibleScope = ( scope: PermissionScaffoldConfig['scope'], ): PermissionScaffoldConfig['scope'] => { const pricingPermission = permission.startsWith('pricing.price_group.'); + const inventoryPermission = permission.startsWith('inventory.'); const pricingScope = scope === 'pricing_catalog' || scope === 'price_group'; if (pricingPermission !== pricingScope) { return raiseScaffoldFailure( 'pricing.price_group.* permissions require pricing_catalog or price_group scope, and those scopes reject other permission families', ); } + if (inventoryPermission !== (scope === 'inventory_resource')) { + return raiseScaffoldFailure( + 'inventory.* permissions require inventory_resource scope, and that scope rejects other permission families', + ); + } const expectedAssortmentScope = Object.entries(assortmentPermissionScopes).find(([code]) => code === permission)?.[1]; if (expectedAssortmentScope !== undefined && expectedAssortmentScope !== scope) { return raiseScaffoldFailure(`permission ${permission} requires --scope ${expectedAssortmentScope}`); @@ -67,6 +73,12 @@ const requireCompatibleScope = ( return scope; }; +const requireCompatibleOwner = (vertical: OntosVerticalMetadata, permission: string): void => { + if (permission.startsWith('inventory.') && vertical.moduleId !== 'commerce.inventory') { + return raiseScaffoldFailure('inventory.* permissions must be owned by the commerce.inventory module'); + } +}; + const permissionSlug = (permission: string): string => permission.replaceAll('.', '-').replaceAll('_', '-'); const descriptorName = (permission: string): string => `${toCamelCase(permissionSlug(permission))}Permission`; @@ -104,6 +116,7 @@ const planPermissionScaffold = Effect.fn('PermissionScaffold.plan')(function* pl requireCompatibleScope(permission, config.scope), ); const vertical = yield* discoverOntosModuleEffect(workspaceRoot, config.vertical); + yield* tryScaffold('permission owner is invalid', () => requireCompatibleOwner(vertical, permission)); const slug = permissionSlug(permission); const permissionPath = yield* tryScaffold('failed to resolve permission path', () => resolveContainedPath(vertical.directory, 'shared', 'permissions', `${slug}.ts`), diff --git a/app/scripts/scaffolding/shared.mts b/app/scripts/scaffolding/shared.mts index adf6d8fcc..7924260d4 100644 --- a/app/scripts/scaffolding/shared.mts +++ b/app/scripts/scaffolding/shared.mts @@ -259,6 +259,7 @@ export interface PermissionScaffoldConfig { | 'assortment_rule' | 'counterparty' | 'counterparty_storefront' + | 'inventory_resource' | 'price_group' | 'pricing_catalog' | 'retail_profile'; diff --git a/app/scripts/scaffolding/tests/permission-generator.test.mts b/app/scripts/scaffolding/tests/permission-generator.test.mts index fb8f17ae5..b53445e55 100644 --- a/app/scripts/scaffolding/tests/permission-generator.test.mts +++ b/app/scripts/scaffolding/tests/permission-generator.test.mts @@ -10,10 +10,13 @@ import { getHelpText, runScaffoldEffect } from '../cli.mts'; const vertical = 'customer-context'; const moduleId = 'commerce.customer-context'; +const inventoryVertical = 'inventory'; +const inventoryModuleId = 'commerce.inventory'; const addressBookPermission = 'counterparty.address_book.use'; const paymentTermPreferencePermission = 'retail.settings.payment_term_preference.manage'; const repeatOrderPermission = 'retail.repeat_order'; const priceGroupReadPermission = 'pricing.price_group.read'; +const inventoryResourceReadPermission = 'inventory.resource.read'; const assortmentPermissions = [ ['assortment.configuration.read', 'assortment_configuration'], ['assortment.decision.explain', 'assortment_decision'], @@ -33,6 +36,7 @@ const PermissionScopeSchema = Schema.Literals([ 'assortment_rule', 'counterparty', 'counterparty_storefront', + 'inventory_resource', 'price_group', 'pricing_catalog', 'retail_profile', @@ -49,28 +53,28 @@ const descriptorName = (permission: string): string => { return `${first}${rest.map(capitalise).join('')}Permission`; }; -const createFixture = (): Effect.Effect => +const createFixture = (fixtureVertical = vertical, fixtureModuleId = moduleId): Effect.Effect => Effect.gen(function* createPermissionFixture() { const root = yield* Effect.promise(() => mkdtemp(path.join(tmpdir(), 'ontos-permission-scaffold-'))); yield* write(root, 'package.json', json({ name: 'fixture', private: true, type: 'module' })); yield* write( root, - `verticals/${vertical}/package.json`, + `verticals/${fixtureVertical}/package.json`, json({ exports: { '.': './src/index.ts' }, modernjs: { - appId: vertical, + appId: fixtureVertical, ontosModule: { contractPath: '/.well-known/ontos-module-manifest.json', manifest: './vertical.manifest.ts', - moduleId, + moduleId: fixtureModuleId, registration: './vertical.registration.ts', schemaVersion: 2, }, role: 'module-federation-remote', topology: '../../topology/reference-topology.json', }, - name: `@app/${vertical}`, + name: `@app/${fixtureVertical}`, private: true, type: 'module', }), @@ -81,21 +85,21 @@ const createFixture = (): Effect.Effect => json({ verticals: [ { - id: vertical, + id: fixtureVertical, kind: 'vertical', - package: `@app/${vertical}`, - path: `verticals/${vertical}`, + package: `@app/${fixtureVertical}`, + path: `verticals/${fixtureVertical}`, }, ], }), ); const ownerHeader = `// @generated by OntOS Codesmith Module Contract v1 -// @ontos-deployment-app-id ${vertical} -// @ontos-module-id ${moduleId} +// @ontos-deployment-app-id ${fixtureVertical} +// @ontos-module-id ${fixtureModuleId} `; yield* write( root, - `verticals/${vertical}/vertical.manifest.ts`, + `verticals/${fixtureVertical}/vertical.manifest.ts`, `${ownerHeader}// // export const manifest = { @@ -110,7 +114,7 @@ export const manifest = { ); yield* write( root, - `verticals/${vertical}/vertical.registration.ts`, + `verticals/${fixtureVertical}/vertical.registration.ts`, `${ownerHeader}export const registration = {}; `, ); @@ -118,12 +122,14 @@ export const manifest = { }); const withFixture = withCreatedFixture(createFixture()); +const withInventoryFixture = withCreatedFixture(createFixture(inventoryVertical, inventoryModuleId)); const scaffoldPermission = ( root: string, permission = addressBookPermission, scope: PermissionScope = 'counterparty_storefront', + targetVertical = vertical, ) => - runScaffoldEffect('permission', ['--vertical', vertical, '--permission', permission, '--scope', scope], { + runScaffoldEffect('permission', ['--vertical', targetVertical, '--permission', permission, '--scope', scope], { workspaceRoot: root, }).pipe(Effect.provide(NodeServices.layer)); @@ -137,9 +143,11 @@ it.live('permission help is write-free and documents exact business scopes', () expect(result.help).toMatch(/pricing\.price_group\.\*/u); expect(result.help).toMatch(/pricing_catalog\|price_group/u); expect(result.help).toMatch( - /retail_profile\|counterparty\|counterparty_storefront\|pricing_catalog\|price_group\|assortment_configuration\|assortment_decision\|assortment_rule\|assortment_binding\|assortment_boundary/u, + /retail_profile\|counterparty\|counterparty_storefront\|inventory_resource\|pricing_catalog\|price_group\|assortment_configuration\|assortment_decision\|assortment_rule\|assortment_binding\|assortment_boundary/u, + ); + expect(result.help).toMatch( + /retail\.\*\|counterparty\.\*\|inventory\.\*\|pricing\.price_group\.\*\|assortment\.\*/u, ); - expect(result.help).toMatch(/retail\.\*\|counterparty\.\*\|pricing\.price_group\.\*\|assortment\.\*/u); expect(result.help).toMatch(/start non-delegable/u); } }), @@ -177,6 +185,52 @@ it.live('generates and registers tenant-only Pricing permissions for both canoni ), ); +it.live('generates and registers exact Inventory Resource permissions', () => + withInventoryFixture( + Effect.fn(function* generatesInventoryPermission(root) { + const result = yield* scaffoldPermission( + root, + inventoryResourceReadPermission, + 'inventory_resource', + inventoryVertical, + ); + expect(result.kind).toBe('generated'); + const [permissionSource, manifest, packageSource] = yield* Effect.all([ + Effect.promise(() => + readFile( + path.join(root, `verticals/${inventoryVertical}/shared/permissions/inventory-resource-read.ts`), + 'utf-8', + ), + ), + Effect.promise(() => readFile(path.join(root, `verticals/${inventoryVertical}/vertical.manifest.ts`), 'utf-8')), + Effect.promise(() => readFile(path.join(root, `verticals/${inventoryVertical}/package.json`), 'utf-8')), + ]); + expect(permissionSource).toMatch(/key: 'inventory\.resource\.read'/u); + expect(permissionSource).toMatch(/allowedScopeKinds: \['inventory_resource'\]/u); + expect(permissionSource).toMatch(/owningCapability: 'commerce\.inventory'/u); + expect(manifest).toMatch(/inventoryResourceReadPermission,/u); + const packageValue = yield* Schema.decodeUnknownEffect(PackageExportsSchema)(JSON.parse(packageSource)); + expect(packageValue.exports['./permissions/inventory.resource.read']).toBe( + './shared/permissions/inventory-resource-read.ts', + ); + }), + ), +); + +it.live('rejects Inventory permissions for a wrong owning module without partial writes', () => + withFixture( + Effect.fn(function* rejectsWrongInventoryOwner(root) { + const before = yield* snapshotTree(root); + const failure = yield* scaffoldPermission(root, inventoryResourceReadPermission, 'inventory_resource').pipe( + Effect.sandbox, + Effect.flip, + ); + expect(String(Cause.squash(failure))).toMatch(/inventory\.\*.*commerce\.inventory/u); + expect(yield* snapshotTree(root)).toEqual(before); + }), + ), +); + it.live('generates and registers conservative versioned business permissions sequentially', () => withFixture( Effect.fn(function* generatesPermission(root) { @@ -320,6 +374,13 @@ it.live('rejects malformed and duplicate permissions without partial writes', () ); expect(String(Cause.squash(wrongScope))).toMatch(/requires --scope assortment_rule/u); expect(yield* snapshotTree(root)).toEqual(before); + const mismatchedInventoryScope = yield* scaffoldPermission( + root, + addressBookPermission, + 'inventory_resource', + ).pipe(Effect.sandbox, Effect.flip); + expect(String(Cause.squash(mismatchedInventoryScope))).toMatch(/inventory\.\*.*inventory_resource/u); + expect(yield* snapshotTree(root)).toEqual(before); yield* scaffoldPermission(root); const after = yield* snapshotTree(root); const duplicate = yield* scaffoldPermission(root).pipe(Effect.sandbox, Effect.flip); diff --git a/app/scripts/tests/active-application-composition.test.mts b/app/scripts/tests/active-application-composition.test.mts index 68583447c..9478457c7 100644 --- a/app/scripts/tests/active-application-composition.test.mts +++ b/app/scripts/tests/active-application-composition.test.mts @@ -370,6 +370,7 @@ it.effect('restarts exactly the Outbox Worker mode services whose start prefligh 'party-registry-worker', CUSTOMER_CONTEXT_WORKER, 'price-group-catalog-worker', + 'inventory-worker', ]); // A switch also shows as this mode's workers not running yet. expect(yield* modeWorkerSetups(zeropsYaml, topology, 'host')).toEqual([OUTBOX_WORKER_HOST_SETUP]); diff --git a/app/scripts/tests/cloudflare-stage-cost-guard.test.mts b/app/scripts/tests/cloudflare-stage-cost-guard.test.mts index 2eea17470..942ede556 100644 --- a/app/scripts/tests/cloudflare-stage-cost-guard.test.mts +++ b/app/scripts/tests/cloudflare-stage-cost-guard.test.mts @@ -54,6 +54,7 @@ const HOSTNAMES = [ 'ontos-stage-pricing.stage.example.com', 'ontos-stage-storefront-registry.stage.example.com', 'ontos-stage-price-group-catalog.stage.example.com', + 'ontos-stage-inventory.stage.example.com', SHELL_HOSTNAME, ]; diff --git a/app/scripts/tests/cloudflare-stage-cutover.test.mts b/app/scripts/tests/cloudflare-stage-cutover.test.mts index 65c3eab6c..a96ec4db1 100644 --- a/app/scripts/tests/cloudflare-stage-cutover.test.mts +++ b/app/scripts/tests/cloudflare-stage-cutover.test.mts @@ -86,6 +86,7 @@ const VERTICAL_HOSTS = [ 'pricing', 'storefrontregistry', 'pricegroupcatalog', + 'inventory', ]; const SECRET_VALUES = { @@ -290,7 +291,7 @@ it.effect('provisions the whole stage data plane on an empty account, without ex ULTRAMODERN_PUBLIC_URL_PRICING: 'https://ontos-stage-pricing.stage.example.com', ULTRAMODERN_PUBLIC_URL_SHELL_SUPER_APP: SHELL_ORIGIN, }); - expect(placement.units).toHaveLength(10); + expect(placement.units).toHaveLength(11); expect(stage.environments.has(STAGE_EDGE)).toBe(true); expect(stage.variables.get(STAGE_EDGE)?.get('CLOUDFLARE_ACCOUNT_ID')).toBe('account-1'); expect(stage.inputs.find(({ command }) => command.startsWith('gh secret set CLOUDFLARE_API_TOKEN'))?.stdin).toBe( @@ -299,7 +300,7 @@ it.effect('provisions the whole stage data plane on an empty account, without ex // Every placed Worker receives its secrets through `wrangler secret bulk` on stdin. const bulk = stage.inputs.filter(({ command }) => command.includes('wrangler secret bulk')); - expect(bulk.map(({ command }) => command.split(' ').at(-1))).toHaveLength(10); + expect(bulk.map(({ command }) => command.split(' ').at(-1))).toHaveLength(11); const shell = bulk.find(({ command }) => command.endsWith('--name app-shell-super-app')); expect(Schema.decodeUnknownSync(StringRecord)(shell?.stdin)).toStrictEqual({ BETTER_AUTH_SECRET: AUTH_SECRET, @@ -593,6 +594,7 @@ const provisionedAccount = ( 'app-pricing', 'app-storefront-registry', 'app-price-group-catalog', + 'app-inventory', 'app-shell-super-app', ], secrets: Object.fromEntries( @@ -824,7 +826,7 @@ it.effect('gives every vertical the Shell key and the callers their stage depend const reveal = (worker: string) => Object.fromEntries(Object.entries(plan.get(worker) ?? {}).map(([key, value]) => [key, Redacted.value(value)])); - expect([...plan.keys()]).toHaveLength(10); + expect([...plan.keys()]).toHaveLength(11); expect(reveal(CUSTOMER_CONTEXT_WORKER)).toMatchObject({ ONTOS_CATALOG_BASE_URL: 'https://ontos-stage-catalog.stage.example.com/catalog-api', ONTOS_PRICE_GROUP_CATALOG_BASE_URL: diff --git a/app/scripts/tests/module-entrypoint-boundaries.test.mts b/app/scripts/tests/module-entrypoint-boundaries.test.mts index a6840fd4b..c9cefc6b0 100644 --- a/app/scripts/tests/module-entrypoint-boundaries.test.mts +++ b/app/scripts/tests/module-entrypoint-boundaries.test.mts @@ -40,6 +40,14 @@ it('accepts a typed Codesmith Action binding but rejects spoofed or mismatched r handleConfirmGtin, gtinServicesForScope, );`; expect(acceptsTypedGtinBinding(binding)).toBe(true); + expect( + acceptsTypedGtinBinding( + binding.replace( + 'GtinServices\n > = defineAction(', + 'GtinServices, GtinHandlerRequirements\n > = defineAction(', + ), + ), + ).toBe(true); expect(acceptsTypedGtinBinding(binding.replace("'commerce.catalog'", "'other.module'"))).toBe(false); expect(acceptsTypedGtinBinding(binding.replace('typeof ConfirmGtinResultSchema', 'typeof WrongResultSchema'))).toBe( false, @@ -384,6 +392,30 @@ it('governed servers bind the trusted handler, authentication, registration, and const accepts = (candidate: string, api = closedApi): boolean => hasGeneratedGovernedServerContract(candidate, exportedName, api); expect(accepts(source)).toBe(true); + const withExportedDomainMapper = source + .replace( + "import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge';", + "import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge';\nimport { Schema } from 'effect';", + ) + .replace( + "StockListInternalProblemSchema } from '../shared/apis/stock-list.ts';", + "StockListInternalProblemSchema, StockListDomainPolicyProblemSchema } from '../shared/apis/stock-list.ts';", + ) + .replace( + 'const problems = makeGovernedReadProblems({', + `export const mapStockListDomainError = ( + error: unknown, +): typeof StockListDomainPolicyProblemSchema.Type => { + Schema.is(Schema.Unknown)(error); + return StockListDomainPolicyProblemSchema.make({ detail: 'Rejected' }); +}; +const problems = makeGovernedReadProblems({`, + ) + .replace( + ' authenticatePrincipal: authenticateOperationPrincipal,', + ' authenticatePrincipal: authenticateOperationPrincipal,\n mapDomainError: mapStockListDomainError,', + ); + expect(accepts(withExportedDomainMapper)).toBe(true); expect(accepts(source.replace(MODULE_API_HEADER, ''))).toBe(false); expect(accepts(source.replace(' problems,', ' problems: problems,'))).toBe(true); for (const [expected, replacement] of [ diff --git a/app/scripts/tests/provision-current-action-authorization.test.mts b/app/scripts/tests/provision-current-action-authorization.test.mts index b55209489..f85d70ae8 100644 --- a/app/scripts/tests/provision-current-action-authorization.test.mts +++ b/app/scripts/tests/provision-current-action-authorization.test.mts @@ -228,6 +228,7 @@ const addedVerticalActionKeys = [ 'commerce.customer-context.trigger-purchase-approval', 'commerce.customer-context.update-customer-group', 'commerce.customer-context.update-saved-address', + 'commerce.inventory.create-inventory-reservation', 'commerce.market-catalog.activate-market', 'commerce.market-catalog.associate-storefront', 'commerce.market-catalog.create-market', @@ -255,6 +256,25 @@ const explicitlyProvisionedActionKeys = [ 'commerce.customer-context.record-portal-enrollment-outcome', 'commerce.customer-context.start-portal-enrollment', 'commerce.customer-context.terminate-portal-enrollment', + 'commerce.inventory.change-stock-sharing-eligibility', + 'commerce.inventory.compensate-inventory-pre-commit', + 'commerce.inventory.correct-catalog-to-stock-binding', + 'commerce.inventory.correct-external-stock-correlation', + 'commerce.inventory.correct-stock-position', + 'commerce.inventory.end-catalog-to-stock-binding', + 'commerce.inventory.end-external-stock-correlation', + 'commerce.inventory.end-stock-sharing-eligibility', + 'commerce.inventory.establish-catalog-to-stock-binding', + 'commerce.inventory.establish-commitment-protection', + 'commerce.inventory.establish-external-stock-correlation', + 'commerce.inventory.establish-stock-sharing-eligibility', + 'commerce.inventory.import-source-assertion', + 'commerce.inventory.recover-inventory-effect', + 'commerce.inventory.release-inventory-reservation', + 'commerce.inventory.resolve-inventory-source-conflict', + 'commerce.inventory.select-inventory-backend', + 'commerce.inventory.stock-issue', + 'commerce.inventory.stock-receipt', 'core.identity.activate-principal-binding', 'core.identity.change-principal-binding-status', 'core.identity.reserve-principal-binding', diff --git a/app/scripts/tests/quality-audit-model.test.mts b/app/scripts/tests/quality-audit-model.test.mts index 8c5283513..44b5ddf9e 100644 --- a/app/scripts/tests/quality-audit-model.test.mts +++ b/app/scripts/tests/quality-audit-model.test.mts @@ -393,6 +393,35 @@ it.live( }), ); +it.live( + 'Drizzle reflection models modular table re-exports without consuming unrelated exports', + Effect.fn(function* testModularDrizzleSchema() { + const root = yield* fixture(); + write( + root, + 'src/inventory-schema.ts', + "import { pgSchema } from 'drizzle-orm/pg-core'; export const inventorySchema = pgSchema('inventory');", + ); + write( + root, + 'src/inventory-table.ts', + [ + "import { text } from 'drizzle-orm/pg-core';", + "import { inventorySchema } from './inventory-schema.ts';", + "export const inventoryStockItems = inventorySchema.table.withRLS('stock_items', { id: text('id') });", + 'export const unrelatedSchemaHelper = () => 7;', + ].join('\n'), + ); + write(root, 'src/schema.ts', "export { inventoryStockItems, unrelatedSchemaHelper } from './inventory-table.ts';"); + const model = yield* buildKnipModel(root, { entry: [indexFile] }).pipe(Effect.provide(NodeServices.layer)); + const reflected = model.evidence + .filter((fact) => fact.reason.startsWith('Drizzle reflective schema consumer')) + .map((fact) => fact.target); + expect(reflected).toContain('src/schema.ts#inventoryStockItems'); + expect(reflected).not.toContain('src/schema.ts#unrelatedSchemaHelper'); + }), +); + it.live( 'modeling fails on invalid source instead of silently losing consumer evidence', Effect.fn(function* testEffect4() { diff --git a/app/scripts/tests/stage-zerops-services.test.mts b/app/scripts/tests/stage-zerops-services.test.mts index bf130499c..dc2cc6114 100644 --- a/app/scripts/tests/stage-zerops-services.test.mts +++ b/app/scripts/tests/stage-zerops-services.test.mts @@ -20,16 +20,22 @@ import type { FakeFiles, FakeStage } from './stage-operations-fixture.mts'; const RECORD_PATH = `${APP_DIRECTORY}/scripts/ops/stage-zerops-retirement.json`; // The Cloudflare target keeps these on Zerops: the data plane, the migrator, the tunnel, the Outbox Worker host, and the dedicated // workers, stopped, whose status each deploy reads to detect an OUTBOX_WORKER_MODE switch. -const OUTBOX_WORKERS = ['partyregistryworker', 'commercecstmrcntxtworker', 'pricegroupcatalogworker']; +const OUTBOX_WORKERS = [ + 'partyregistryworker', + 'commercecstmrcntxtworker', + 'pricegroupcatalogworker', + 'inventoryworker', +]; const KEPT_ON_ZEROPS = new Set(['cloudflared', 'db18', 'migrator', 'outboxworkerhost', 'spicedb', ...OUTBOX_WORKERS]); -// The original nine IDs come from the backup bundle; Assortment is new to this branch. +// The original nine IDs come from the backup bundle; Inventory and Assortment are newer additions. const STAGE_SERVICE_IDS = new Map( Object.entries({ assortment: 'assortment-id', catalog: 'IGOF5E9vQ7izD4ygQgoNiQ', commercecustomercontext: 'omIBMTDCR7iARcXTt4SqJw', commercemarketcatalog: '7nJtt1fnQMKsGRDTl6Wv1w', + inventory: 'inventory-service-id', partyregistry: 'cxNTAHZJSbiJr3xTqkypOg', paymenttermcatalog: '2FgvrWn9RzCJrfbMapwM6Q', pricegroupcatalog: 'aHab72wuSDS4AjkgxNbHDw', @@ -150,6 +156,7 @@ it('retires exactly the application services zerops-import.yaml declares, each w 'ZEROPS_CATALOG_SERVICE_ID', 'ZEROPS_COMMERCE_CUSTOMER_CONTEXT_SERVICE_ID', 'ZEROPS_COMMERCE_MARKET_CATALOG_SERVICE_ID', + 'ZEROPS_INVENTORY_SERVICE_ID', 'ZEROPS_PARTY_REGISTRY_SERVICE_ID', 'ZEROPS_PAYMENT_TERM_CATALOG_SERVICE_ID', 'ZEROPS_PRICE_GROUP_CATALOG_SERVICE_ID', diff --git a/app/scripts/tests/zerops-deployment-contract.test.mts b/app/scripts/tests/zerops-deployment-contract.test.mts index adba1b8ee..5de2fcb2a 100644 --- a/app/scripts/tests/zerops-deployment-contract.test.mts +++ b/app/scripts/tests/zerops-deployment-contract.test.mts @@ -143,6 +143,15 @@ it("stops the other Outbox Worker mode's workers after this mode's workers deplo ); }); +it('declares the Inventory public URL for Cloudflare proof', () => { + const workflow = readFileSync( + new URL('../../../.github/workflows/ultramodern-workspace-gates.yml', import.meta.url), + 'utf-8', + ); + + expect(workflow).toContain('ULTRAMODERN_PUBLIC_URL_INVENTORY: https://inventory.invalid'); +}); + it('starts a dedicated Price Group worker that drains durable pending projections after restart', () => { const zeropsYaml = readFileSync(zeropsYamlPath, 'utf-8'); const worker = serviceBlock(zeropsYaml, 'price-group-catalog-worker'); diff --git a/app/scripts/verify-application-db-schema.mts b/app/scripts/verify-application-db-schema.mts index e8e337a7f..1083ca04c 100644 --- a/app/scripts/verify-application-db-schema.mts +++ b/app/scripts/verify-application-db-schema.mts @@ -18,6 +18,7 @@ const EXPECTED_APPLICATION_SCHEMAS = [ 'commerce_market_catalog', 'contacts', 'core', + 'inventory', 'party', 'payment_term_catalog', 'price_group_catalog', @@ -32,6 +33,7 @@ const EXPECTED_MIGRATION_JOURNALS = [ '__drizzle_migrations_commerce_market_catalog', '__drizzle_migrations_contacts', '__drizzle_migrations_core', + '__drizzle_migrations_inventory', '__drizzle_migrations_party', '__drizzle_migrations_payment_term_catalog', '__drizzle_migrations_price_group_catalog', @@ -146,6 +148,7 @@ const ownerVerifierPaths = [ '../verticals/commerce-customer-context/scripts/verify-db-schema.mts', '../verticals/commerce-market-catalog/scripts/verify-db-schema.mts', '../verticals/catalog/scripts/verify-db-schema.mts', + '../verticals/inventory/scripts/verify-db-schema.mts', '../verticals/pricing/scripts/verify-db-schema.mts', '../verticals/storefront-registry/scripts/verify-db-schema.mts', ] as const; diff --git a/app/topology/authorization-rollout.json b/app/topology/authorization-rollout.json index 8d7a82f09..23987dc09 100644 --- a/app/topology/authorization-rollout.json +++ b/app/topology/authorization-rollout.json @@ -1,7 +1,7 @@ { "activatedAt": "2026-09-02T00:00:00.000Z", - "baselineInventoryHash": "5add40b2a32a640ba40169b4b37380aa9e02a5ebcd164b9e334737fd7c8016ed", - "baselineSourceRevision": "0093dca91719a3a1ffaa2844f5bd3ab13a4ebed1", + "baselineInventoryHash": "702a3aab193c460e69deaebda1282395308ff2726979833f0c73af9a7bbbd309", + "baselineSourceRevision": "59fa020f5f63f37d44622f71978b726725132e3e", "compatibilityEligibleEntrypoints": [], "decisionReference": "https://github.com/TechsioCZ/ontos/issues/173", "expiresAt": "2026-09-30T23:59:59.000Z", diff --git a/app/topology/cloudflare-placement.json b/app/topology/cloudflare-placement.json index 1e87d7373..68b2d5289 100644 --- a/app/topology/cloudflare-placement.json +++ b/app/topology/cloudflare-placement.json @@ -26,6 +26,7 @@ "pricing", "storefront-registry", "price-group-catalog", + "inventory", "shell-super-app" ], "unitServiceBindings": { diff --git a/app/topology/local-overlays/development.json b/app/topology/local-overlays/development.json index 01f76a86f..06388c901 100644 --- a/app/topology/local-overlays/development.json +++ b/app/topology/local-overlays/development.json @@ -8,7 +8,8 @@ "catalog": "http://localhost:4105/.well-known/ontos-module-manifest.json", "pricing": "http://localhost:4106/.well-known/ontos-module-manifest.json", "storefront-registry": "http://localhost:4107/.well-known/ontos-module-manifest.json", - "price-group-catalog": "http://localhost:4108/.well-known/ontos-module-manifest.json" + "price-group-catalog": "http://localhost:4108/.well-known/ontos-module-manifest.json", + "inventory": "http://localhost:4110/.well-known/ontos-module-manifest.json" }, "schemaVersion": 1, "environment": "development", @@ -23,13 +24,15 @@ "catalog": 4105, "pricing": 4106, "storefront-registry": 4107, - "price-group-catalog": 4108 + "price-group-catalog": 4108, + "inventory": 4110 }, "manifests": { "assortment": "http://localhost:4104/mf-manifest.json", "party-registry": "http://localhost:4102/mf-manifest.json", "commerce-market-catalog": "http://localhost:4109/mf-manifest.json", - "catalog": "http://localhost:4105/mf-manifest.json" + "catalog": "http://localhost:4105/mf-manifest.json", + "inventory": "http://localhost:4110/mf-manifest.json" }, "serverExecution": { "party-registry": { @@ -441,6 +444,57 @@ } } }, + "inventory": { + "apiBaseUrl": "http://localhost:4110/inventory-api", + "versionBoundary": "web-and-api-same-build", + "deliveryUnit": { + "unitId": "app/inventory", + "buildMarker": "d87a59b2fccc989f" + }, + "cloudflare": { + "kind": "cloudflare-worker-snapshot", + "workerName": "app-inventory", + "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_INVENTORY", + "ssr": { + "workerEntry": ".output/server/index.mjs", + "workerManifest": ".output/server/modern-worker-manifest.json", + "effectBffBundle": ".output/worker/__modern_bff_effect.js", + "routeManifest": ".output/server/route.json", + "ssrBundle": ".output/worker/index.js", + "assetsBinding": "ASSETS" + }, + "zephyr": { + "runtime": "ssr-worker", + "integration": "managed-cloudflare", + "snapshotIdEnv": "ZEPHYR_INVENTORY_SNAPSHOT_ID", + "versionIdEnv": "ZEPHYR_INVENTORY_VERSION_ID", + "applicationUidEnv": "ZEPHYR_INVENTORY_APPLICATION_UID" + }, + "workerDispatch": { + "preferred": "service-binding", + "serviceBinding": "VERTICAL_INVENTORY_WORKER", + "serviceBindingEnv": "VERTICAL_INVENTORY_WORKER_BINDING", + "dispatchNamespaceEnv": "VERTICAL_INVENTORY_DISPATCH_NAMESPACE", + "dispatchWorkerNameEnv": "VERTICAL_INVENTORY_WORKER_NAME", + "requestInterface": "fetch" + } + }, + "node": { + "kind": "node-mf-runtime", + "adapterVersion": "backend-mf-effect-v1", + "remoteName": "verticalInventoryBackend", + "manifestEnv": "VERTICAL_INVENTORY_BACKEND_MF_MANIFEST", + "manifestUrl": "http://localhost:4110/backend-mf-manifest.json", + "containerEntry": "http://localhost:4110/backendRemoteEntry.cjs", + "remoteType": "commonjs-module", + "expose": "./effect-api", + "runtimePackage": "@modern-js/plugin-bff-extensions/backend-federation-manifest/node", + "expected": { + "unitId": "app/inventory", + "buildMarker": "d87a59b2fccc989f" + } + } + }, "assortment": { "apiBaseUrl": "http://localhost:4104/assortment-api", "versionBoundary": "web-and-api-same-build", @@ -502,6 +556,7 @@ "pricing": "http://localhost:4106/pricing-api", "storefront-registry": "http://localhost:4107/storefront-registry-api", "price-group-catalog": "http://localhost:4108/price-group-catalog-api", - "assortment": "http://localhost:4104/assortment-api" + "assortment": "http://localhost:4104/assortment-api", + "inventory": "http://localhost:4110/inventory-api" } } diff --git a/app/topology/ownership.json b/app/topology/ownership.json index bfbf228b5..35081f6f7 100644 --- a/app/topology/ownership.json +++ b/app/topology/ownership.json @@ -289,6 +289,22 @@ } } }, + { + "id": "inventory", + "package": "@app/inventory", + "path": "verticals/inventory", + "ownership": { + "team": "super-app-platform", + "slack": "#super-app-platform", + "pagerDuty": "pd-super-app-platform", + "runbookRef": "runbooks/verticals/inventory.md", + "adrRef": "docs/super-app-rfc-adr/verticals.md#inventory", + "blastRadius": { + "tier": "tier-2-vertical", + "references": ["docs/super-app-rfc-adr/blast-radius.md#inventory"] + } + } + }, { "id": "commerce-market-catalog", "package": "@app/commerce-market-catalog", diff --git a/app/topology/reference-topology.json b/app/topology/reference-topology.json index ef22a2198..fb4a7adf9 100644 --- a/app/topology/reference-topology.json +++ b/app/topology/reference-topology.json @@ -13,27 +13,18 @@ "party-registry", "commerce-market-catalog", "catalog", - "assortment" + "assortment", + "inventory" ], "authentication": { "kind": "shell-core-capability", - "owners": [ - "shell-super-app", - "core-runtime" - ], + "owners": ["shell-super-app", "core-runtime"], "databaseSchema": "auth", "api": { "runtimeFramework": "effect", "strictEffectApproach": true, "prefix": "/shell-super-app-api", - "operations": [ - "signIn", - "currentSession", - "signOut", - "availableTenants", - "switchTenant", - "issueGatewayContext" - ] + "operations": ["signIn", "currentSession", "signOut", "availableTenants", "switchTenant", "issueGatewayContext"] } }, "moduleFederation": { @@ -59,6 +50,11 @@ "id": "assortment", "name": "verticalAssortment", "manifestUrl": "http://localhost:4104/mf-manifest.json" + }, + { + "id": "inventory", + "name": "verticalInventory", + "manifestUrl": "http://localhost:4110/mf-manifest.json" } ], "ssr": true, @@ -69,10 +65,7 @@ "workerName": "app-shell-super-app", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_SHELL_SUPER_APP", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "distributedSsrProofRoutes": [], "routes": { @@ -90,64 +83,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -228,9 +175,7 @@ "role": "remote", "name": "verticalPartyRegistry", "manifestUrl": "http://localhost:4102/mf-manifest.json", - "exposes": [ - "./PageContacts" - ], + "exposes": ["./PageContacts"], "ssr": true, "sharedContractVersion": "mf-ssr-contract-v1" }, @@ -361,11 +306,7 @@ }, "serverEntry": "verticals/party-registry/api/index.ts", "basePath": "/party-registry-api/party-registry", - "consumedBy": [ - "shell-super-app", - "commerce-customer-context", - "party-registry" - ], + "consumedBy": ["shell-super-app", "commerce-customer-context", "party-registry"], "readiness": { "endpoint": "/party-registry/readiness", "marker": { @@ -373,12 +314,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -398,10 +334,7 @@ "workerName": "app-party-registry", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_PARTY_REGISTRY", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "distributedSsrProofRoutes": [ "/en/contacts" @@ -421,64 +354,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -544,9 +431,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#party-registry", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#party-registry" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#party-registry"] } } }, @@ -684,10 +569,7 @@ }, "serverEntry": "verticals/commerce-customer-context/api/index.ts", "basePath": "/commerce-customer-context-api/commerce-customer-context", - "consumedBy": [ - "shell-super-app", - "commerce-customer-context" - ], + "consumedBy": ["shell-super-app", "commerce-customer-context"], "readiness": { "endpoint": "/commerce-customer-context/readiness", "marker": { @@ -695,12 +577,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -743,10 +620,7 @@ "workerName": "app-commerce-customer-context", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_COMMERCE_CUSTOMER_CONTEXT", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "apiReadiness": "/commerce-customer-context-api/commerce-customer-context/readiness" @@ -761,64 +635,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -884,9 +712,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#commerce-customer-context", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#commerce-customer-context" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#commerce-customer-context"] } } }, @@ -1024,10 +850,7 @@ }, "serverEntry": "verticals/payment-term-catalog/api/index.ts", "basePath": "/payment-term-catalog-api/payment-term-catalog", - "consumedBy": [ - "shell-super-app", - "payment-term-catalog" - ], + "consumedBy": ["shell-super-app", "payment-term-catalog"], "readiness": { "endpoint": "/payment-term-catalog/readiness", "marker": { @@ -1035,12 +858,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -1083,10 +901,7 @@ "workerName": "app-payment-term-catalog", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_PAYMENT_TERM_CATALOG", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "apiReadiness": "/payment-term-catalog-api/payment-term-catalog/readiness" @@ -1101,64 +916,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -1224,9 +993,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#payment-term-catalog", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#payment-term-catalog" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#payment-term-catalog"] } } }, @@ -1373,11 +1140,7 @@ }, "serverEntry": "verticals/commerce-market-catalog/api/index.ts", "basePath": "/commerce-market-catalog-api/commerce-market-catalog", - "consumedBy": [ - "shell-super-app", - "commerce-customer-context", - "commerce-market-catalog" - ], + "consumedBy": ["shell-super-app", "commerce-customer-context", "commerce-market-catalog"], "readiness": { "endpoint": "/commerce-market-catalog/readiness", "marker": { @@ -1385,12 +1148,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -1410,10 +1168,7 @@ "workerName": "app-commerce-market-catalog", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_COMMERCE_MARKET_CATALOG", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "ssr": "/en", @@ -1431,64 +1186,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -1554,9 +1263,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#commerce-market-catalog", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#commerce-market-catalog" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#commerce-market-catalog"] } } }, @@ -1570,10 +1277,7 @@ "role": "remote", "name": "verticalCatalog", "manifestUrl": "http://localhost:4105/mf-manifest.json", - "exposes": [ - "./Route", - "./Widget" - ], + "exposes": ["./Route", "./Widget"], "ssr": true, "sharedContractVersion": "mf-ssr-contract-v1" }, @@ -1704,10 +1408,7 @@ }, "serverEntry": "verticals/catalog/api/index.ts", "basePath": "/catalog-api/catalog", - "consumedBy": [ - "shell-super-app", - "catalog" - ], + "consumedBy": ["shell-super-app", "catalog"], "readiness": { "endpoint": "/catalog/readiness", "marker": { @@ -1715,12 +1416,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -1756,10 +1452,7 @@ "workerName": "app-catalog", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_CATALOG", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "ssr": "/en", @@ -1777,64 +1470,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -1900,9 +1547,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#catalog", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#catalog" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#catalog"] } } }, @@ -2040,10 +1685,7 @@ }, "serverEntry": "verticals/pricing/api/index.ts", "basePath": "/pricing-api/pricing", - "consumedBy": [ - "shell-super-app", - "pricing" - ], + "consumedBy": ["shell-super-app", "pricing"], "readiness": { "endpoint": "/pricing/readiness", "marker": { @@ -2051,12 +1693,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -2099,10 +1736,7 @@ "workerName": "app-pricing", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_PRICING", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "apiReadiness": "/pricing-api/pricing/readiness" @@ -2117,64 +1751,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -2240,9 +1828,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#pricing", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#pricing" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#pricing"] } } }, @@ -2380,10 +1966,7 @@ }, "serverEntry": "verticals/storefront-registry/api/index.ts", "basePath": "/storefront-registry-api/storefront-registry", - "consumedBy": [ - "shell-super-app", - "storefront-registry" - ], + "consumedBy": ["shell-super-app", "storefront-registry"], "readiness": { "endpoint": "/storefront-registry/readiness", "marker": { @@ -2391,12 +1974,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -2439,10 +2017,7 @@ "workerName": "app-storefront-registry", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_STOREFRONT_REGISTRY", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "apiReadiness": "/storefront-registry-api/storefront-registry/readiness" @@ -2457,64 +2032,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -2580,9 +2109,7 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#storefront-registry", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#storefront-registry" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#storefront-registry"] } } }, @@ -2720,10 +2247,7 @@ }, "serverEntry": "verticals/price-group-catalog/api/index.ts", "basePath": "/price-group-catalog-api/price-group-catalog", - "consumedBy": [ - "shell-super-app", - "price-group-catalog" - ], + "consumedBy": ["shell-super-app", "price-group-catalog"], "readiness": { "endpoint": "/price-group-catalog/readiness", "marker": { @@ -2731,12 +2255,7 @@ "api": "ultramodernApiMarker", "skew": "none" }, - "checks": [ - "moduleFederation", - "ssr", - "translations", - "api" - ] + "checks": ["moduleFederation", "ssr", "translations", "api"] }, "requestContext": { "propagatedHeaders": [ @@ -2779,10 +2298,7 @@ "workerName": "app-price-group-catalog", "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_PRICE_GROUP_CATALOG", "compatibilityDate": "2026-06-02", - "compatibilityFlags": [ - "nodejs_compat", - "global_fetch_strictly_public" - ], + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], "assetsBinding": "ASSETS", "routes": { "apiReadiness": "/price-group-catalog-api/price-group-catalog/readiness" @@ -2797,64 +2313,18 @@ "contentSecurityPolicy": { "mode": "report-only", "directives": { - "base-uri": [ - "'self'" - ], - "connect-src": [ - "'self'", - "https:", - "http:", - "wss:", - "ws:" - ], - "default-src": [ - "'self'" - ], - "font-src": [ - "'self'", - "data:", - "https:", - "http:" - ], - "form-action": [ - "'self'" - ], - "frame-ancestors": [ - "'self'" - ], - "img-src": [ - "'self'", - "data:", - "blob:", - "https:", - "http:" - ], - "manifest-src": [ - "'self'", - "https:", - "http:" - ], - "object-src": [ - "'none'" - ], - "script-src": [ - "'self'", - "'unsafe-inline'", - "'unsafe-eval'", - "https:", - "http:", - "blob:" - ], - "style-src": [ - "'self'", - "'unsafe-inline'", - "https:", - "http:" - ], - "worker-src": [ - "'self'", - "blob:" - ] + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] }, "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." }, @@ -2920,9 +2390,298 @@ "adrRef": "docs/super-app-rfc-adr/verticals.md#price-group-catalog", "blastRadius": { "tier": "tier-2-vertical", - "references": [ - "docs/super-app-rfc-adr/blast-radius.md#price-group-catalog" - ] + "references": ["docs/super-app-rfc-adr/blast-radius.md#price-group-catalog"] + } + } + }, + { + "id": "inventory", + "kind": "vertical", + "domain": "inventory", + "package": "@app/inventory", + "path": "verticals/inventory", + "moduleFederation": { + "role": "remote", + "name": "verticalInventory", + "manifestUrl": "http://localhost:4110/mf-manifest.json", + "exposes": ["./Route", "./Widget"], + "ssr": true, + "sharedContractVersion": "mf-ssr-contract-v1" + }, + "backendFederation": { + "role": "microvertical-server", + "name": "verticalInventoryBackend", + "runtimeFramework": "effect", + "strictEffectApproach": true, + "deliveryUnit": { + "schemaVersion": 1, + "kind": "microvertical-delivery-unit", + "unitId": "app/inventory", + "packageName": "@app/inventory", + "version": "0.1.0", + "buildMarker": "d87a59b2fccc989f", + "sourceRevision": "workspace" + }, + "exposes": { + "./effect-api": { + "contract": "verticals/inventory/shared/api.ts", + "runtime": "verticals/inventory/api/index.ts", + "client": "verticals/inventory/src/api/inventory-client.ts", + "openapi": "/inventory-api/openapi.json", + "readiness": "/inventory-api/inventory/readiness" + } + }, + "versionBoundary": { + "invariant": "web-and-api-same-build", + "identityRoot": "deliveryUnit", + "packageName": "@app/inventory", + "ui": { + "manifestEnv": "VERTICAL_INVENTORY_MF_MANIFEST", + "manifestUrl": "http://localhost:4110/mf-manifest.json", + "buildMarker": "verticals/inventory/src/routes/ultramodern-route-metadata.ts" + }, + "api": { + "readiness": "/inventory-api/inventory/readiness", + "buildMarker": "verticals/inventory/shared/ultramodern-build.ts", + "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_INVENTORY" + } + }, + "executionSurfaces": { + "cloudflare": { + "kind": "cloudflare-worker-snapshot", + "workerName": "app-inventory", + "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_INVENTORY", + "ssr": { + "workerEntry": ".output/server/index.mjs", + "workerManifest": ".output/server/modern-worker-manifest.json", + "effectBffBundle": ".output/worker/__modern_bff_effect.js", + "routeManifest": ".output/server/route.json", + "ssrBundle": ".output/worker/index.js", + "assetsBinding": "ASSETS" + }, + "zephyr": { + "runtime": "ssr-worker", + "integration": "managed-cloudflare", + "snapshotIdEnv": "ZEPHYR_INVENTORY_SNAPSHOT_ID", + "versionIdEnv": "ZEPHYR_INVENTORY_VERSION_ID", + "applicationUidEnv": "ZEPHYR_INVENTORY_APPLICATION_UID" + }, + "workerDispatch": { + "preferred": "service-binding", + "serviceBinding": "VERTICAL_INVENTORY_WORKER", + "serviceBindingEnv": "VERTICAL_INVENTORY_WORKER_BINDING", + "dispatchNamespaceEnv": "VERTICAL_INVENTORY_DISPATCH_NAMESPACE", + "dispatchWorkerNameEnv": "VERTICAL_INVENTORY_WORKER_NAME", + "requestInterface": "fetch" + } + }, + "node": { + "kind": "node-mf-runtime", + "adapterVersion": "backend-mf-effect-v1", + "remoteName": "verticalInventoryBackend", + "manifestEnv": "VERTICAL_INVENTORY_BACKEND_MF_MANIFEST", + "manifestUrl": "http://localhost:4110/backend-mf-manifest.json", + "containerEntry": "http://localhost:4110/backendRemoteEntry.cjs", + "remoteType": "commonjs-module", + "expose": "./effect-api", + "runtimePackage": "@modern-js/plugin-bff-extensions/backend-federation-manifest/node", + "expected": { + "unitId": "app/inventory", + "buildMarker": "d87a59b2fccc989f" + } + } + }, + "compatibility": { + "contractVersion": "microvertical-server-effect-v1", + "packageName": "@app/inventory", + "effectVersion": "4.0.0-rc.117", + "moduleFederationVersion": "2.9.1" + }, + "cache": { + "cloudflareSnapshot": "immutable", + "nodeManifest": "no-store", + "nodeVersionedContainer": "immutable", + "nodeUnpinnedContainer": "revalidate" + }, + "fallback": { + "timeoutMs": 1500, + "failureEvent": "modernjs:microvertical-server-fallback", + "strategy": "typed-effect-error" + } + }, + "deliveryUnit": { + "schemaVersion": 1, + "kind": "microvertical-delivery-unit", + "unitId": "app/inventory", + "packageName": "@app/inventory", + "version": "0.1.0", + "buildMarker": "d87a59b2fccc989f", + "sourceRevision": "workspace" + }, + "api": { + "runtime": "effect", + "bff": { + "prefix": "/inventory-api", + "openapi": "/openapi.json", + "strictEffectApproach": true + }, + "contract": { + "export": "./api", + "path": "verticals/inventory/shared/api.ts" + }, + "client": { + "export": "./api/client", + "path": "verticals/inventory/src/api/inventory-client.ts" + }, + "serverEntry": "verticals/inventory/api/index.ts", + "basePath": "/inventory-api/inventory", + "consumedBy": ["shell-super-app", "inventory"], + "readiness": { + "endpoint": "/inventory/readiness", + "marker": { + "ui": "ultramodernUiMarker", + "api": "ultramodernApiMarker", + "skew": "none" + }, + "checks": ["moduleFederation", "ssr", "translations", "api"] + }, + "requestContext": { + "propagatedHeaders": [ + "accept-language", + "authorization", + "traceparent", + "x-correlation-id", + "x-tenant-id", + "x-ultramodern-env", + "x-vertical-version-id" + ], + "source": "shell-to-vertical-api-client" + }, + "domainOperations": { + "workspaceFeed": { + "client": "listInventory", + "method": "GET", + "path": "/inventory", + "resource": "workspace-items", + "owner": "inventory" + }, + "workspaceDetail": { + "client": "getInventory", + "method": "GET", + "path": "/inventory/:id", + "resource": "workspace-item", + "owner": "inventory" + }, + "workspaceCreate": { + "client": "createInventory", + "method": "POST", + "path": "/inventory", + "resource": "inventory", + "owner": "inventory" + } + } + }, + "cloudflare": { + "target": "cloudflare", + "workerName": "app-inventory", + "publicUrlEnv": "ULTRAMODERN_PUBLIC_URL_INVENTORY", + "compatibilityDate": "2026-06-02", + "compatibilityFlags": ["nodejs_compat", "global_fetch_strictly_public"], + "assetsBinding": "ASSETS", + "routes": { + "ssr": "/en", + "mfManifest": "/mf-manifest.json", + "locale": "/locales/en/inventory.json", + "apiReadiness": "/inventory-api/inventory/readiness" + }, + "security": { + "enabled": true, + "headers": { + "referrerPolicy": "strict-origin-when-cross-origin", + "contentTypeOptions": "nosniff", + "permissionsPolicy": "camera=(), geolocation=(), microphone=(), payment=(), usb=()" + }, + "contentSecurityPolicy": { + "mode": "report-only", + "directives": { + "base-uri": ["'self'"], + "connect-src": ["'self'", "https:", "http:", "wss:", "ws:"], + "default-src": ["'self'"], + "font-src": ["'self'", "data:", "https:", "http:"], + "form-action": ["'self'"], + "frame-ancestors": ["'self'"], + "img-src": ["'self'", "data:", "blob:", "https:", "http:"], + "manifest-src": ["'self'", "https:", "http:"], + "object-src": ["'none'"], + "script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'", "https:", "http:", "blob:"], + "style-src": ["'self'", "'unsafe-inline'", "https:", "http:"], + "worker-src": ["'self'", "blob:"] + }, + "reason": "Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement." + }, + "noindex": { + "workersDev": true, + "localhost": true, + "previewHostnames": [] + } + }, + "qualityGates": { + "publicRoutes": { + "requireSitemapWhenPresent": true, + "requireRobotsSitemapConsistency": true, + "requireWebManifestWhenPresent": true + }, + "statusCodes": { + "notFoundRoute": "/__ultramodern-smoke-missing/nope", + "unknownRouteStatus": 404 + }, + "indexing": { + "previewNoindex": true, + "productionPublicRoutesIndexable": true + }, + "assets": { + "cssPreloadRequired": true, + "cssResponseRequired": true, + "cacheControlRequiredForCss": true, + "sourcemapsPubliclyReferenced": false + }, + "budgets": { + "ssrHtmlMaxBytes": 250000, + "mfManifestMaxBytes": 500000, + "localeJsonMaxBytes": 100000, + "sitemapXmlMaxBytes": 500000, + "cssAssetMaxBytes": 750000 + }, + "csp": { + "finalMode": "report-only-dogfood", + "decision": "Report-only remains the generated final mode until public smoke proof records MF SSR script/style/connect compatibility for the deployed surface." + } + }, + "evidence": { + "reportDefault": ".codex/reports/cloudflare-version-proof/public-url-proof.json" + }, + "jsonSmokeChecks": [ + { + "id": "inventory-readiness-smoke", + "route": "/inventory-api/inventory/readiness", + "expect": { + "status": "ready", + "checks.api": "ready", + "checks.moduleFederation": "ready", + "checks.ssr": "ready" + } + } + ] + }, + "ownership": { + "team": "super-app-platform", + "slack": "#super-app-platform", + "pagerDuty": "pd-super-app-platform", + "runbookRef": "runbooks/verticals/inventory.md", + "adrRef": "docs/super-app-rfc-adr/verticals.md#inventory", + "blastRadius": { + "tier": "tier-2-vertical", + "references": ["docs/super-app-rfc-adr/blast-radius.md#inventory"] } } }, diff --git a/app/tsconfig.json b/app/tsconfig.json index 733e3b4f7..5c6b4f04a 100644 --- a/app/tsconfig.json +++ b/app/tsconfig.json @@ -57,6 +57,9 @@ }, { "path": "verticals/assortment" + }, + { + "path": "verticals/inventory" } ] } diff --git a/app/verticals/inventory/api/action-http-runner.ts b/app/verticals/inventory/api/action-http-runner.ts new file mode 100644 index 000000000..6d984fc80 --- /dev/null +++ b/app/verticals/inventory/api/action-http-runner.ts @@ -0,0 +1,16 @@ +// @generated by OntOS Codesmith MicroVertical Action Boundary v1 +// @ontos-action-boundary-owner inventory +import { bindGovernedActionHttp } from '@app/core-runtime/http/action-runner'; +import type { PrincipalAuthenticationProblems } from '@app/core-runtime/http/principal-authentication'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +/** + * Owner-bound governed Action transport. Endpoint contracts, registrations, and exhaustive + * public Problem Details mappings remain explicit at each local HttpApi handler. + */ +export const bindActionHttpRunner = ( + problems: PrincipalAuthenticationProblems, +) => + bindGovernedActionHttp({ + authenticate: (authorization) => authenticateOperationPrincipal(authorization, problems), + }); diff --git a/app/verticals/inventory/api/auth/action-principal.ts b/app/verticals/inventory/api/auth/action-principal.ts new file mode 100644 index 000000000..c10f8eea0 --- /dev/null +++ b/app/verticals/inventory/api/auth/action-principal.ts @@ -0,0 +1,21 @@ +// @generated by OntOS Codesmith MicroVertical Action Boundary v1 +// @ontos-action-boundary-owner inventory +// @ontos-action-boundary-audience inventory +import { GatewayAssertionRedemptionService } from '@app/core-runtime/auth/gateway-assertion-redemption'; +import { makeMicroverticalHttpPrincipalAuthentication } from '@app/core-runtime/http/principal-authentication'; +import { bindGatewayPrincipalVerifier } from '@app/gateway-principal-verifier/server'; +import { Effect } from 'effect'; +import type { Redacted } from 'effect'; + +const ACTION_GATEWAY_AUDIENCE = 'inventory' as const; +export { GatewayPrincipalVerifierLive as ActionPrincipalVerifierLive } from '@app/gateway-principal-verifier/server'; + +const principalVerifier = bindGatewayPrincipalVerifier(ACTION_GATEWAY_AUDIENCE); + +const verifyOperationPrincipal = (authorization: Redacted.Redacted) => + GatewayAssertionRedemptionService.pipe( + Effect.flatMap((redemption) => principalVerifier.verifyAndRedeem(authorization, { redemption })), + ); + +/** Shared HTTP acquisition bound to this deployment's audience-specific verifier. */ +export const authenticateOperationPrincipal = makeMicroverticalHttpPrincipalAuthentication(verifyOperationPrincipal); diff --git a/app/verticals/inventory/api/auth/gateway-assertion-redemption.ts b/app/verticals/inventory/api/auth/gateway-assertion-redemption.ts new file mode 100644 index 000000000..60358f5dd --- /dev/null +++ b/app/verticals/inventory/api/auth/gateway-assertion-redemption.ts @@ -0,0 +1,26 @@ +// @generated by OntOS Codesmith MicroVertical Action Boundary v1 +// @ontos-action-boundary-owner inventory +import { + GatewayAssertionRedemptionService, + GatewayAssertionRedemptionUnavailableError, +} from '@app/core-runtime/auth/gateway-assertion-redemption'; +import type { GatewayAssertionRedemption } from '@app/core-runtime/auth/gateway-assertion-redemption'; +import { Effect, Layer } from 'effect'; + +/** + * Fail-closed generated seam. The owner must replace this implementation with an atomic, + * durable insert keyed by (issuer, audience, jti) before wiring the boundary in production. + */ +const gatewayAssertionRedemption: GatewayAssertionRedemption = { + consume: () => + Effect.fail( + new GatewayAssertionRedemptionUnavailableError({ + reason: 'Bearer assertion redemption storage is not configured', + }), + ), +}; + +export const GatewayAssertionRedemptionLive = Layer.succeed( + GatewayAssertionRedemptionService, + gatewayAssertionRedemption, +); diff --git a/app/verticals/inventory/api/backend-federation.ts b/app/verticals/inventory/api/backend-federation.ts new file mode 100644 index 000000000..4beb1a3a2 --- /dev/null +++ b/app/verticals/inventory/api/backend-federation.ts @@ -0,0 +1,29 @@ +import { ultramodernApiMarker } from '../shared/ultramodern-build.ts'; + +export const backendFederationContract = { + compatibility: { + build: ultramodernApiMarker.build, + contractVersion: 'microvertical-server-effect-v1', + nodeAdapterVersion: 'backend-mf-effect-v1', + packageName: ultramodernApiMarker.packageName, + sourceRevision: ultramodernApiMarker.sourceRevision, + unitId: ultramodernApiMarker.unitId, + }, + contractVersion: 'microvertical-server-effect-v1', + executionSurfaces: ['node-mf-runtime'], + exposes: ['./effect-api'], + name: 'verticalInventoryBackend', + nodeAdapterVersion: 'backend-mf-effect-v1', + openapiPath: '/inventory-api/openapi.json', + readinessPath: '/inventory-api/inventory/readiness', + role: 'microvertical-server', + runtimeFramework: 'effect', + strictEffectApproach: true, +} as const; + +export { default, default as runtime } from './index.ts'; +export { + inventoryApi as api, + inventoryApiContract as contract, + inventoryOperationContexts as operationContexts, +} from '../shared/api.ts'; diff --git a/app/verticals/inventory/api/catalog-to-stock-binding-resolution-read-server.ts b/app/verticals/inventory/api/catalog-to-stock-binding-resolution-read-server.ts new file mode 100644 index 000000000..024e6db2f --- /dev/null +++ b/app/verticals/inventory/api/catalog-to-stock-binding-resolution-read-server.ts @@ -0,0 +1,91 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + CatalogToStockBindingResolutionAuthenticationProblemSchema, + CatalogToStockBindingResolutionDomainPolicyProblemSchema, + CatalogToStockBindingResolutionDomainUnavailableProblemSchema, + CatalogToStockBindingResolutionForbiddenProblemSchema, + CatalogToStockBindingResolutionInternalProblemSchema, + CatalogToStockBindingResolutionInvalidProblemSchema, + CatalogToStockBindingResolutionNotFoundProblemSchema, + CatalogToStockBindingResolutionPolicyConflictProblemSchema, + CatalogToStockBindingResolutionPolicyProblemSchema, + CatalogToStockBindingResolutionUnavailableProblemSchema, +} from '../shared/apis/catalog-to-stock-binding-resolution.ts'; +import type { + CatalogToStockBindingResolutionDomainPolicyProblem, + CatalogToStockBindingResolutionDomainUnavailableProblem, +} from '../shared/apis/catalog-to-stock-binding-resolution.ts'; +import { CatalogToStockBindingResolutionFailure } from '../shared/domain/catalog-to-stock-binding-resolution.ts'; +import { CatalogToStockBindingUnavailable } from '../shared/domain/catalog-to-stock-binding-unavailable.ts'; +import { InventoryBackendConfigurationPersistenceUnavailable } from '../shared/domain/inventory-backend-configuration-persistence-unavailable.ts'; +import { catalogToStockBindingResolutionRead } from '../src/api/catalog-to-stock-binding-resolution.read.ts'; +import type { CatalogToStockBindingResolutionDomainError } from '../src/api/catalog-to-stock-binding-resolution.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: CatalogToStockBindingResolutionAuthenticationProblemSchema, + forbidden: CatalogToStockBindingResolutionForbiddenProblemSchema, + internal: CatalogToStockBindingResolutionInternalProblemSchema, + invalid: CatalogToStockBindingResolutionInvalidProblemSchema, + notFound: CatalogToStockBindingResolutionNotFoundProblemSchema, + policyConflict: CatalogToStockBindingResolutionPolicyConflictProblemSchema, + policyIneligible: CatalogToStockBindingResolutionPolicyProblemSchema, + unavailable: CatalogToStockBindingResolutionUnavailableProblemSchema, +}); + +export const mapCatalogToStockBindingResolutionDomainError = ( + error: CatalogToStockBindingResolutionDomainError, +): CatalogToStockBindingResolutionDomainPolicyProblem | CatalogToStockBindingResolutionDomainUnavailableProblem => { + if (Schema.is(CatalogToStockBindingResolutionFailure)(error)) { + return CatalogToStockBindingResolutionDomainPolicyProblemSchema.make({ + detail: + error.outcome === 'CONFLICTING' + ? 'The exact Catalog Selection has more than one Current Stock Item binding.' + : 'The Current Catalog-to-Stock Binding cannot satisfy the exact requested meaning and Unit.', + outcome: error.outcome === 'CONFLICTING' ? ('AMBIGUOUS' as const) : ('UNSUPPORTED' as const), + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 422, + title: 'Catalog-to-Stock Binding resolution rejected', + type: 'https://ontos.dev/problems/catalog-to-stock-binding-resolution-rejected', + }); + } + let reasonCode: 'catalog_to_stock_binding_unavailable' | 'inventory_backend_configuration_persistence_unavailable'; + if (Schema.is(CatalogToStockBindingUnavailable)(error)) { + reasonCode = error.code; + } else if (Schema.is(InventoryBackendConfigurationPersistenceUnavailable)(error)) { + reasonCode = error.code; + } else { + reasonCode = 'catalog_to_stock_binding_unavailable'; + } + return CatalogToStockBindingResolutionDomainUnavailableProblemSchema.make({ + detail: 'Catalog-to-Stock Binding resolution is temporarily unavailable.', + outcome: 'UNAVAILABLE', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Catalog-to-Stock Binding resolution unavailable', + type: 'https://ontos.dev/problems/catalog-to-stock-binding-resolution-unavailable', + }); +}; + +export const catalogToStockBindingResolutionReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'catalogToStockBindingResolution', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapCatalogToStockBindingResolutionDomainError, + problems, + registration: catalogToStockBindingResolutionRead, + }), + ), +); diff --git a/app/verticals/inventory/api/change-stock-sharing-eligibility-action-problems.ts b/app/verticals/inventory/api/change-stock-sharing-eligibility-action-problems.ts new file mode 100644 index 000000000..9e46bcfcf --- /dev/null +++ b/app/verticals/inventory/api/change-stock-sharing-eligibility-action-problems.ts @@ -0,0 +1,199 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug change-stock-sharing-eligibility +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + ChangeStockSharingEligibilityActionAlreadyCommittedProblemSchema, + ChangeStockSharingEligibilityActionAuthenticationProblemSchema, + ChangeStockSharingEligibilityActionCommitIndeterminateProblemSchema, + ChangeStockSharingEligibilityActionConflictProblemSchema, + ChangeStockSharingEligibilityActionForbiddenProblemSchema, + ChangeStockSharingEligibilityActionIneligibleProblemSchema, + ChangeStockSharingEligibilityActionInternalProblemSchema, + ChangeStockSharingEligibilityActionInvalidProblemSchema, + ChangeStockSharingEligibilityActionNotFoundProblemSchema, + ChangeStockSharingEligibilityActionPreconditionProblemSchema, + ChangeStockSharingEligibilityActionSchemaErrorMiddleware, + ChangeStockSharingEligibilityActionUnavailableProblemSchema, +} from '../shared/apis/change-stock-sharing-eligibility-action.ts'; +import type { ChangeStockSharingEligibilityActionProblem } from '../shared/apis/change-stock-sharing-eligibility-action.ts'; +import { changeStockSharingEligibilityAction } from '../src/actions/change-stock-sharing-eligibility.action.ts'; + +type DomainError = typeof changeStockSharingEligibilityAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + ChangeStockSharingEligibilityActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const changeStockSharingEligibilityActionProblem = { + authentication: (): ProblemOf<'ChangeStockSharingEligibilityActionAuthenticationProblem'> => + ChangeStockSharingEligibilityActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'ChangeStockSharingEligibilityActionConflictProblem'>['code'], + ): ProblemOf<'ChangeStockSharingEligibilityActionConflictProblem'> => + ChangeStockSharingEligibilityActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'ChangeStockSharingEligibilityActionForbiddenProblem'>['code'], + ): ProblemOf<'ChangeStockSharingEligibilityActionForbiddenProblem'> => + ChangeStockSharingEligibilityActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'ChangeStockSharingEligibilityActionIneligibleProblem'>['code'], + ): ProblemOf<'ChangeStockSharingEligibilityActionIneligibleProblem'> => + ChangeStockSharingEligibilityActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'ChangeStockSharingEligibilityActionInternalProblem'> => + ChangeStockSharingEligibilityActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'ChangeStockSharingEligibilityActionInvalidProblem'> => + ChangeStockSharingEligibilityActionInvalidProblemSchema.make({ + detail: 'The change-stock-sharing-eligibility Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'ChangeStockSharingEligibilityActionNotFoundProblem'>['code'], + ): ProblemOf<'ChangeStockSharingEligibilityActionNotFoundProblem'> => + ChangeStockSharingEligibilityActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'ChangeStockSharingEligibilityActionPreconditionProblem'> => + ChangeStockSharingEligibilityActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'ChangeStockSharingEligibilityActionUnavailableProblem'>['code'], + ): ProblemOf<'ChangeStockSharingEligibilityActionUnavailableProblem'> => + ChangeStockSharingEligibilityActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): ChangeStockSharingEligibilityActionProblem => + Match.value(error).pipe( + Match.tags({ + StockSharingEligibilityLifecycleRejected: () => + changeStockSharingEligibilityActionProblem.conflict('stock_sharing_eligibility_lifecycle_rejected'), + StockSharingEligibilityRejected: () => + changeStockSharingEligibilityActionProblem.ineligible('stock_sharing_eligibility_rejected'), + StockSharingEligibilityUnavailable: () => + changeStockSharingEligibilityActionProblem.unavailable('stock_sharing_eligibility_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): ChangeStockSharingEligibilityActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + ChangeStockSharingEligibilityActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: changeStockSharingEligibilityActionProblem.internal, + ActionCommitIndeterminate: (failure) => + ChangeStockSharingEligibilityActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: changeStockSharingEligibilityActionProblem.internal, + ActionIdempotencyKeyRequired: changeStockSharingEligibilityActionProblem.precondition, + ActionInvocationNotFound: (failure) => changeStockSharingEligibilityActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + changeStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => changeStockSharingEligibilityActionProblem.conflict(failure.code), + ActionPayloadValidationError: changeStockSharingEligibilityActionProblem.invalid, + ActionPermissionCheckError: (failure) => changeStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => changeStockSharingEligibilityActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => changeStockSharingEligibilityActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => changeStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => changeStockSharingEligibilityActionProblem.conflict(failure.code), + ActionResultValidationError: changeStockSharingEligibilityActionProblem.internal, + ActionTransactionError: (failure) => changeStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: changeStockSharingEligibilityActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + changeStockSharingEligibilityActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => changeStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: changeStockSharingEligibilityActionProblem.authentication, + OperationContextDenied: (failure) => changeStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => changeStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => changeStockSharingEligibilityActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(changeStockSharingEligibilityAction.descriptor.domainErrorSchema); +export const mapChangeStockSharingEligibilityActionProblem = ( + error: ActionCoreError | DomainError, +): ChangeStockSharingEligibilityActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const changeStockSharingEligibilityActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + ChangeStockSharingEligibilityActionSchemaErrorMiddleware, + () => Effect.fail(changeStockSharingEligibilityActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/change-stock-sharing-eligibility-action-server.ts b/app/verticals/inventory/api/change-stock-sharing-eligibility-action-server.ts new file mode 100644 index 000000000..c39b0a70c --- /dev/null +++ b/app/verticals/inventory/api/change-stock-sharing-eligibility-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug change-stock-sharing-eligibility +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { changeStockSharingEligibilityAction } from '../src/actions/change-stock-sharing-eligibility.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + changeStockSharingEligibilityActionProblem, + changeStockSharingEligibilityActionSchemaErrorLive, + mapChangeStockSharingEligibilityActionProblem, +} from './change-stock-sharing-eligibility-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: changeStockSharingEligibilityActionProblem.authentication, + unavailable: () => changeStockSharingEligibilityActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('ChangeStockSharingEligibilityActionServer.execute')( + function* executeChangeStockSharingEligibility( + payload: typeof changeStockSharingEligibilityAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(changeStockSharingEligibilityActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(changeStockSharingEligibilityAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(changeStockSharingEligibilityActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: changeStockSharingEligibilityActionProblem.internal, + invalidCorrelationProblem: changeStockSharingEligibilityActionProblem.invalid, + mapError: mapChangeStockSharingEligibilityActionProblem, + payload: decoded, + registration: changeStockSharingEligibilityAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const changeStockSharingEligibilityActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'changeStockSharingEligibilityAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(changeStockSharingEligibilityActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/commitment-protection-verification-read-server.ts b/app/verticals/inventory/api/commitment-protection-verification-read-server.ts new file mode 100644 index 000000000..2937602e0 --- /dev/null +++ b/app/verticals/inventory/api/commitment-protection-verification-read-server.ts @@ -0,0 +1,76 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + CommitmentProtectionVerificationAuthenticationProblemSchema, + CommitmentProtectionVerificationDomainConflictProblemSchema, + CommitmentProtectionVerificationDomainUnavailableProblemSchema, + CommitmentProtectionVerificationForbiddenProblemSchema, + CommitmentProtectionVerificationInternalProblemSchema, + CommitmentProtectionVerificationInvalidProblemSchema, + CommitmentProtectionVerificationNotFoundProblemSchema, + CommitmentProtectionVerificationPolicyConflictProblemSchema, + CommitmentProtectionVerificationPolicyProblemSchema, + CommitmentProtectionVerificationUnavailableProblemSchema, +} from '../shared/apis/commitment-protection-verification.ts'; +import type { + CommitmentProtectionVerificationDomainConflictProblem, + CommitmentProtectionVerificationDomainUnavailableProblem, +} from '../shared/apis/commitment-protection-verification.ts'; +import { CommitmentProtectionUnavailable } from '../shared/domain/commitment-protection.ts'; +import { commitmentProtectionVerificationRead } from '../src/api/commitment-protection-verification.read.ts'; +import type { CommitmentProtectionVerificationDomainError } from '../src/api/commitment-protection-verification.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: CommitmentProtectionVerificationAuthenticationProblemSchema, + forbidden: CommitmentProtectionVerificationForbiddenProblemSchema, + internal: CommitmentProtectionVerificationInternalProblemSchema, + invalid: CommitmentProtectionVerificationInvalidProblemSchema, + notFound: CommitmentProtectionVerificationNotFoundProblemSchema, + policyConflict: CommitmentProtectionVerificationPolicyConflictProblemSchema, + policyIneligible: CommitmentProtectionVerificationPolicyProblemSchema, + unavailable: CommitmentProtectionVerificationUnavailableProblemSchema, +}); + +export const mapCommitmentProtectionVerificationDomainError = ( + error: CommitmentProtectionVerificationDomainError, +): CommitmentProtectionVerificationDomainConflictProblem | CommitmentProtectionVerificationDomainUnavailableProblem => { + const unavailable = Schema.is(CommitmentProtectionUnavailable)(error); + return unavailable + ? CommitmentProtectionVerificationDomainUnavailableProblemSchema.make({ + detail: 'Commitment Protection cannot be verified safely.', + reasonCode: 'commitment_protection_unavailable', + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Commitment Protection unavailable', + type: 'https://ontos.dev/problems/commitment-protection-unavailable', + }) + : CommitmentProtectionVerificationDomainConflictProblemSchema.make({ + detail: 'Commitment Protection does not match the requested Reservation and Attempt.', + reasonCode: 'commitment_protection_scope_conflict', + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 409, + title: 'Commitment Protection scope conflict', + type: 'https://ontos.dev/problems/commitment-protection-scope-conflict', + }); +}; + +export const commitmentProtectionVerificationReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'commitmentProtectionVerification', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapCommitmentProtectionVerificationDomainError, + problems, + registration: commitmentProtectionVerificationRead, + }), + ), +); diff --git a/app/verticals/inventory/api/compensate-inventory-pre-commit-action-problems.ts b/app/verticals/inventory/api/compensate-inventory-pre-commit-action-problems.ts new file mode 100644 index 000000000..5027e3a20 --- /dev/null +++ b/app/verticals/inventory/api/compensate-inventory-pre-commit-action-problems.ts @@ -0,0 +1,197 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug compensate-inventory-pre-commit +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + CompensateInventoryPreCommitActionAlreadyCommittedProblemSchema, + CompensateInventoryPreCommitActionAuthenticationProblemSchema, + CompensateInventoryPreCommitActionCommitIndeterminateProblemSchema, + CompensateInventoryPreCommitActionConflictProblemSchema, + CompensateInventoryPreCommitActionForbiddenProblemSchema, + CompensateInventoryPreCommitActionIneligibleProblemSchema, + CompensateInventoryPreCommitActionInternalProblemSchema, + CompensateInventoryPreCommitActionInvalidProblemSchema, + CompensateInventoryPreCommitActionNotFoundProblemSchema, + CompensateInventoryPreCommitActionPreconditionProblemSchema, + CompensateInventoryPreCommitActionSchemaErrorMiddleware, + CompensateInventoryPreCommitActionUnavailableProblemSchema, +} from '../shared/apis/compensate-inventory-pre-commit-action.ts'; +import type { CompensateInventoryPreCommitActionProblem } from '../shared/apis/compensate-inventory-pre-commit-action.ts'; +import { compensateInventoryPreCommitAction } from '../src/actions/compensate-inventory-pre-commit.action.ts'; + +type DomainError = typeof compensateInventoryPreCommitAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + CompensateInventoryPreCommitActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const compensateInventoryPreCommitActionProblem = { + authentication: (): ProblemOf<'CompensateInventoryPreCommitActionAuthenticationProblem'> => + CompensateInventoryPreCommitActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'CompensateInventoryPreCommitActionConflictProblem'>['code'], + ): ProblemOf<'CompensateInventoryPreCommitActionConflictProblem'> => + CompensateInventoryPreCommitActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'CompensateInventoryPreCommitActionForbiddenProblem'>['code'], + ): ProblemOf<'CompensateInventoryPreCommitActionForbiddenProblem'> => + CompensateInventoryPreCommitActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'CompensateInventoryPreCommitActionIneligibleProblem'>['code'], + ): ProblemOf<'CompensateInventoryPreCommitActionIneligibleProblem'> => + CompensateInventoryPreCommitActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'CompensateInventoryPreCommitActionInternalProblem'> => + CompensateInventoryPreCommitActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'CompensateInventoryPreCommitActionInvalidProblem'> => + CompensateInventoryPreCommitActionInvalidProblemSchema.make({ + detail: 'The compensate-inventory-pre-commit Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'CompensateInventoryPreCommitActionNotFoundProblem'>['code'], + ): ProblemOf<'CompensateInventoryPreCommitActionNotFoundProblem'> => + CompensateInventoryPreCommitActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'CompensateInventoryPreCommitActionPreconditionProblem'> => + CompensateInventoryPreCommitActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'CompensateInventoryPreCommitActionUnavailableProblem'>['code'], + ): ProblemOf<'CompensateInventoryPreCommitActionUnavailableProblem'> => + CompensateInventoryPreCommitActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): CompensateInventoryPreCommitActionProblem => + Match.value(error).pipe( + Match.tags({ + InventoryPreCommitCompensationRejected: () => + compensateInventoryPreCommitActionProblem.ineligible('inventory_pre_commit_compensation_rejected'), + InventoryPreCommitCompensationUnavailable: () => + compensateInventoryPreCommitActionProblem.unavailable('inventory_pre_commit_compensation_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): CompensateInventoryPreCommitActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + CompensateInventoryPreCommitActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: compensateInventoryPreCommitActionProblem.internal, + ActionCommitIndeterminate: (failure) => + CompensateInventoryPreCommitActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: compensateInventoryPreCommitActionProblem.internal, + ActionIdempotencyKeyRequired: compensateInventoryPreCommitActionProblem.precondition, + ActionInvocationNotFound: (failure) => compensateInventoryPreCommitActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + compensateInventoryPreCommitActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => compensateInventoryPreCommitActionProblem.conflict(failure.code), + ActionPayloadValidationError: compensateInventoryPreCommitActionProblem.invalid, + ActionPermissionCheckError: (failure) => compensateInventoryPreCommitActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => compensateInventoryPreCommitActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => compensateInventoryPreCommitActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => compensateInventoryPreCommitActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => compensateInventoryPreCommitActionProblem.conflict(failure.code), + ActionResultValidationError: compensateInventoryPreCommitActionProblem.internal, + ActionTransactionError: (failure) => compensateInventoryPreCommitActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: compensateInventoryPreCommitActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + compensateInventoryPreCommitActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => compensateInventoryPreCommitActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: compensateInventoryPreCommitActionProblem.authentication, + OperationContextDenied: (failure) => compensateInventoryPreCommitActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => compensateInventoryPreCommitActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => compensateInventoryPreCommitActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(compensateInventoryPreCommitAction.descriptor.domainErrorSchema); +export const mapCompensateInventoryPreCommitActionProblem = ( + error: ActionCoreError | DomainError, +): CompensateInventoryPreCommitActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const compensateInventoryPreCommitActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + CompensateInventoryPreCommitActionSchemaErrorMiddleware, + () => Effect.fail(compensateInventoryPreCommitActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/compensate-inventory-pre-commit-action-server.ts b/app/verticals/inventory/api/compensate-inventory-pre-commit-action-server.ts new file mode 100644 index 000000000..42ba07419 --- /dev/null +++ b/app/verticals/inventory/api/compensate-inventory-pre-commit-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug compensate-inventory-pre-commit +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { compensateInventoryPreCommitAction } from '../src/actions/compensate-inventory-pre-commit.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + compensateInventoryPreCommitActionProblem, + compensateInventoryPreCommitActionSchemaErrorLive, + mapCompensateInventoryPreCommitActionProblem, +} from './compensate-inventory-pre-commit-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: compensateInventoryPreCommitActionProblem.authentication, + unavailable: () => compensateInventoryPreCommitActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('CompensateInventoryPreCommitActionServer.execute')( + function* executeCompensateInventoryPreCommit( + payload: typeof compensateInventoryPreCommitAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(compensateInventoryPreCommitActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(compensateInventoryPreCommitAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(compensateInventoryPreCommitActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: compensateInventoryPreCommitActionProblem.internal, + invalidCorrelationProblem: compensateInventoryPreCommitActionProblem.invalid, + mapError: mapCompensateInventoryPreCommitActionProblem, + payload: decoded, + registration: compensateInventoryPreCommitAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const compensateInventoryPreCommitActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'compensateInventoryPreCommitAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(compensateInventoryPreCommitActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/correct-catalog-to-stock-binding-action-problems.ts b/app/verticals/inventory/api/correct-catalog-to-stock-binding-action-problems.ts new file mode 100644 index 000000000..f40c38edf --- /dev/null +++ b/app/verticals/inventory/api/correct-catalog-to-stock-binding-action-problems.ts @@ -0,0 +1,197 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-catalog-to-stock-binding +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + CorrectCatalogToStockBindingActionAlreadyCommittedProblemSchema, + CorrectCatalogToStockBindingActionAuthenticationProblemSchema, + CorrectCatalogToStockBindingActionCommitIndeterminateProblemSchema, + CorrectCatalogToStockBindingActionConflictProblemSchema, + CorrectCatalogToStockBindingActionForbiddenProblemSchema, + CorrectCatalogToStockBindingActionIneligibleProblemSchema, + CorrectCatalogToStockBindingActionInternalProblemSchema, + CorrectCatalogToStockBindingActionInvalidProblemSchema, + CorrectCatalogToStockBindingActionNotFoundProblemSchema, + CorrectCatalogToStockBindingActionPreconditionProblemSchema, + CorrectCatalogToStockBindingActionSchemaErrorMiddleware, + CorrectCatalogToStockBindingActionUnavailableProblemSchema, +} from '../shared/apis/correct-catalog-to-stock-binding-action.ts'; +import type { CorrectCatalogToStockBindingActionProblem } from '../shared/apis/correct-catalog-to-stock-binding-action.ts'; +import { correctCatalogToStockBindingAction } from '../src/actions/correct-catalog-to-stock-binding.action.ts'; + +type DomainError = typeof correctCatalogToStockBindingAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + CorrectCatalogToStockBindingActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const correctCatalogToStockBindingActionProblem = { + authentication: (): ProblemOf<'CorrectCatalogToStockBindingActionAuthenticationProblem'> => + CorrectCatalogToStockBindingActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'CorrectCatalogToStockBindingActionConflictProblem'>['code'], + ): ProblemOf<'CorrectCatalogToStockBindingActionConflictProblem'> => + CorrectCatalogToStockBindingActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'CorrectCatalogToStockBindingActionForbiddenProblem'>['code'], + ): ProblemOf<'CorrectCatalogToStockBindingActionForbiddenProblem'> => + CorrectCatalogToStockBindingActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'CorrectCatalogToStockBindingActionIneligibleProblem'>['code'], + ): ProblemOf<'CorrectCatalogToStockBindingActionIneligibleProblem'> => + CorrectCatalogToStockBindingActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'CorrectCatalogToStockBindingActionInternalProblem'> => + CorrectCatalogToStockBindingActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'CorrectCatalogToStockBindingActionInvalidProblem'> => + CorrectCatalogToStockBindingActionInvalidProblemSchema.make({ + detail: 'The correct-catalog-to-stock-binding Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'CorrectCatalogToStockBindingActionNotFoundProblem'>['code'], + ): ProblemOf<'CorrectCatalogToStockBindingActionNotFoundProblem'> => + CorrectCatalogToStockBindingActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'CorrectCatalogToStockBindingActionPreconditionProblem'> => + CorrectCatalogToStockBindingActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'CorrectCatalogToStockBindingActionUnavailableProblem'>['code'], + ): ProblemOf<'CorrectCatalogToStockBindingActionUnavailableProblem'> => + CorrectCatalogToStockBindingActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): CorrectCatalogToStockBindingActionProblem => + Match.value(error).pipe( + Match.tags({ + CatalogToStockBindingRejected: () => + correctCatalogToStockBindingActionProblem.ineligible('catalog_to_stock_binding_rejected'), + CatalogToStockBindingUnavailable: () => + correctCatalogToStockBindingActionProblem.unavailable('catalog_to_stock_binding_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): CorrectCatalogToStockBindingActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + CorrectCatalogToStockBindingActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: correctCatalogToStockBindingActionProblem.internal, + ActionCommitIndeterminate: (failure) => + CorrectCatalogToStockBindingActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: correctCatalogToStockBindingActionProblem.internal, + ActionIdempotencyKeyRequired: correctCatalogToStockBindingActionProblem.precondition, + ActionInvocationNotFound: (failure) => correctCatalogToStockBindingActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + correctCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => correctCatalogToStockBindingActionProblem.conflict(failure.code), + ActionPayloadValidationError: correctCatalogToStockBindingActionProblem.invalid, + ActionPermissionCheckError: (failure) => correctCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => correctCatalogToStockBindingActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => correctCatalogToStockBindingActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => correctCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => correctCatalogToStockBindingActionProblem.conflict(failure.code), + ActionResultValidationError: correctCatalogToStockBindingActionProblem.internal, + ActionTransactionError: (failure) => correctCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: correctCatalogToStockBindingActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + correctCatalogToStockBindingActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => correctCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: correctCatalogToStockBindingActionProblem.authentication, + OperationContextDenied: (failure) => correctCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => correctCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => correctCatalogToStockBindingActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(correctCatalogToStockBindingAction.descriptor.domainErrorSchema); +export const mapCorrectCatalogToStockBindingActionProblem = ( + error: ActionCoreError | DomainError, +): CorrectCatalogToStockBindingActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const correctCatalogToStockBindingActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + CorrectCatalogToStockBindingActionSchemaErrorMiddleware, + () => Effect.fail(correctCatalogToStockBindingActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/correct-catalog-to-stock-binding-action-server.ts b/app/verticals/inventory/api/correct-catalog-to-stock-binding-action-server.ts new file mode 100644 index 000000000..462760ce9 --- /dev/null +++ b/app/verticals/inventory/api/correct-catalog-to-stock-binding-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-catalog-to-stock-binding +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { correctCatalogToStockBindingAction } from '../src/actions/correct-catalog-to-stock-binding.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + correctCatalogToStockBindingActionProblem, + correctCatalogToStockBindingActionSchemaErrorLive, + mapCorrectCatalogToStockBindingActionProblem, +} from './correct-catalog-to-stock-binding-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: correctCatalogToStockBindingActionProblem.authentication, + unavailable: () => correctCatalogToStockBindingActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('CorrectCatalogToStockBindingActionServer.execute')( + function* executeCorrectCatalogToStockBinding( + payload: typeof correctCatalogToStockBindingAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(correctCatalogToStockBindingActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(correctCatalogToStockBindingAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(correctCatalogToStockBindingActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: correctCatalogToStockBindingActionProblem.internal, + invalidCorrelationProblem: correctCatalogToStockBindingActionProblem.invalid, + mapError: mapCorrectCatalogToStockBindingActionProblem, + payload: decoded, + registration: correctCatalogToStockBindingAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const correctCatalogToStockBindingActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'correctCatalogToStockBindingAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(correctCatalogToStockBindingActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/correct-external-stock-correlation-action-problems.ts b/app/verticals/inventory/api/correct-external-stock-correlation-action-problems.ts new file mode 100644 index 000000000..10c9f2478 --- /dev/null +++ b/app/verticals/inventory/api/correct-external-stock-correlation-action-problems.ts @@ -0,0 +1,197 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-external-stock-correlation +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + CorrectExternalStockCorrelationActionAlreadyCommittedProblemSchema, + CorrectExternalStockCorrelationActionAuthenticationProblemSchema, + CorrectExternalStockCorrelationActionCommitIndeterminateProblemSchema, + CorrectExternalStockCorrelationActionConflictProblemSchema, + CorrectExternalStockCorrelationActionForbiddenProblemSchema, + CorrectExternalStockCorrelationActionIneligibleProblemSchema, + CorrectExternalStockCorrelationActionInternalProblemSchema, + CorrectExternalStockCorrelationActionInvalidProblemSchema, + CorrectExternalStockCorrelationActionNotFoundProblemSchema, + CorrectExternalStockCorrelationActionPreconditionProblemSchema, + CorrectExternalStockCorrelationActionSchemaErrorMiddleware, + CorrectExternalStockCorrelationActionUnavailableProblemSchema, +} from '../shared/apis/correct-external-stock-correlation-action.ts'; +import type { CorrectExternalStockCorrelationActionProblem } from '../shared/apis/correct-external-stock-correlation-action.ts'; +import { correctExternalStockCorrelationAction } from '../src/actions/correct-external-stock-correlation.action.ts'; + +type DomainError = typeof correctExternalStockCorrelationAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + CorrectExternalStockCorrelationActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const correctExternalStockCorrelationActionProblem = { + authentication: (): ProblemOf<'CorrectExternalStockCorrelationActionAuthenticationProblem'> => + CorrectExternalStockCorrelationActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'CorrectExternalStockCorrelationActionConflictProblem'>['code'], + ): ProblemOf<'CorrectExternalStockCorrelationActionConflictProblem'> => + CorrectExternalStockCorrelationActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'CorrectExternalStockCorrelationActionForbiddenProblem'>['code'], + ): ProblemOf<'CorrectExternalStockCorrelationActionForbiddenProblem'> => + CorrectExternalStockCorrelationActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'CorrectExternalStockCorrelationActionIneligibleProblem'>['code'], + ): ProblemOf<'CorrectExternalStockCorrelationActionIneligibleProblem'> => + CorrectExternalStockCorrelationActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'CorrectExternalStockCorrelationActionInternalProblem'> => + CorrectExternalStockCorrelationActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'CorrectExternalStockCorrelationActionInvalidProblem'> => + CorrectExternalStockCorrelationActionInvalidProblemSchema.make({ + detail: 'The correct-external-stock-correlation Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'CorrectExternalStockCorrelationActionNotFoundProblem'>['code'], + ): ProblemOf<'CorrectExternalStockCorrelationActionNotFoundProblem'> => + CorrectExternalStockCorrelationActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'CorrectExternalStockCorrelationActionPreconditionProblem'> => + CorrectExternalStockCorrelationActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'CorrectExternalStockCorrelationActionUnavailableProblem'>['code'], + ): ProblemOf<'CorrectExternalStockCorrelationActionUnavailableProblem'> => + CorrectExternalStockCorrelationActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): CorrectExternalStockCorrelationActionProblem => + Match.value(error).pipe( + Match.tags({ + ExternalStockCorrelationPersistenceUnavailable: () => + correctExternalStockCorrelationActionProblem.unavailable('external_stock_correlation_persistence_unavailable'), + ExternalStockCorrelationRejected: () => + correctExternalStockCorrelationActionProblem.ineligible('external_stock_correlation_rejected'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): CorrectExternalStockCorrelationActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + CorrectExternalStockCorrelationActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: correctExternalStockCorrelationActionProblem.internal, + ActionCommitIndeterminate: (failure) => + CorrectExternalStockCorrelationActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: correctExternalStockCorrelationActionProblem.internal, + ActionIdempotencyKeyRequired: correctExternalStockCorrelationActionProblem.precondition, + ActionInvocationNotFound: (failure) => correctExternalStockCorrelationActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + correctExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => correctExternalStockCorrelationActionProblem.conflict(failure.code), + ActionPayloadValidationError: correctExternalStockCorrelationActionProblem.invalid, + ActionPermissionCheckError: (failure) => correctExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => correctExternalStockCorrelationActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => correctExternalStockCorrelationActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => correctExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => correctExternalStockCorrelationActionProblem.conflict(failure.code), + ActionResultValidationError: correctExternalStockCorrelationActionProblem.internal, + ActionTransactionError: (failure) => correctExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: correctExternalStockCorrelationActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + correctExternalStockCorrelationActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => correctExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: correctExternalStockCorrelationActionProblem.authentication, + OperationContextDenied: (failure) => correctExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => correctExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => correctExternalStockCorrelationActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(correctExternalStockCorrelationAction.descriptor.domainErrorSchema); +export const mapCorrectExternalStockCorrelationActionProblem = ( + error: ActionCoreError | DomainError, +): CorrectExternalStockCorrelationActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const correctExternalStockCorrelationActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + CorrectExternalStockCorrelationActionSchemaErrorMiddleware, + () => Effect.fail(correctExternalStockCorrelationActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/correct-external-stock-correlation-action-server.ts b/app/verticals/inventory/api/correct-external-stock-correlation-action-server.ts new file mode 100644 index 000000000..03fee2e2d --- /dev/null +++ b/app/verticals/inventory/api/correct-external-stock-correlation-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-external-stock-correlation +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { correctExternalStockCorrelationAction } from '../src/actions/correct-external-stock-correlation.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + correctExternalStockCorrelationActionProblem, + correctExternalStockCorrelationActionSchemaErrorLive, + mapCorrectExternalStockCorrelationActionProblem, +} from './correct-external-stock-correlation-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: correctExternalStockCorrelationActionProblem.authentication, + unavailable: () => correctExternalStockCorrelationActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('CorrectExternalStockCorrelationActionServer.execute')( + function* executeCorrectExternalStockCorrelation( + payload: typeof correctExternalStockCorrelationAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(correctExternalStockCorrelationActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(correctExternalStockCorrelationAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(correctExternalStockCorrelationActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: correctExternalStockCorrelationActionProblem.internal, + invalidCorrelationProblem: correctExternalStockCorrelationActionProblem.invalid, + mapError: mapCorrectExternalStockCorrelationActionProblem, + payload: decoded, + registration: correctExternalStockCorrelationAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const correctExternalStockCorrelationActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'correctExternalStockCorrelationAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(correctExternalStockCorrelationActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/correct-stock-position-action-problems.ts b/app/verticals/inventory/api/correct-stock-position-action-problems.ts new file mode 100644 index 000000000..c71d8c8fe --- /dev/null +++ b/app/verticals/inventory/api/correct-stock-position-action-problems.ts @@ -0,0 +1,193 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-stock-position +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + CorrectStockPositionActionAlreadyCommittedProblemSchema, + CorrectStockPositionActionAuthenticationProblemSchema, + CorrectStockPositionActionCommitIndeterminateProblemSchema, + CorrectStockPositionActionConflictProblemSchema, + CorrectStockPositionActionForbiddenProblemSchema, + CorrectStockPositionActionIneligibleProblemSchema, + CorrectStockPositionActionInternalProblemSchema, + CorrectStockPositionActionInvalidProblemSchema, + CorrectStockPositionActionNotFoundProblemSchema, + CorrectStockPositionActionPreconditionProblemSchema, + CorrectStockPositionActionSchemaErrorMiddleware, + CorrectStockPositionActionUnavailableProblemSchema, +} from '../shared/apis/correct-stock-position-action.ts'; +import type { CorrectStockPositionActionProblem } from '../shared/apis/correct-stock-position-action.ts'; +import { correctStockPositionAction } from '../src/actions/correct-stock-position.action.ts'; + +type DomainError = typeof correctStockPositionAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + CorrectStockPositionActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const correctStockPositionActionProblem = { + authentication: (): ProblemOf<'CorrectStockPositionActionAuthenticationProblem'> => + CorrectStockPositionActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'CorrectStockPositionActionConflictProblem'>['code'], + ): ProblemOf<'CorrectStockPositionActionConflictProblem'> => + CorrectStockPositionActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'CorrectStockPositionActionForbiddenProblem'>['code'], + ): ProblemOf<'CorrectStockPositionActionForbiddenProblem'> => + CorrectStockPositionActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'CorrectStockPositionActionIneligibleProblem'>['code'], + ): ProblemOf<'CorrectStockPositionActionIneligibleProblem'> => + CorrectStockPositionActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'CorrectStockPositionActionInternalProblem'> => + CorrectStockPositionActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'CorrectStockPositionActionInvalidProblem'> => + CorrectStockPositionActionInvalidProblemSchema.make({ + detail: 'The correct-stock-position Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'CorrectStockPositionActionNotFoundProblem'>['code'], + ): ProblemOf<'CorrectStockPositionActionNotFoundProblem'> => + CorrectStockPositionActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'CorrectStockPositionActionPreconditionProblem'> => + CorrectStockPositionActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'CorrectStockPositionActionUnavailableProblem'>['code'], + ): ProblemOf<'CorrectStockPositionActionUnavailableProblem'> => + CorrectStockPositionActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): CorrectStockPositionActionProblem => + Match.value(error).pipe( + Match.tags({ + StockCorrectionConflict: () => correctStockPositionActionProblem.conflict('stock_correction_conflict'), + StockCorrectionRejected: () => correctStockPositionActionProblem.ineligible('stock_correction_rejected'), + StockCorrectionUnavailable: () => correctStockPositionActionProblem.unavailable('stock_correction_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): CorrectStockPositionActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + CorrectStockPositionActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: correctStockPositionActionProblem.internal, + ActionCommitIndeterminate: (failure) => + CorrectStockPositionActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: correctStockPositionActionProblem.internal, + ActionIdempotencyKeyRequired: correctStockPositionActionProblem.precondition, + ActionInvocationNotFound: (failure) => correctStockPositionActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => correctStockPositionActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => correctStockPositionActionProblem.conflict(failure.code), + ActionPayloadValidationError: correctStockPositionActionProblem.invalid, + ActionPermissionCheckError: (failure) => correctStockPositionActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => correctStockPositionActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => correctStockPositionActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => correctStockPositionActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => correctStockPositionActionProblem.conflict(failure.code), + ActionResultValidationError: correctStockPositionActionProblem.internal, + ActionTransactionError: (failure) => correctStockPositionActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: correctStockPositionActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => correctStockPositionActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => correctStockPositionActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: correctStockPositionActionProblem.authentication, + OperationContextDenied: (failure) => correctStockPositionActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => correctStockPositionActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => correctStockPositionActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(correctStockPositionAction.descriptor.domainErrorSchema); +export const mapCorrectStockPositionActionProblem = ( + error: ActionCoreError | DomainError, +): CorrectStockPositionActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const correctStockPositionActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + CorrectStockPositionActionSchemaErrorMiddleware, + () => Effect.fail(correctStockPositionActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/correct-stock-position-action-server.ts b/app/verticals/inventory/api/correct-stock-position-action-server.ts new file mode 100644 index 000000000..15363d0d4 --- /dev/null +++ b/app/verticals/inventory/api/correct-stock-position-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-stock-position +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { correctStockPositionAction } from '../src/actions/correct-stock-position.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + correctStockPositionActionProblem, + correctStockPositionActionSchemaErrorLive, + mapCorrectStockPositionActionProblem, +} from './correct-stock-position-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: correctStockPositionActionProblem.authentication, + unavailable: () => correctStockPositionActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('CorrectStockPositionActionServer.execute')(function* executeCorrectStockPosition( + payload: typeof correctStockPositionAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(correctStockPositionActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(correctStockPositionAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(correctStockPositionActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: correctStockPositionActionProblem.internal, + invalidCorrelationProblem: correctStockPositionActionProblem.invalid, + mapError: mapCorrectStockPositionActionProblem, + payload: decoded, + registration: correctStockPositionAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const correctStockPositionActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'correctStockPositionAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(correctStockPositionActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/create-inventory-reservation-action-problems.ts b/app/verticals/inventory/api/create-inventory-reservation-action-problems.ts new file mode 100644 index 000000000..aeeb770ef --- /dev/null +++ b/app/verticals/inventory/api/create-inventory-reservation-action-problems.ts @@ -0,0 +1,200 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug create-inventory-reservation +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + CreateInventoryReservationActionAlreadyCommittedProblemSchema, + CreateInventoryReservationActionAuthenticationProblemSchema, + CreateInventoryReservationActionCommitIndeterminateProblemSchema, + CreateInventoryReservationActionConflictProblemSchema, + CreateInventoryReservationActionForbiddenProblemSchema, + CreateInventoryReservationActionIneligibleProblemSchema, + CreateInventoryReservationActionInternalProblemSchema, + CreateInventoryReservationActionInvalidProblemSchema, + CreateInventoryReservationActionNotFoundProblemSchema, + CreateInventoryReservationActionPreconditionProblemSchema, + CreateInventoryReservationActionSchemaErrorMiddleware, + CreateInventoryReservationActionUnavailableProblemSchema, +} from '../shared/apis/create-inventory-reservation-action.ts'; +import type { CreateInventoryReservationActionProblem } from '../shared/apis/create-inventory-reservation-action.ts'; +import { createInventoryReservationAction } from '../src/actions/create-inventory-reservation.action.ts'; + +type DomainError = typeof createInventoryReservationAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + CreateInventoryReservationActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const createInventoryReservationActionProblem = { + authentication: (): ProblemOf<'CreateInventoryReservationActionAuthenticationProblem'> => + CreateInventoryReservationActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'CreateInventoryReservationActionConflictProblem'>['code'], + ): ProblemOf<'CreateInventoryReservationActionConflictProblem'> => + CreateInventoryReservationActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'CreateInventoryReservationActionForbiddenProblem'>['code'], + ): ProblemOf<'CreateInventoryReservationActionForbiddenProblem'> => + CreateInventoryReservationActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'CreateInventoryReservationActionIneligibleProblem'>['code'], + ): ProblemOf<'CreateInventoryReservationActionIneligibleProblem'> => + CreateInventoryReservationActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'CreateInventoryReservationActionInternalProblem'> => + CreateInventoryReservationActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'CreateInventoryReservationActionInvalidProblem'> => + CreateInventoryReservationActionInvalidProblemSchema.make({ + detail: 'The create-inventory-reservation Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'CreateInventoryReservationActionNotFoundProblem'>['code'], + ): ProblemOf<'CreateInventoryReservationActionNotFoundProblem'> => + CreateInventoryReservationActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'CreateInventoryReservationActionPreconditionProblem'> => + CreateInventoryReservationActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'CreateInventoryReservationActionUnavailableProblem'>['code'], + ): ProblemOf<'CreateInventoryReservationActionUnavailableProblem'> => + CreateInventoryReservationActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): CreateInventoryReservationActionProblem => + Match.value(error).pipe( + Match.tags({ + CatalogToStockBindingResolutionFailure: () => + createInventoryReservationActionProblem.ineligible('catalog_to_stock_binding_resolution_failure'), + InventoryReservationCreateRejected: (failure) => + ['ATTEMPT_ALREADY_BOUND', 'ATTEMPT_HAS_UNRESOLVED_EFFECT', 'EFFECT_ID_CONFLICT'].includes(failure.reason) + ? createInventoryReservationActionProblem.conflict('inventory_reservation_create_rejected') + : createInventoryReservationActionProblem.ineligible('inventory_reservation_create_rejected'), + InventoryReservationCreateUnavailable: () => + createInventoryReservationActionProblem.unavailable('inventory_reservation_create_unavailable'), + InventoryReservationGuaranteeUnsupported: () => + createInventoryReservationActionProblem.ineligible('inventory_reservation_guarantee_unsupported'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): CreateInventoryReservationActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + CreateInventoryReservationActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: createInventoryReservationActionProblem.internal, + ActionCommitIndeterminate: (failure) => + CreateInventoryReservationActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: createInventoryReservationActionProblem.internal, + ActionIdempotencyKeyRequired: createInventoryReservationActionProblem.precondition, + ActionInvocationNotFound: (failure) => createInventoryReservationActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => createInventoryReservationActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => createInventoryReservationActionProblem.conflict(failure.code), + ActionPayloadValidationError: createInventoryReservationActionProblem.invalid, + ActionPermissionCheckError: (failure) => createInventoryReservationActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => createInventoryReservationActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => createInventoryReservationActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => createInventoryReservationActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => createInventoryReservationActionProblem.conflict(failure.code), + ActionResultValidationError: createInventoryReservationActionProblem.internal, + ActionTransactionError: (failure) => createInventoryReservationActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: createInventoryReservationActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => createInventoryReservationActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => createInventoryReservationActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: createInventoryReservationActionProblem.authentication, + OperationContextDenied: (failure) => createInventoryReservationActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => createInventoryReservationActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => createInventoryReservationActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(createInventoryReservationAction.descriptor.domainErrorSchema); +export const mapCreateInventoryReservationActionProblem = ( + error: ActionCoreError | DomainError, +): CreateInventoryReservationActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const createInventoryReservationActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + CreateInventoryReservationActionSchemaErrorMiddleware, + () => Effect.fail(createInventoryReservationActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/create-inventory-reservation-action-server.ts b/app/verticals/inventory/api/create-inventory-reservation-action-server.ts new file mode 100644 index 000000000..ac9c78477 --- /dev/null +++ b/app/verticals/inventory/api/create-inventory-reservation-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug create-inventory-reservation +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { createInventoryReservationAction } from '../src/actions/create-inventory-reservation.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + createInventoryReservationActionProblem, + createInventoryReservationActionSchemaErrorLive, + mapCreateInventoryReservationActionProblem, +} from './create-inventory-reservation-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: createInventoryReservationActionProblem.authentication, + unavailable: () => createInventoryReservationActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('CreateInventoryReservationActionServer.execute')(function* executeCreateInventoryReservation( + payload: typeof createInventoryReservationAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(createInventoryReservationActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(createInventoryReservationAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(createInventoryReservationActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: createInventoryReservationActionProblem.internal, + invalidCorrelationProblem: createInventoryReservationActionProblem.invalid, + mapError: mapCreateInventoryReservationActionProblem, + payload: decoded, + registration: createInventoryReservationAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const createInventoryReservationActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'createInventoryReservationAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(createInventoryReservationActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/current-stock-evidence-for-availability-read-server.ts b/app/verticals/inventory/api/current-stock-evidence-for-availability-read-server.ts new file mode 100644 index 000000000..50925b821 --- /dev/null +++ b/app/verticals/inventory/api/current-stock-evidence-for-availability-read-server.ts @@ -0,0 +1,84 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + CurrentStockEvidenceForAvailabilityAuthenticationProblemSchema, + CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema, + CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema, + CurrentStockEvidenceForAvailabilityForbiddenProblemSchema, + CurrentStockEvidenceForAvailabilityInternalProblemSchema, + CurrentStockEvidenceForAvailabilityInvalidProblemSchema, + CurrentStockEvidenceForAvailabilityNotFoundProblemSchema, + CurrentStockEvidenceForAvailabilityPolicyConflictProblemSchema, + CurrentStockEvidenceForAvailabilityPolicyProblemSchema, + CurrentStockEvidenceForAvailabilityUnavailableProblemSchema, +} from '../shared/apis/current-stock-evidence-for-availability.ts'; +import type { + CurrentStockEvidenceForAvailabilityDomainPolicyProblem, + CurrentStockEvidenceForAvailabilityDomainUnavailableProblem, +} from '../shared/apis/current-stock-evidence-for-availability.ts'; +import { + CurrentStockEvidenceForAvailabilityRejected, + CurrentStockEvidenceForAvailabilityUnavailable, +} from '../shared/domain/current-stock-evidence-for-availability.ts'; +import { currentStockEvidenceForAvailabilityRead } from '../src/api/current-stock-evidence-for-availability.read.ts'; +import type { CurrentStockEvidenceForAvailabilityDomainError } from '../src/api/current-stock-evidence-for-availability.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: CurrentStockEvidenceForAvailabilityAuthenticationProblemSchema, + forbidden: CurrentStockEvidenceForAvailabilityForbiddenProblemSchema, + internal: CurrentStockEvidenceForAvailabilityInternalProblemSchema, + invalid: CurrentStockEvidenceForAvailabilityInvalidProblemSchema, + notFound: CurrentStockEvidenceForAvailabilityNotFoundProblemSchema, + policyConflict: CurrentStockEvidenceForAvailabilityPolicyConflictProblemSchema, + policyIneligible: CurrentStockEvidenceForAvailabilityPolicyProblemSchema, + unavailable: CurrentStockEvidenceForAvailabilityUnavailableProblemSchema, +}); + +export const mapCurrentStockEvidenceForAvailabilityDomainError = ( + error: CurrentStockEvidenceForAvailabilityDomainError, +): + | CurrentStockEvidenceForAvailabilityDomainPolicyProblem + | CurrentStockEvidenceForAvailabilityDomainUnavailableProblem => { + if (Schema.is(CurrentStockEvidenceForAvailabilityRejected)(error)) { + return CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema.make({ + detail: 'Current stock evidence cannot be used for the requested Position.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 422, + title: 'Current stock evidence rejected', + type: 'https://ontos.dev/problems/current-stock-evidence-rejected', + }); + } + const reasonCode = Schema.is(CurrentStockEvidenceForAvailabilityUnavailable)(error) + ? error.code + : 'current_stock_evidence_for_availability_unavailable'; + return CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema.make({ + detail: 'Current stock evidence cannot be read safely.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Current stock evidence unavailable', + type: 'https://ontos.dev/problems/current-stock-evidence-unavailable', + }); +}; + +export const currentStockEvidenceForAvailabilityReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'currentStockEvidenceForAvailability', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapCurrentStockEvidenceForAvailabilityDomainError, + problems, + registration: currentStockEvidenceForAvailabilityRead, + }), + ), +); diff --git a/app/verticals/inventory/api/effect-api.ts b/app/verticals/inventory/api/effect-api.ts new file mode 100644 index 000000000..a750d7ca0 --- /dev/null +++ b/app/verticals/inventory/api/effect-api.ts @@ -0,0 +1,27 @@ +import { ultramodernApiMarker } from '../shared/ultramodern-build.ts'; + +export const backendFederationContract = { + compatibility: { + build: ultramodernApiMarker.build, + contractVersion: 'microvertical-server-effect-v1', + nodeAdapterVersion: 'backend-mf-effect-v1', + packageName: '@app/inventory', + sourceRevision: ultramodernApiMarker.sourceRevision, + unitId: ultramodernApiMarker.unitId, + }, + executionSurfaces: ['node-mf-runtime'], + exposes: ['./effect-api'], + name: 'verticalInventoryBackend', + openapiPath: '/inventory-api/openapi.json', + readinessPath: '/inventory-api/inventory/readiness', + role: 'microvertical-server', + runtimeFramework: 'effect', + strictEffectApproach: true, +} as const; + +export { default, default as runtime } from './index.ts'; +export { + inventoryApi as api, + inventoryApiContract as contract, + inventoryOperationContexts as operationContexts, +} from '../shared/api.ts'; diff --git a/app/verticals/inventory/api/end-catalog-to-stock-binding-action-problems.ts b/app/verticals/inventory/api/end-catalog-to-stock-binding-action-problems.ts new file mode 100644 index 000000000..7c621abaa --- /dev/null +++ b/app/verticals/inventory/api/end-catalog-to-stock-binding-action-problems.ts @@ -0,0 +1,194 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-catalog-to-stock-binding +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EndCatalogToStockBindingActionAlreadyCommittedProblemSchema, + EndCatalogToStockBindingActionAuthenticationProblemSchema, + EndCatalogToStockBindingActionCommitIndeterminateProblemSchema, + EndCatalogToStockBindingActionConflictProblemSchema, + EndCatalogToStockBindingActionForbiddenProblemSchema, + EndCatalogToStockBindingActionIneligibleProblemSchema, + EndCatalogToStockBindingActionInternalProblemSchema, + EndCatalogToStockBindingActionInvalidProblemSchema, + EndCatalogToStockBindingActionNotFoundProblemSchema, + EndCatalogToStockBindingActionPreconditionProblemSchema, + EndCatalogToStockBindingActionSchemaErrorMiddleware, + EndCatalogToStockBindingActionUnavailableProblemSchema, +} from '../shared/apis/end-catalog-to-stock-binding-action.ts'; +import type { EndCatalogToStockBindingActionProblem } from '../shared/apis/end-catalog-to-stock-binding-action.ts'; +import { endCatalogToStockBindingAction } from '../src/actions/end-catalog-to-stock-binding.action.ts'; + +type DomainError = typeof endCatalogToStockBindingAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EndCatalogToStockBindingActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const endCatalogToStockBindingActionProblem = { + authentication: (): ProblemOf<'EndCatalogToStockBindingActionAuthenticationProblem'> => + EndCatalogToStockBindingActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EndCatalogToStockBindingActionConflictProblem'>['code'], + ): ProblemOf<'EndCatalogToStockBindingActionConflictProblem'> => + EndCatalogToStockBindingActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EndCatalogToStockBindingActionForbiddenProblem'>['code'], + ): ProblemOf<'EndCatalogToStockBindingActionForbiddenProblem'> => + EndCatalogToStockBindingActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EndCatalogToStockBindingActionIneligibleProblem'>['code'], + ): ProblemOf<'EndCatalogToStockBindingActionIneligibleProblem'> => + EndCatalogToStockBindingActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EndCatalogToStockBindingActionInternalProblem'> => + EndCatalogToStockBindingActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EndCatalogToStockBindingActionInvalidProblem'> => + EndCatalogToStockBindingActionInvalidProblemSchema.make({ + detail: 'The end-catalog-to-stock-binding Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EndCatalogToStockBindingActionNotFoundProblem'>['code'], + ): ProblemOf<'EndCatalogToStockBindingActionNotFoundProblem'> => + EndCatalogToStockBindingActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EndCatalogToStockBindingActionPreconditionProblem'> => + EndCatalogToStockBindingActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EndCatalogToStockBindingActionUnavailableProblem'>['code'], + ): ProblemOf<'EndCatalogToStockBindingActionUnavailableProblem'> => + EndCatalogToStockBindingActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EndCatalogToStockBindingActionProblem => + Match.value(error).pipe( + Match.tags({ + CatalogToStockBindingRejected: () => + endCatalogToStockBindingActionProblem.ineligible('catalog_to_stock_binding_rejected'), + CatalogToStockBindingUnavailable: () => + endCatalogToStockBindingActionProblem.unavailable('catalog_to_stock_binding_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EndCatalogToStockBindingActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EndCatalogToStockBindingActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: endCatalogToStockBindingActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EndCatalogToStockBindingActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: endCatalogToStockBindingActionProblem.internal, + ActionIdempotencyKeyRequired: endCatalogToStockBindingActionProblem.precondition, + ActionInvocationNotFound: (failure) => endCatalogToStockBindingActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => endCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => endCatalogToStockBindingActionProblem.conflict(failure.code), + ActionPayloadValidationError: endCatalogToStockBindingActionProblem.invalid, + ActionPermissionCheckError: (failure) => endCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => endCatalogToStockBindingActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => endCatalogToStockBindingActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => endCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => endCatalogToStockBindingActionProblem.conflict(failure.code), + ActionResultValidationError: endCatalogToStockBindingActionProblem.internal, + ActionTransactionError: (failure) => endCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: endCatalogToStockBindingActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => endCatalogToStockBindingActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => endCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: endCatalogToStockBindingActionProblem.authentication, + OperationContextDenied: (failure) => endCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => endCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => endCatalogToStockBindingActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(endCatalogToStockBindingAction.descriptor.domainErrorSchema); +export const mapEndCatalogToStockBindingActionProblem = ( + error: ActionCoreError | DomainError, +): EndCatalogToStockBindingActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const endCatalogToStockBindingActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EndCatalogToStockBindingActionSchemaErrorMiddleware, + () => Effect.fail(endCatalogToStockBindingActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/end-catalog-to-stock-binding-action-server.ts b/app/verticals/inventory/api/end-catalog-to-stock-binding-action-server.ts new file mode 100644 index 000000000..10f20a0a6 --- /dev/null +++ b/app/verticals/inventory/api/end-catalog-to-stock-binding-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-catalog-to-stock-binding +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { endCatalogToStockBindingAction } from '../src/actions/end-catalog-to-stock-binding.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + endCatalogToStockBindingActionProblem, + endCatalogToStockBindingActionSchemaErrorLive, + mapEndCatalogToStockBindingActionProblem, +} from './end-catalog-to-stock-binding-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: endCatalogToStockBindingActionProblem.authentication, + unavailable: () => endCatalogToStockBindingActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EndCatalogToStockBindingActionServer.execute')(function* executeEndCatalogToStockBinding( + payload: typeof endCatalogToStockBindingAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(endCatalogToStockBindingActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(endCatalogToStockBindingAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(endCatalogToStockBindingActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: endCatalogToStockBindingActionProblem.internal, + invalidCorrelationProblem: endCatalogToStockBindingActionProblem.invalid, + mapError: mapEndCatalogToStockBindingActionProblem, + payload: decoded, + registration: endCatalogToStockBindingAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const endCatalogToStockBindingActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'endCatalogToStockBindingAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(endCatalogToStockBindingActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/end-external-stock-correlation-action-problems.ts b/app/verticals/inventory/api/end-external-stock-correlation-action-problems.ts new file mode 100644 index 000000000..423866e3e --- /dev/null +++ b/app/verticals/inventory/api/end-external-stock-correlation-action-problems.ts @@ -0,0 +1,194 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-external-stock-correlation +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EndExternalStockCorrelationActionAlreadyCommittedProblemSchema, + EndExternalStockCorrelationActionAuthenticationProblemSchema, + EndExternalStockCorrelationActionCommitIndeterminateProblemSchema, + EndExternalStockCorrelationActionConflictProblemSchema, + EndExternalStockCorrelationActionForbiddenProblemSchema, + EndExternalStockCorrelationActionIneligibleProblemSchema, + EndExternalStockCorrelationActionInternalProblemSchema, + EndExternalStockCorrelationActionInvalidProblemSchema, + EndExternalStockCorrelationActionNotFoundProblemSchema, + EndExternalStockCorrelationActionPreconditionProblemSchema, + EndExternalStockCorrelationActionSchemaErrorMiddleware, + EndExternalStockCorrelationActionUnavailableProblemSchema, +} from '../shared/apis/end-external-stock-correlation-action.ts'; +import type { EndExternalStockCorrelationActionProblem } from '../shared/apis/end-external-stock-correlation-action.ts'; +import { endExternalStockCorrelationAction } from '../src/actions/end-external-stock-correlation.action.ts'; + +type DomainError = typeof endExternalStockCorrelationAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EndExternalStockCorrelationActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const endExternalStockCorrelationActionProblem = { + authentication: (): ProblemOf<'EndExternalStockCorrelationActionAuthenticationProblem'> => + EndExternalStockCorrelationActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EndExternalStockCorrelationActionConflictProblem'>['code'], + ): ProblemOf<'EndExternalStockCorrelationActionConflictProblem'> => + EndExternalStockCorrelationActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EndExternalStockCorrelationActionForbiddenProblem'>['code'], + ): ProblemOf<'EndExternalStockCorrelationActionForbiddenProblem'> => + EndExternalStockCorrelationActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EndExternalStockCorrelationActionIneligibleProblem'>['code'], + ): ProblemOf<'EndExternalStockCorrelationActionIneligibleProblem'> => + EndExternalStockCorrelationActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EndExternalStockCorrelationActionInternalProblem'> => + EndExternalStockCorrelationActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EndExternalStockCorrelationActionInvalidProblem'> => + EndExternalStockCorrelationActionInvalidProblemSchema.make({ + detail: 'The end-external-stock-correlation Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EndExternalStockCorrelationActionNotFoundProblem'>['code'], + ): ProblemOf<'EndExternalStockCorrelationActionNotFoundProblem'> => + EndExternalStockCorrelationActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EndExternalStockCorrelationActionPreconditionProblem'> => + EndExternalStockCorrelationActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EndExternalStockCorrelationActionUnavailableProblem'>['code'], + ): ProblemOf<'EndExternalStockCorrelationActionUnavailableProblem'> => + EndExternalStockCorrelationActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EndExternalStockCorrelationActionProblem => + Match.value(error).pipe( + Match.tags({ + ExternalStockCorrelationPersistenceUnavailable: () => + endExternalStockCorrelationActionProblem.unavailable('external_stock_correlation_persistence_unavailable'), + ExternalStockCorrelationRejected: () => + endExternalStockCorrelationActionProblem.ineligible('external_stock_correlation_rejected'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EndExternalStockCorrelationActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EndExternalStockCorrelationActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: endExternalStockCorrelationActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EndExternalStockCorrelationActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: endExternalStockCorrelationActionProblem.internal, + ActionIdempotencyKeyRequired: endExternalStockCorrelationActionProblem.precondition, + ActionInvocationNotFound: (failure) => endExternalStockCorrelationActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => endExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => endExternalStockCorrelationActionProblem.conflict(failure.code), + ActionPayloadValidationError: endExternalStockCorrelationActionProblem.invalid, + ActionPermissionCheckError: (failure) => endExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => endExternalStockCorrelationActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => endExternalStockCorrelationActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => endExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => endExternalStockCorrelationActionProblem.conflict(failure.code), + ActionResultValidationError: endExternalStockCorrelationActionProblem.internal, + ActionTransactionError: (failure) => endExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: endExternalStockCorrelationActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => endExternalStockCorrelationActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => endExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: endExternalStockCorrelationActionProblem.authentication, + OperationContextDenied: (failure) => endExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => endExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => endExternalStockCorrelationActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(endExternalStockCorrelationAction.descriptor.domainErrorSchema); +export const mapEndExternalStockCorrelationActionProblem = ( + error: ActionCoreError | DomainError, +): EndExternalStockCorrelationActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const endExternalStockCorrelationActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EndExternalStockCorrelationActionSchemaErrorMiddleware, + () => Effect.fail(endExternalStockCorrelationActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/end-external-stock-correlation-action-server.ts b/app/verticals/inventory/api/end-external-stock-correlation-action-server.ts new file mode 100644 index 000000000..446decdf9 --- /dev/null +++ b/app/verticals/inventory/api/end-external-stock-correlation-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-external-stock-correlation +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { endExternalStockCorrelationAction } from '../src/actions/end-external-stock-correlation.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + endExternalStockCorrelationActionProblem, + endExternalStockCorrelationActionSchemaErrorLive, + mapEndExternalStockCorrelationActionProblem, +} from './end-external-stock-correlation-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: endExternalStockCorrelationActionProblem.authentication, + unavailable: () => endExternalStockCorrelationActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EndExternalStockCorrelationActionServer.execute')( + function* executeEndExternalStockCorrelation( + payload: typeof endExternalStockCorrelationAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(endExternalStockCorrelationActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(endExternalStockCorrelationAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(endExternalStockCorrelationActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: endExternalStockCorrelationActionProblem.internal, + invalidCorrelationProblem: endExternalStockCorrelationActionProblem.invalid, + mapError: mapEndExternalStockCorrelationActionProblem, + payload: decoded, + registration: endExternalStockCorrelationAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const endExternalStockCorrelationActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'endExternalStockCorrelationAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(endExternalStockCorrelationActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/end-stock-sharing-eligibility-action-problems.ts b/app/verticals/inventory/api/end-stock-sharing-eligibility-action-problems.ts new file mode 100644 index 000000000..45c544b1a --- /dev/null +++ b/app/verticals/inventory/api/end-stock-sharing-eligibility-action-problems.ts @@ -0,0 +1,196 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-stock-sharing-eligibility +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EndStockSharingEligibilityActionAlreadyCommittedProblemSchema, + EndStockSharingEligibilityActionAuthenticationProblemSchema, + EndStockSharingEligibilityActionCommitIndeterminateProblemSchema, + EndStockSharingEligibilityActionConflictProblemSchema, + EndStockSharingEligibilityActionForbiddenProblemSchema, + EndStockSharingEligibilityActionIneligibleProblemSchema, + EndStockSharingEligibilityActionInternalProblemSchema, + EndStockSharingEligibilityActionInvalidProblemSchema, + EndStockSharingEligibilityActionNotFoundProblemSchema, + EndStockSharingEligibilityActionPreconditionProblemSchema, + EndStockSharingEligibilityActionSchemaErrorMiddleware, + EndStockSharingEligibilityActionUnavailableProblemSchema, +} from '../shared/apis/end-stock-sharing-eligibility-action.ts'; +import type { EndStockSharingEligibilityActionProblem } from '../shared/apis/end-stock-sharing-eligibility-action.ts'; +import { endStockSharingEligibilityAction } from '../src/actions/end-stock-sharing-eligibility.action.ts'; + +type DomainError = typeof endStockSharingEligibilityAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EndStockSharingEligibilityActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const endStockSharingEligibilityActionProblem = { + authentication: (): ProblemOf<'EndStockSharingEligibilityActionAuthenticationProblem'> => + EndStockSharingEligibilityActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EndStockSharingEligibilityActionConflictProblem'>['code'], + ): ProblemOf<'EndStockSharingEligibilityActionConflictProblem'> => + EndStockSharingEligibilityActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EndStockSharingEligibilityActionForbiddenProblem'>['code'], + ): ProblemOf<'EndStockSharingEligibilityActionForbiddenProblem'> => + EndStockSharingEligibilityActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EndStockSharingEligibilityActionIneligibleProblem'>['code'], + ): ProblemOf<'EndStockSharingEligibilityActionIneligibleProblem'> => + EndStockSharingEligibilityActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EndStockSharingEligibilityActionInternalProblem'> => + EndStockSharingEligibilityActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EndStockSharingEligibilityActionInvalidProblem'> => + EndStockSharingEligibilityActionInvalidProblemSchema.make({ + detail: 'The end-stock-sharing-eligibility Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EndStockSharingEligibilityActionNotFoundProblem'>['code'], + ): ProblemOf<'EndStockSharingEligibilityActionNotFoundProblem'> => + EndStockSharingEligibilityActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EndStockSharingEligibilityActionPreconditionProblem'> => + EndStockSharingEligibilityActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EndStockSharingEligibilityActionUnavailableProblem'>['code'], + ): ProblemOf<'EndStockSharingEligibilityActionUnavailableProblem'> => + EndStockSharingEligibilityActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EndStockSharingEligibilityActionProblem => + Match.value(error).pipe( + Match.tags({ + StockSharingEligibilityLifecycleRejected: () => + endStockSharingEligibilityActionProblem.conflict('stock_sharing_eligibility_lifecycle_rejected'), + StockSharingEligibilityRejected: () => + endStockSharingEligibilityActionProblem.ineligible('stock_sharing_eligibility_rejected'), + StockSharingEligibilityUnavailable: () => + endStockSharingEligibilityActionProblem.unavailable('stock_sharing_eligibility_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EndStockSharingEligibilityActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EndStockSharingEligibilityActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: endStockSharingEligibilityActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EndStockSharingEligibilityActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: endStockSharingEligibilityActionProblem.internal, + ActionIdempotencyKeyRequired: endStockSharingEligibilityActionProblem.precondition, + ActionInvocationNotFound: (failure) => endStockSharingEligibilityActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => endStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => endStockSharingEligibilityActionProblem.conflict(failure.code), + ActionPayloadValidationError: endStockSharingEligibilityActionProblem.invalid, + ActionPermissionCheckError: (failure) => endStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => endStockSharingEligibilityActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => endStockSharingEligibilityActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => endStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => endStockSharingEligibilityActionProblem.conflict(failure.code), + ActionResultValidationError: endStockSharingEligibilityActionProblem.internal, + ActionTransactionError: (failure) => endStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: endStockSharingEligibilityActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => endStockSharingEligibilityActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => endStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: endStockSharingEligibilityActionProblem.authentication, + OperationContextDenied: (failure) => endStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => endStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => endStockSharingEligibilityActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(endStockSharingEligibilityAction.descriptor.domainErrorSchema); +export const mapEndStockSharingEligibilityActionProblem = ( + error: ActionCoreError | DomainError, +): EndStockSharingEligibilityActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const endStockSharingEligibilityActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EndStockSharingEligibilityActionSchemaErrorMiddleware, + () => Effect.fail(endStockSharingEligibilityActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/end-stock-sharing-eligibility-action-server.ts b/app/verticals/inventory/api/end-stock-sharing-eligibility-action-server.ts new file mode 100644 index 000000000..235324a37 --- /dev/null +++ b/app/verticals/inventory/api/end-stock-sharing-eligibility-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-stock-sharing-eligibility +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { endStockSharingEligibilityAction } from '../src/actions/end-stock-sharing-eligibility.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + endStockSharingEligibilityActionProblem, + endStockSharingEligibilityActionSchemaErrorLive, + mapEndStockSharingEligibilityActionProblem, +} from './end-stock-sharing-eligibility-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: endStockSharingEligibilityActionProblem.authentication, + unavailable: () => endStockSharingEligibilityActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EndStockSharingEligibilityActionServer.execute')(function* executeEndStockSharingEligibility( + payload: typeof endStockSharingEligibilityAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(endStockSharingEligibilityActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(endStockSharingEligibilityAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(endStockSharingEligibilityActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: endStockSharingEligibilityActionProblem.internal, + invalidCorrelationProblem: endStockSharingEligibilityActionProblem.invalid, + mapError: mapEndStockSharingEligibilityActionProblem, + payload: decoded, + registration: endStockSharingEligibilityAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const endStockSharingEligibilityActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'endStockSharingEligibilityAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(endStockSharingEligibilityActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/establish-catalog-to-stock-binding-action-problems.ts b/app/verticals/inventory/api/establish-catalog-to-stock-binding-action-problems.ts new file mode 100644 index 000000000..b314dc2c7 --- /dev/null +++ b/app/verticals/inventory/api/establish-catalog-to-stock-binding-action-problems.ts @@ -0,0 +1,197 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-catalog-to-stock-binding +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EstablishCatalogToStockBindingActionAlreadyCommittedProblemSchema, + EstablishCatalogToStockBindingActionAuthenticationProblemSchema, + EstablishCatalogToStockBindingActionCommitIndeterminateProblemSchema, + EstablishCatalogToStockBindingActionConflictProblemSchema, + EstablishCatalogToStockBindingActionForbiddenProblemSchema, + EstablishCatalogToStockBindingActionIneligibleProblemSchema, + EstablishCatalogToStockBindingActionInternalProblemSchema, + EstablishCatalogToStockBindingActionInvalidProblemSchema, + EstablishCatalogToStockBindingActionNotFoundProblemSchema, + EstablishCatalogToStockBindingActionPreconditionProblemSchema, + EstablishCatalogToStockBindingActionSchemaErrorMiddleware, + EstablishCatalogToStockBindingActionUnavailableProblemSchema, +} from '../shared/apis/establish-catalog-to-stock-binding-action.ts'; +import type { EstablishCatalogToStockBindingActionProblem } from '../shared/apis/establish-catalog-to-stock-binding-action.ts'; +import { establishCatalogToStockBindingAction } from '../src/actions/establish-catalog-to-stock-binding.action.ts'; + +type DomainError = typeof establishCatalogToStockBindingAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EstablishCatalogToStockBindingActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const establishCatalogToStockBindingActionProblem = { + authentication: (): ProblemOf<'EstablishCatalogToStockBindingActionAuthenticationProblem'> => + EstablishCatalogToStockBindingActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EstablishCatalogToStockBindingActionConflictProblem'>['code'], + ): ProblemOf<'EstablishCatalogToStockBindingActionConflictProblem'> => + EstablishCatalogToStockBindingActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EstablishCatalogToStockBindingActionForbiddenProblem'>['code'], + ): ProblemOf<'EstablishCatalogToStockBindingActionForbiddenProblem'> => + EstablishCatalogToStockBindingActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EstablishCatalogToStockBindingActionIneligibleProblem'>['code'], + ): ProblemOf<'EstablishCatalogToStockBindingActionIneligibleProblem'> => + EstablishCatalogToStockBindingActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EstablishCatalogToStockBindingActionInternalProblem'> => + EstablishCatalogToStockBindingActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EstablishCatalogToStockBindingActionInvalidProblem'> => + EstablishCatalogToStockBindingActionInvalidProblemSchema.make({ + detail: 'The establish-catalog-to-stock-binding Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EstablishCatalogToStockBindingActionNotFoundProblem'>['code'], + ): ProblemOf<'EstablishCatalogToStockBindingActionNotFoundProblem'> => + EstablishCatalogToStockBindingActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EstablishCatalogToStockBindingActionPreconditionProblem'> => + EstablishCatalogToStockBindingActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EstablishCatalogToStockBindingActionUnavailableProblem'>['code'], + ): ProblemOf<'EstablishCatalogToStockBindingActionUnavailableProblem'> => + EstablishCatalogToStockBindingActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EstablishCatalogToStockBindingActionProblem => + Match.value(error).pipe( + Match.tags({ + CatalogToStockBindingRejected: () => + establishCatalogToStockBindingActionProblem.ineligible('catalog_to_stock_binding_rejected'), + CatalogToStockBindingUnavailable: () => + establishCatalogToStockBindingActionProblem.unavailable('catalog_to_stock_binding_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EstablishCatalogToStockBindingActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EstablishCatalogToStockBindingActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: establishCatalogToStockBindingActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EstablishCatalogToStockBindingActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: establishCatalogToStockBindingActionProblem.internal, + ActionIdempotencyKeyRequired: establishCatalogToStockBindingActionProblem.precondition, + ActionInvocationNotFound: (failure) => establishCatalogToStockBindingActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + establishCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => establishCatalogToStockBindingActionProblem.conflict(failure.code), + ActionPayloadValidationError: establishCatalogToStockBindingActionProblem.invalid, + ActionPermissionCheckError: (failure) => establishCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => establishCatalogToStockBindingActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => establishCatalogToStockBindingActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => establishCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => establishCatalogToStockBindingActionProblem.conflict(failure.code), + ActionResultValidationError: establishCatalogToStockBindingActionProblem.internal, + ActionTransactionError: (failure) => establishCatalogToStockBindingActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: establishCatalogToStockBindingActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + establishCatalogToStockBindingActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => establishCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: establishCatalogToStockBindingActionProblem.authentication, + OperationContextDenied: (failure) => establishCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => establishCatalogToStockBindingActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => establishCatalogToStockBindingActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(establishCatalogToStockBindingAction.descriptor.domainErrorSchema); +export const mapEstablishCatalogToStockBindingActionProblem = ( + error: ActionCoreError | DomainError, +): EstablishCatalogToStockBindingActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const establishCatalogToStockBindingActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EstablishCatalogToStockBindingActionSchemaErrorMiddleware, + () => Effect.fail(establishCatalogToStockBindingActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/establish-catalog-to-stock-binding-action-server.ts b/app/verticals/inventory/api/establish-catalog-to-stock-binding-action-server.ts new file mode 100644 index 000000000..e9099ed4c --- /dev/null +++ b/app/verticals/inventory/api/establish-catalog-to-stock-binding-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-catalog-to-stock-binding +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { establishCatalogToStockBindingAction } from '../src/actions/establish-catalog-to-stock-binding.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + establishCatalogToStockBindingActionProblem, + establishCatalogToStockBindingActionSchemaErrorLive, + mapEstablishCatalogToStockBindingActionProblem, +} from './establish-catalog-to-stock-binding-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: establishCatalogToStockBindingActionProblem.authentication, + unavailable: () => establishCatalogToStockBindingActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EstablishCatalogToStockBindingActionServer.execute')( + function* executeEstablishCatalogToStockBinding( + payload: typeof establishCatalogToStockBindingAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(establishCatalogToStockBindingActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(establishCatalogToStockBindingAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(establishCatalogToStockBindingActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: establishCatalogToStockBindingActionProblem.internal, + invalidCorrelationProblem: establishCatalogToStockBindingActionProblem.invalid, + mapError: mapEstablishCatalogToStockBindingActionProblem, + payload: decoded, + registration: establishCatalogToStockBindingAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const establishCatalogToStockBindingActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'establishCatalogToStockBindingAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(establishCatalogToStockBindingActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/establish-commitment-protection-action-problems.ts b/app/verticals/inventory/api/establish-commitment-protection-action-problems.ts new file mode 100644 index 000000000..73e6b6b03 --- /dev/null +++ b/app/verticals/inventory/api/establish-commitment-protection-action-problems.ts @@ -0,0 +1,199 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-commitment-protection +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EstablishCommitmentProtectionActionAlreadyCommittedProblemSchema, + EstablishCommitmentProtectionActionAuthenticationProblemSchema, + EstablishCommitmentProtectionActionCommitIndeterminateProblemSchema, + EstablishCommitmentProtectionActionConflictProblemSchema, + EstablishCommitmentProtectionActionForbiddenProblemSchema, + EstablishCommitmentProtectionActionIneligibleProblemSchema, + EstablishCommitmentProtectionActionInternalProblemSchema, + EstablishCommitmentProtectionActionInvalidProblemSchema, + EstablishCommitmentProtectionActionNotFoundProblemSchema, + EstablishCommitmentProtectionActionPreconditionProblemSchema, + EstablishCommitmentProtectionActionSchemaErrorMiddleware, + EstablishCommitmentProtectionActionUnavailableProblemSchema, +} from '../shared/apis/establish-commitment-protection-action.ts'; +import type { EstablishCommitmentProtectionActionProblem } from '../shared/apis/establish-commitment-protection-action.ts'; +import { establishCommitmentProtectionAction } from '../src/actions/establish-commitment-protection.action.ts'; + +type DomainError = typeof establishCommitmentProtectionAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EstablishCommitmentProtectionActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const establishCommitmentProtectionActionProblem = { + authentication: (): ProblemOf<'EstablishCommitmentProtectionActionAuthenticationProblem'> => + EstablishCommitmentProtectionActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EstablishCommitmentProtectionActionConflictProblem'>['code'], + ): ProblemOf<'EstablishCommitmentProtectionActionConflictProblem'> => + EstablishCommitmentProtectionActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EstablishCommitmentProtectionActionForbiddenProblem'>['code'], + ): ProblemOf<'EstablishCommitmentProtectionActionForbiddenProblem'> => + EstablishCommitmentProtectionActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EstablishCommitmentProtectionActionIneligibleProblem'>['code'], + ): ProblemOf<'EstablishCommitmentProtectionActionIneligibleProblem'> => + EstablishCommitmentProtectionActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EstablishCommitmentProtectionActionInternalProblem'> => + EstablishCommitmentProtectionActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EstablishCommitmentProtectionActionInvalidProblem'> => + EstablishCommitmentProtectionActionInvalidProblemSchema.make({ + detail: 'The establish-commitment-protection Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EstablishCommitmentProtectionActionNotFoundProblem'>['code'], + ): ProblemOf<'EstablishCommitmentProtectionActionNotFoundProblem'> => + EstablishCommitmentProtectionActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EstablishCommitmentProtectionActionPreconditionProblem'> => + EstablishCommitmentProtectionActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EstablishCommitmentProtectionActionUnavailableProblem'>['code'], + ): ProblemOf<'EstablishCommitmentProtectionActionUnavailableProblem'> => + EstablishCommitmentProtectionActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EstablishCommitmentProtectionActionProblem => + Match.value(error).pipe( + Match.tags({ + CommitmentProtectionConflict: () => + establishCommitmentProtectionActionProblem.conflict('commitment_protection_conflict'), + CommitmentProtectionRejected: () => + establishCommitmentProtectionActionProblem.ineligible('commitment_protection_rejected'), + CommitmentProtectionUnavailable: () => + establishCommitmentProtectionActionProblem.unavailable('commitment_protection_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EstablishCommitmentProtectionActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EstablishCommitmentProtectionActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: establishCommitmentProtectionActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EstablishCommitmentProtectionActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: establishCommitmentProtectionActionProblem.internal, + ActionIdempotencyKeyRequired: establishCommitmentProtectionActionProblem.precondition, + ActionInvocationNotFound: (failure) => establishCommitmentProtectionActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + establishCommitmentProtectionActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => establishCommitmentProtectionActionProblem.conflict(failure.code), + ActionPayloadValidationError: establishCommitmentProtectionActionProblem.invalid, + ActionPermissionCheckError: (failure) => establishCommitmentProtectionActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => establishCommitmentProtectionActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => establishCommitmentProtectionActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => establishCommitmentProtectionActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => establishCommitmentProtectionActionProblem.conflict(failure.code), + ActionResultValidationError: establishCommitmentProtectionActionProblem.internal, + ActionTransactionError: (failure) => establishCommitmentProtectionActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: establishCommitmentProtectionActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + establishCommitmentProtectionActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => establishCommitmentProtectionActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: establishCommitmentProtectionActionProblem.authentication, + OperationContextDenied: (failure) => establishCommitmentProtectionActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => establishCommitmentProtectionActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => establishCommitmentProtectionActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(establishCommitmentProtectionAction.descriptor.domainErrorSchema); +export const mapEstablishCommitmentProtectionActionProblem = ( + error: ActionCoreError | DomainError, +): EstablishCommitmentProtectionActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const establishCommitmentProtectionActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EstablishCommitmentProtectionActionSchemaErrorMiddleware, + () => Effect.fail(establishCommitmentProtectionActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/establish-commitment-protection-action-server.ts b/app/verticals/inventory/api/establish-commitment-protection-action-server.ts new file mode 100644 index 000000000..ca02ecd91 --- /dev/null +++ b/app/verticals/inventory/api/establish-commitment-protection-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-commitment-protection +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { establishCommitmentProtectionAction } from '../src/actions/establish-commitment-protection.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + establishCommitmentProtectionActionProblem, + establishCommitmentProtectionActionSchemaErrorLive, + mapEstablishCommitmentProtectionActionProblem, +} from './establish-commitment-protection-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: establishCommitmentProtectionActionProblem.authentication, + unavailable: () => establishCommitmentProtectionActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EstablishCommitmentProtectionActionServer.execute')( + function* executeEstablishCommitmentProtection( + payload: typeof establishCommitmentProtectionAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(establishCommitmentProtectionActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(establishCommitmentProtectionAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(establishCommitmentProtectionActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: establishCommitmentProtectionActionProblem.internal, + invalidCorrelationProblem: establishCommitmentProtectionActionProblem.invalid, + mapError: mapEstablishCommitmentProtectionActionProblem, + payload: decoded, + registration: establishCommitmentProtectionAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const establishCommitmentProtectionActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'establishCommitmentProtectionAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(establishCommitmentProtectionActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/establish-external-stock-correlation-action-problems.ts b/app/verticals/inventory/api/establish-external-stock-correlation-action-problems.ts new file mode 100644 index 000000000..750915eb4 --- /dev/null +++ b/app/verticals/inventory/api/establish-external-stock-correlation-action-problems.ts @@ -0,0 +1,201 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-external-stock-correlation +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EstablishExternalStockCorrelationActionAlreadyCommittedProblemSchema, + EstablishExternalStockCorrelationActionAuthenticationProblemSchema, + EstablishExternalStockCorrelationActionCommitIndeterminateProblemSchema, + EstablishExternalStockCorrelationActionConflictProblemSchema, + EstablishExternalStockCorrelationActionForbiddenProblemSchema, + EstablishExternalStockCorrelationActionIneligibleProblemSchema, + EstablishExternalStockCorrelationActionInternalProblemSchema, + EstablishExternalStockCorrelationActionInvalidProblemSchema, + EstablishExternalStockCorrelationActionNotFoundProblemSchema, + EstablishExternalStockCorrelationActionPreconditionProblemSchema, + EstablishExternalStockCorrelationActionSchemaErrorMiddleware, + EstablishExternalStockCorrelationActionUnavailableProblemSchema, +} from '../shared/apis/establish-external-stock-correlation-action.ts'; +import type { EstablishExternalStockCorrelationActionProblem } from '../shared/apis/establish-external-stock-correlation-action.ts'; +import { establishExternalStockCorrelationAction } from '../src/actions/establish-external-stock-correlation.action.ts'; + +type DomainError = typeof establishExternalStockCorrelationAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EstablishExternalStockCorrelationActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const establishExternalStockCorrelationActionProblem = { + authentication: (): ProblemOf<'EstablishExternalStockCorrelationActionAuthenticationProblem'> => + EstablishExternalStockCorrelationActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EstablishExternalStockCorrelationActionConflictProblem'>['code'], + ): ProblemOf<'EstablishExternalStockCorrelationActionConflictProblem'> => + EstablishExternalStockCorrelationActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EstablishExternalStockCorrelationActionForbiddenProblem'>['code'], + ): ProblemOf<'EstablishExternalStockCorrelationActionForbiddenProblem'> => + EstablishExternalStockCorrelationActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EstablishExternalStockCorrelationActionIneligibleProblem'>['code'], + ): ProblemOf<'EstablishExternalStockCorrelationActionIneligibleProblem'> => + EstablishExternalStockCorrelationActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EstablishExternalStockCorrelationActionInternalProblem'> => + EstablishExternalStockCorrelationActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EstablishExternalStockCorrelationActionInvalidProblem'> => + EstablishExternalStockCorrelationActionInvalidProblemSchema.make({ + detail: 'The establish-external-stock-correlation Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EstablishExternalStockCorrelationActionNotFoundProblem'>['code'], + ): ProblemOf<'EstablishExternalStockCorrelationActionNotFoundProblem'> => + EstablishExternalStockCorrelationActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EstablishExternalStockCorrelationActionPreconditionProblem'> => + EstablishExternalStockCorrelationActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EstablishExternalStockCorrelationActionUnavailableProblem'>['code'], + ): ProblemOf<'EstablishExternalStockCorrelationActionUnavailableProblem'> => + EstablishExternalStockCorrelationActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EstablishExternalStockCorrelationActionProblem => + Match.value(error).pipe( + Match.tags({ + ExternalStockCorrelationPersistenceUnavailable: () => + establishExternalStockCorrelationActionProblem.unavailable( + 'external_stock_correlation_persistence_unavailable', + ), + ExternalStockCorrelationRejected: () => + establishExternalStockCorrelationActionProblem.ineligible('external_stock_correlation_rejected'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EstablishExternalStockCorrelationActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EstablishExternalStockCorrelationActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: establishExternalStockCorrelationActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EstablishExternalStockCorrelationActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: establishExternalStockCorrelationActionProblem.internal, + ActionIdempotencyKeyRequired: establishExternalStockCorrelationActionProblem.precondition, + ActionInvocationNotFound: (failure) => establishExternalStockCorrelationActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + establishExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => establishExternalStockCorrelationActionProblem.conflict(failure.code), + ActionPayloadValidationError: establishExternalStockCorrelationActionProblem.invalid, + ActionPermissionCheckError: (failure) => establishExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => establishExternalStockCorrelationActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => establishExternalStockCorrelationActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => + establishExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => establishExternalStockCorrelationActionProblem.conflict(failure.code), + ActionResultValidationError: establishExternalStockCorrelationActionProblem.internal, + ActionTransactionError: (failure) => establishExternalStockCorrelationActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: establishExternalStockCorrelationActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + establishExternalStockCorrelationActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => establishExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: establishExternalStockCorrelationActionProblem.authentication, + OperationContextDenied: (failure) => establishExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => establishExternalStockCorrelationActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => + establishExternalStockCorrelationActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(establishExternalStockCorrelationAction.descriptor.domainErrorSchema); +export const mapEstablishExternalStockCorrelationActionProblem = ( + error: ActionCoreError | DomainError, +): EstablishExternalStockCorrelationActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const establishExternalStockCorrelationActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EstablishExternalStockCorrelationActionSchemaErrorMiddleware, + () => Effect.fail(establishExternalStockCorrelationActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/establish-external-stock-correlation-action-server.ts b/app/verticals/inventory/api/establish-external-stock-correlation-action-server.ts new file mode 100644 index 000000000..bd21bd6e7 --- /dev/null +++ b/app/verticals/inventory/api/establish-external-stock-correlation-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-external-stock-correlation +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { establishExternalStockCorrelationAction } from '../src/actions/establish-external-stock-correlation.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + establishExternalStockCorrelationActionProblem, + establishExternalStockCorrelationActionSchemaErrorLive, + mapEstablishExternalStockCorrelationActionProblem, +} from './establish-external-stock-correlation-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: establishExternalStockCorrelationActionProblem.authentication, + unavailable: () => establishExternalStockCorrelationActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EstablishExternalStockCorrelationActionServer.execute')( + function* executeEstablishExternalStockCorrelation( + payload: typeof establishExternalStockCorrelationAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(establishExternalStockCorrelationActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(establishExternalStockCorrelationAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(establishExternalStockCorrelationActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: establishExternalStockCorrelationActionProblem.internal, + invalidCorrelationProblem: establishExternalStockCorrelationActionProblem.invalid, + mapError: mapEstablishExternalStockCorrelationActionProblem, + payload: decoded, + registration: establishExternalStockCorrelationAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const establishExternalStockCorrelationActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'establishExternalStockCorrelationAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(establishExternalStockCorrelationActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/establish-stock-sharing-eligibility-action-problems.ts b/app/verticals/inventory/api/establish-stock-sharing-eligibility-action-problems.ts new file mode 100644 index 000000000..7f7f1630c --- /dev/null +++ b/app/verticals/inventory/api/establish-stock-sharing-eligibility-action-problems.ts @@ -0,0 +1,199 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-stock-sharing-eligibility +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + EstablishStockSharingEligibilityActionAlreadyCommittedProblemSchema, + EstablishStockSharingEligibilityActionAuthenticationProblemSchema, + EstablishStockSharingEligibilityActionCommitIndeterminateProblemSchema, + EstablishStockSharingEligibilityActionConflictProblemSchema, + EstablishStockSharingEligibilityActionForbiddenProblemSchema, + EstablishStockSharingEligibilityActionIneligibleProblemSchema, + EstablishStockSharingEligibilityActionInternalProblemSchema, + EstablishStockSharingEligibilityActionInvalidProblemSchema, + EstablishStockSharingEligibilityActionNotFoundProblemSchema, + EstablishStockSharingEligibilityActionPreconditionProblemSchema, + EstablishStockSharingEligibilityActionSchemaErrorMiddleware, + EstablishStockSharingEligibilityActionUnavailableProblemSchema, +} from '../shared/apis/establish-stock-sharing-eligibility-action.ts'; +import type { EstablishStockSharingEligibilityActionProblem } from '../shared/apis/establish-stock-sharing-eligibility-action.ts'; +import { establishStockSharingEligibilityAction } from '../src/actions/establish-stock-sharing-eligibility.action.ts'; + +type DomainError = typeof establishStockSharingEligibilityAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + EstablishStockSharingEligibilityActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const establishStockSharingEligibilityActionProblem = { + authentication: (): ProblemOf<'EstablishStockSharingEligibilityActionAuthenticationProblem'> => + EstablishStockSharingEligibilityActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'EstablishStockSharingEligibilityActionConflictProblem'>['code'], + ): ProblemOf<'EstablishStockSharingEligibilityActionConflictProblem'> => + EstablishStockSharingEligibilityActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'EstablishStockSharingEligibilityActionForbiddenProblem'>['code'], + ): ProblemOf<'EstablishStockSharingEligibilityActionForbiddenProblem'> => + EstablishStockSharingEligibilityActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'EstablishStockSharingEligibilityActionIneligibleProblem'>['code'], + ): ProblemOf<'EstablishStockSharingEligibilityActionIneligibleProblem'> => + EstablishStockSharingEligibilityActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'EstablishStockSharingEligibilityActionInternalProblem'> => + EstablishStockSharingEligibilityActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'EstablishStockSharingEligibilityActionInvalidProblem'> => + EstablishStockSharingEligibilityActionInvalidProblemSchema.make({ + detail: 'The establish-stock-sharing-eligibility Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'EstablishStockSharingEligibilityActionNotFoundProblem'>['code'], + ): ProblemOf<'EstablishStockSharingEligibilityActionNotFoundProblem'> => + EstablishStockSharingEligibilityActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'EstablishStockSharingEligibilityActionPreconditionProblem'> => + EstablishStockSharingEligibilityActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'EstablishStockSharingEligibilityActionUnavailableProblem'>['code'], + ): ProblemOf<'EstablishStockSharingEligibilityActionUnavailableProblem'> => + EstablishStockSharingEligibilityActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): EstablishStockSharingEligibilityActionProblem => + Match.value(error).pipe( + Match.tags({ + StockSharingEligibilityLifecycleRejected: () => + establishStockSharingEligibilityActionProblem.conflict('stock_sharing_eligibility_lifecycle_rejected'), + StockSharingEligibilityRejected: () => + establishStockSharingEligibilityActionProblem.ineligible('stock_sharing_eligibility_rejected'), + StockSharingEligibilityUnavailable: () => + establishStockSharingEligibilityActionProblem.unavailable('stock_sharing_eligibility_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): EstablishStockSharingEligibilityActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + EstablishStockSharingEligibilityActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: establishStockSharingEligibilityActionProblem.internal, + ActionCommitIndeterminate: (failure) => + EstablishStockSharingEligibilityActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: establishStockSharingEligibilityActionProblem.internal, + ActionIdempotencyKeyRequired: establishStockSharingEligibilityActionProblem.precondition, + ActionInvocationNotFound: (failure) => establishStockSharingEligibilityActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + establishStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => establishStockSharingEligibilityActionProblem.conflict(failure.code), + ActionPayloadValidationError: establishStockSharingEligibilityActionProblem.invalid, + ActionPermissionCheckError: (failure) => establishStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => establishStockSharingEligibilityActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => establishStockSharingEligibilityActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => establishStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => establishStockSharingEligibilityActionProblem.conflict(failure.code), + ActionResultValidationError: establishStockSharingEligibilityActionProblem.internal, + ActionTransactionError: (failure) => establishStockSharingEligibilityActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: establishStockSharingEligibilityActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + establishStockSharingEligibilityActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => establishStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: establishStockSharingEligibilityActionProblem.authentication, + OperationContextDenied: (failure) => establishStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => establishStockSharingEligibilityActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => establishStockSharingEligibilityActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(establishStockSharingEligibilityAction.descriptor.domainErrorSchema); +export const mapEstablishStockSharingEligibilityActionProblem = ( + error: ActionCoreError | DomainError, +): EstablishStockSharingEligibilityActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const establishStockSharingEligibilityActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + EstablishStockSharingEligibilityActionSchemaErrorMiddleware, + () => Effect.fail(establishStockSharingEligibilityActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/establish-stock-sharing-eligibility-action-server.ts b/app/verticals/inventory/api/establish-stock-sharing-eligibility-action-server.ts new file mode 100644 index 000000000..5881b9f18 --- /dev/null +++ b/app/verticals/inventory/api/establish-stock-sharing-eligibility-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-stock-sharing-eligibility +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { establishStockSharingEligibilityAction } from '../src/actions/establish-stock-sharing-eligibility.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + establishStockSharingEligibilityActionProblem, + establishStockSharingEligibilityActionSchemaErrorLive, + mapEstablishStockSharingEligibilityActionProblem, +} from './establish-stock-sharing-eligibility-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: establishStockSharingEligibilityActionProblem.authentication, + unavailable: () => establishStockSharingEligibilityActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('EstablishStockSharingEligibilityActionServer.execute')( + function* executeEstablishStockSharingEligibility( + payload: typeof establishStockSharingEligibilityAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(establishStockSharingEligibilityActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(establishStockSharingEligibilityAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(establishStockSharingEligibilityActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: establishStockSharingEligibilityActionProblem.internal, + invalidCorrelationProblem: establishStockSharingEligibilityActionProblem.invalid, + mapError: mapEstablishStockSharingEligibilityActionProblem, + payload: decoded, + registration: establishStockSharingEligibilityAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const establishStockSharingEligibilityActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'establishStockSharingEligibilityAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(establishStockSharingEligibilityActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/import-source-assertion-action-problems.ts b/app/verticals/inventory/api/import-source-assertion-action-problems.ts new file mode 100644 index 000000000..126404467 --- /dev/null +++ b/app/verticals/inventory/api/import-source-assertion-action-problems.ts @@ -0,0 +1,194 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug import-source-assertion +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + ImportSourceAssertionActionAlreadyCommittedProblemSchema, + ImportSourceAssertionActionAuthenticationProblemSchema, + ImportSourceAssertionActionCommitIndeterminateProblemSchema, + ImportSourceAssertionActionConflictProblemSchema, + ImportSourceAssertionActionForbiddenProblemSchema, + ImportSourceAssertionActionIneligibleProblemSchema, + ImportSourceAssertionActionInternalProblemSchema, + ImportSourceAssertionActionInvalidProblemSchema, + ImportSourceAssertionActionNotFoundProblemSchema, + ImportSourceAssertionActionPreconditionProblemSchema, + ImportSourceAssertionActionSchemaErrorMiddleware, + ImportSourceAssertionActionUnavailableProblemSchema, +} from '../shared/apis/import-source-assertion-action.ts'; +import type { ImportSourceAssertionActionProblem } from '../shared/apis/import-source-assertion-action.ts'; +import { importSourceAssertionAction } from '../src/actions/import-source-assertion.action.ts'; + +type DomainError = typeof importSourceAssertionAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + ImportSourceAssertionActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const importSourceAssertionActionProblem = { + authentication: (): ProblemOf<'ImportSourceAssertionActionAuthenticationProblem'> => + ImportSourceAssertionActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'ImportSourceAssertionActionConflictProblem'>['code'], + ): ProblemOf<'ImportSourceAssertionActionConflictProblem'> => + ImportSourceAssertionActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'ImportSourceAssertionActionForbiddenProblem'>['code'], + ): ProblemOf<'ImportSourceAssertionActionForbiddenProblem'> => + ImportSourceAssertionActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'ImportSourceAssertionActionIneligibleProblem'>['code'], + ): ProblemOf<'ImportSourceAssertionActionIneligibleProblem'> => + ImportSourceAssertionActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'ImportSourceAssertionActionInternalProblem'> => + ImportSourceAssertionActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'ImportSourceAssertionActionInvalidProblem'> => + ImportSourceAssertionActionInvalidProblemSchema.make({ + detail: 'The import-source-assertion Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'ImportSourceAssertionActionNotFoundProblem'>['code'], + ): ProblemOf<'ImportSourceAssertionActionNotFoundProblem'> => + ImportSourceAssertionActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'ImportSourceAssertionActionPreconditionProblem'> => + ImportSourceAssertionActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'ImportSourceAssertionActionUnavailableProblem'>['code'], + ): ProblemOf<'ImportSourceAssertionActionUnavailableProblem'> => + ImportSourceAssertionActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): ImportSourceAssertionActionProblem => + Match.value(error).pipe( + Match.tags({ + InventorySourceImportRequestRejected: () => + importSourceAssertionActionProblem.ineligible('inventory_source_import_request_rejected'), + InventorySourceImportUnavailable: () => + importSourceAssertionActionProblem.unavailable('inventory_source_import_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): ImportSourceAssertionActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + ImportSourceAssertionActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: importSourceAssertionActionProblem.internal, + ActionCommitIndeterminate: (failure) => + ImportSourceAssertionActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: importSourceAssertionActionProblem.internal, + ActionIdempotencyKeyRequired: importSourceAssertionActionProblem.precondition, + ActionInvocationNotFound: (failure) => importSourceAssertionActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => importSourceAssertionActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => importSourceAssertionActionProblem.conflict(failure.code), + ActionPayloadValidationError: importSourceAssertionActionProblem.invalid, + ActionPermissionCheckError: (failure) => importSourceAssertionActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => importSourceAssertionActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => importSourceAssertionActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => importSourceAssertionActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => importSourceAssertionActionProblem.conflict(failure.code), + ActionResultValidationError: importSourceAssertionActionProblem.internal, + ActionTransactionError: (failure) => importSourceAssertionActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: importSourceAssertionActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => importSourceAssertionActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => importSourceAssertionActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: importSourceAssertionActionProblem.authentication, + OperationContextDenied: (failure) => importSourceAssertionActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => importSourceAssertionActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => importSourceAssertionActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(importSourceAssertionAction.descriptor.domainErrorSchema); +export const mapImportSourceAssertionActionProblem = ( + error: ActionCoreError | DomainError, +): ImportSourceAssertionActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const importSourceAssertionActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + ImportSourceAssertionActionSchemaErrorMiddleware, + () => Effect.fail(importSourceAssertionActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/import-source-assertion-action-server.ts b/app/verticals/inventory/api/import-source-assertion-action-server.ts new file mode 100644 index 000000000..281f3be1d --- /dev/null +++ b/app/verticals/inventory/api/import-source-assertion-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug import-source-assertion +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { importSourceAssertionAction } from '../src/actions/import-source-assertion.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + importSourceAssertionActionProblem, + importSourceAssertionActionSchemaErrorLive, + mapImportSourceAssertionActionProblem, +} from './import-source-assertion-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: importSourceAssertionActionProblem.authentication, + unavailable: () => importSourceAssertionActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('ImportSourceAssertionActionServer.execute')(function* executeImportSourceAssertion( + payload: typeof importSourceAssertionAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(importSourceAssertionActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(importSourceAssertionAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(importSourceAssertionActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: importSourceAssertionActionProblem.internal, + invalidCorrelationProblem: importSourceAssertionActionProblem.invalid, + mapError: mapImportSourceAssertionActionProblem, + payload: decoded, + registration: importSourceAssertionAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const importSourceAssertionActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'importSourceAssertionAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(importSourceAssertionActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/index.ts b/app/verticals/inventory/api/index.ts new file mode 100644 index 000000000..8be7a35e7 --- /dev/null +++ b/app/verticals/inventory/api/index.ts @@ -0,0 +1,197 @@ +import { RequestSchemaProblemLive } from '@app/shared-contracts/server/http-error-seam'; +import { + ActionRuntimeLive, + ContextAccessLive, + CorePersistenceLive, + DatabaseConfigLive, + ReadRuntimeLive, + TenantModuleStateServiceLive, +} from '@app/core-runtime'; +import type { ActionRuntime, GatewayAssertionRedemptionService, ReadRuntime } from '@app/core-runtime'; +import { + ActionPermissionLive, + ActionRepositoryLive, + ModuleEntrypointGatewayLive, + ModuleStateGateLive, + OperationalScopeResolverLive, +} from '@app/core-runtime/actions/runtime-wiring'; +import { assembleEffectBffRuntime } from '@modern-js/bff-effect/assembly'; +import type { EffectBffRuntimeAssembly } from '@modern-js/bff-effect/assembly'; +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { EffectBffDefinition, EffectBffRuntime, HttpRouter } from '@modern-js/bff-effect/effect-edge'; +import { Layer as GovernedReadLayer, Logger, References, Tracer } from 'effect'; + +// +import { ActionPrincipalVerifierLive as GovernedActionPrincipalVerifierLive } from './auth/action-principal.ts'; +import { GatewayAssertionRedemptionLive as GovernedGatewayAssertionRedemptionLive } from './auth/gateway-assertion-redemption.ts'; +// + +// +import { catalogToStockBindingResolutionReadApiLive } from './catalog-to-stock-binding-resolution-read-server.ts'; +import { changeStockSharingEligibilityActionApiLive } from './change-stock-sharing-eligibility-action-server.ts'; +import { commitmentProtectionVerificationReadApiLive } from './commitment-protection-verification-read-server.ts'; +import { compensateInventoryPreCommitActionApiLive } from './compensate-inventory-pre-commit-action-server.ts'; +import { correctCatalogToStockBindingActionApiLive } from './correct-catalog-to-stock-binding-action-server.ts'; +import { correctExternalStockCorrelationActionApiLive } from './correct-external-stock-correlation-action-server.ts'; +import { correctStockPositionActionApiLive } from './correct-stock-position-action-server.ts'; +import { createInventoryReservationActionApiLive } from './create-inventory-reservation-action-server.ts'; +import { currentStockEvidenceForAvailabilityReadApiLive } from './current-stock-evidence-for-availability-read-server.ts'; +import { endCatalogToStockBindingActionApiLive } from './end-catalog-to-stock-binding-action-server.ts'; +import { endExternalStockCorrelationActionApiLive } from './end-external-stock-correlation-action-server.ts'; +import { endStockSharingEligibilityActionApiLive } from './end-stock-sharing-eligibility-action-server.ts'; +import { establishCatalogToStockBindingActionApiLive } from './establish-catalog-to-stock-binding-action-server.ts'; +import { establishCommitmentProtectionActionApiLive } from './establish-commitment-protection-action-server.ts'; +import { establishExternalStockCorrelationActionApiLive } from './establish-external-stock-correlation-action-server.ts'; +import { establishStockSharingEligibilityActionApiLive } from './establish-stock-sharing-eligibility-action-server.ts'; +import { importSourceAssertionActionApiLive } from './import-source-assertion-action-server.ts'; +import { inventoryBackendConfigurationCurrentReadApiLive } from './inventory-backend-configuration-current-read-server.ts'; +import { inventoryEffectOutcomeReadApiLive } from './inventory-effect-outcome-read-server.ts'; +import { inventoryReconciliationEvidenceReadApiLive } from './inventory-reconciliation-evidence-read-server.ts'; +import { inventoryReservationDetailReadApiLive } from './inventory-reservation-detail-read-server.ts'; +import { inventorySourceConflictDetailReadApiLive } from './inventory-source-conflict-detail-read-server.ts'; +import { recoverInventoryEffectActionApiLive } from './recover-inventory-effect-action-server.ts'; +import { releaseInventoryReservationActionApiLive } from './release-inventory-reservation-action-server.ts'; +import { reservationConfirmationVerificationReadApiLive } from './reservation-confirmation-verification-read-server.ts'; +import { resolveInventorySourceConflictActionApiLive } from './resolve-inventory-source-conflict-action-server.ts'; +import { selectInventoryBackendActionApiLive } from './select-inventory-backend-action-server.ts'; +import { stockIssueActionApiLive } from './stock-issue-action-server.ts'; +import { stockReceiptActionApiLive } from './stock-receipt-action-server.ts'; +import { stockSharingEligibilityResolutionReadApiLive } from './stock-sharing-eligibility-resolution-read-server.ts'; +// + +import { microVerticalOperationAttributes } from '@app/shared-contracts'; +import { inventoryApi, inventoryOperationContexts } from '../shared/api.ts'; +import { ultramodernApiMarker } from '../shared/ultramodern-build.ts'; + +const inventoryReadinessLayer = HttpApiBuilder.group(inventoryApi, 'foundation', (handlers) => + handlers.handle('readiness', () => + Effect.succeed({ + checks: { + api: 'ready' as const, + moduleFederation: 'ready' as const, + ssr: 'ready' as const, + translations: 'ready' as const, + }, + marker: { + ...ultramodernApiMarker, + kind: 'microvertical-delivery-unit' as const, + schemaVersion: 1 as const, + }, + status: 'ready' as const, + versionSkew: 'none' as const, + }).pipe( + Effect.withSpan('ultramodern.api.inventory.readiness', { + attributes: microVerticalOperationAttributes(inventoryOperationContexts.readiness), + kind: 'server', + }), + ), + ), +); + +const runtimeObservabilityLive = Layer.mergeAll( + Logger.layer([Logger.defaultLogger, Logger.tracerLogger]), + Layer.succeed(Tracer.Tracer, Tracer.make({ span: (options) => new Tracer.NativeSpan(options) })), + Layer.succeed(References.MinimumLogLevel, 'Info'), +); + +const tenantModuleStateServiceLive = TenantModuleStateServiceLive.pipe(Layer.provide(CorePersistenceLive)); +const moduleStateGateLive = ModuleStateGateLive.pipe(Layer.provide(tenantModuleStateServiceLive)); +const operationalScopeResolverLive = OperationalScopeResolverLive.pipe( + Layer.provide(Layer.mergeAll(CorePersistenceLive, ContextAccessLive)), +); +const moduleEntrypointGatewayLive = ModuleEntrypointGatewayLive.pipe(Layer.provide(moduleStateGateLive)); +const inventoryActionRuntimeLive = ActionRuntimeLive.pipe( + Layer.provide( + Layer.mergeAll( + CorePersistenceLive, + ActionRepositoryLive, + ActionPermissionLive, + ContextAccessLive, + moduleStateGateLive, + moduleEntrypointGatewayLive, + operationalScopeResolverLive, + ), + ), + Layer.provide(DatabaseConfigLive), +); +const inventoryReadRuntimeLive = ReadRuntimeLive.pipe( + Layer.provide( + Layer.mergeAll(CorePersistenceLive, ContextAccessLive, moduleEntrypointGatewayLive, operationalScopeResolverLive), + ), + Layer.provide(DatabaseConfigLive), +); + +type InventoryApiRuntimeArguments = readonly [ + readRuntime: Layer.Layer>, + actionRuntime: Layer.Layer>, + gatewayAssertionRedemption: Layer.Layer, +]; + +type InventoryApiGroups = (typeof inventoryApi.groups)[keyof typeof inventoryApi.groups]; + +export const makeInventoryApiRuntime = ( + ...args: InventoryApiRuntimeArguments +): EffectBffDefinition & EffectBffRuntime => { + const [governedReadRuntimeLive, governedActionRuntimeLive, gatewayAssertionRedemption] = args; + const actionPrincipalVerifierLive = GovernedActionPrincipalVerifierLive.pipe( + Layer.provide(governedActionRuntimeLive), + ); + const apiHandlersLive = Layer.mergeAll( + inventoryReadinessLayer, + // + catalogToStockBindingResolutionReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + changeStockSharingEligibilityActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + commitmentProtectionVerificationReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + compensateInventoryPreCommitActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + correctCatalogToStockBindingActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + correctExternalStockCorrelationActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + correctStockPositionActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + createInventoryReservationActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + currentStockEvidenceForAvailabilityReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + endCatalogToStockBindingActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + endExternalStockCorrelationActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + endStockSharingEligibilityActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + establishCatalogToStockBindingActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + establishCommitmentProtectionActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + establishExternalStockCorrelationActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + establishStockSharingEligibilityActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + importSourceAssertionActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + inventoryBackendConfigurationCurrentReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + inventoryEffectOutcomeReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + inventoryReconciliationEvidenceReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + inventoryReservationDetailReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + inventorySourceConflictDetailReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + recoverInventoryEffectActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + releaseInventoryReservationActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + reservationConfirmationVerificationReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + resolveInventorySourceConflictActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + selectInventoryBackendActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + stockIssueActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + stockReceiptActionApiLive.pipe(GovernedReadLayer.provide(governedActionRuntimeLive)), + stockSharingEligibilityResolutionReadApiLive.pipe(GovernedReadLayer.provide(governedReadRuntimeLive)), + // + ).pipe(Layer.provide(Layer.mergeAll(actionPrincipalVerifierLive, gatewayAssertionRedemption))); + type InventoryHandlerRequirements = + | (typeof apiHandlersLive extends Layer.Layer + ? Requirements + : never) + | HttpRouter.HttpRouter; + const resolvedApiHandlersLive: EffectBffRuntimeAssembly< + 'InventoryApi', + InventoryApiGroups, + InventoryHandlerRequirements + >['handlers'] = apiHandlersLive.pipe( + Layer.provide(Layer.mergeAll(runtimeObservabilityLive, RequestSchemaProblemLive)), + Layer.orDie, + ); + + return assembleEffectBffRuntime({ + api: inventoryApi, + handlers: resolvedApiHandlersLive, + }); +}; + +const apiRuntime: EffectBffDefinition & EffectBffRuntime = + makeInventoryApiRuntime(inventoryReadRuntimeLive, inventoryActionRuntimeLive, GovernedGatewayAssertionRedemptionLive); + +export default apiRuntime; diff --git a/app/verticals/inventory/api/inventory-backend-configuration-current-read-server.ts b/app/verticals/inventory/api/inventory-backend-configuration-current-read-server.ts new file mode 100644 index 000000000..1aa91bfa8 --- /dev/null +++ b/app/verticals/inventory/api/inventory-backend-configuration-current-read-server.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + InventoryBackendConfigurationCurrentAuthenticationProblemSchema, + InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema, + InventoryBackendConfigurationCurrentForbiddenProblemSchema, + InventoryBackendConfigurationCurrentInternalProblemSchema, + InventoryBackendConfigurationCurrentInvalidProblemSchema, + InventoryBackendConfigurationCurrentNotFoundProblemSchema, + InventoryBackendConfigurationCurrentPolicyConflictProblemSchema, + InventoryBackendConfigurationCurrentPolicyProblemSchema, + InventoryBackendConfigurationCurrentUnavailableProblemSchema, +} from '../shared/apis/inventory-backend-configuration-current.ts'; +import type { InventoryBackendConfigurationCurrentDomainUnavailableProblem } from '../shared/apis/inventory-backend-configuration-current.ts'; +import { InventoryBackendConfigurationPersistenceUnavailable } from '../shared/domain/inventory-backend-configuration-persistence-unavailable.ts'; +import { inventoryBackendConfigurationCurrentRead } from '../src/api/inventory-backend-configuration-current.read.ts'; +import type { InventoryBackendConfigurationCurrentDomainError } from '../src/api/inventory-backend-configuration-current.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: InventoryBackendConfigurationCurrentAuthenticationProblemSchema, + forbidden: InventoryBackendConfigurationCurrentForbiddenProblemSchema, + internal: InventoryBackendConfigurationCurrentInternalProblemSchema, + invalid: InventoryBackendConfigurationCurrentInvalidProblemSchema, + notFound: InventoryBackendConfigurationCurrentNotFoundProblemSchema, + policyConflict: InventoryBackendConfigurationCurrentPolicyConflictProblemSchema, + policyIneligible: InventoryBackendConfigurationCurrentPolicyProblemSchema, + unavailable: InventoryBackendConfigurationCurrentUnavailableProblemSchema, +}); + +const mapInventoryBackendConfigurationCurrentDomainError = ( + _error: InventoryBackendConfigurationCurrentDomainError, +): InventoryBackendConfigurationCurrentDomainUnavailableProblem => { + const reasonCode = Schema.is(InventoryBackendConfigurationPersistenceUnavailable)(_error) + ? _error.code + : 'inventory_backend_configuration_persistence_unavailable'; + return InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema.make({ + detail: 'The selected Inventory Backend cannot be read safely.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- This is the checked literal field of the endpoint's declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Inventory Backend configuration unavailable', + type: 'https://ontos.dev/problems/inventory-backend-configuration-unavailable', + }); +}; + +export const inventoryBackendConfigurationCurrentReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'inventoryBackendConfigurationCurrent', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapInventoryBackendConfigurationCurrentDomainError, + problems, + registration: inventoryBackendConfigurationCurrentRead, + }), + ), +); diff --git a/app/verticals/inventory/api/inventory-effect-outcome-read-server.ts b/app/verticals/inventory/api/inventory-effect-outcome-read-server.ts new file mode 100644 index 000000000..a844295d4 --- /dev/null +++ b/app/verticals/inventory/api/inventory-effect-outcome-read-server.ts @@ -0,0 +1,81 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + InventoryEffectOutcomeAuthenticationProblemSchema, + InventoryEffectOutcomeDomainConflictProblemSchema, + InventoryEffectOutcomeDomainUnavailableProblemSchema, + InventoryEffectOutcomeForbiddenProblemSchema, + InventoryEffectOutcomeInternalProblemSchema, + InventoryEffectOutcomeInvalidProblemSchema, + InventoryEffectOutcomeNotFoundProblemSchema, + InventoryEffectOutcomePolicyConflictProblemSchema, + InventoryEffectOutcomePolicyProblemSchema, + InventoryEffectOutcomeUnavailableProblemSchema, +} from '../shared/apis/inventory-effect-outcome.ts'; +import type { + InventoryEffectOutcomeDomainConflictProblem, + InventoryEffectOutcomeDomainUnavailableProblem, +} from '../shared/apis/inventory-effect-outcome.ts'; +import { + InventoryEffectLedgerConflict, + InventoryEffectLedgerUnavailable, +} from '../shared/domain/inventory-effect-ledger.ts'; +import { inventoryEffectOutcomeRead } from '../src/api/inventory-effect-outcome.read.ts'; +import type { InventoryEffectOutcomeDomainError } from '../src/api/inventory-effect-outcome.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: InventoryEffectOutcomeAuthenticationProblemSchema, + forbidden: InventoryEffectOutcomeForbiddenProblemSchema, + internal: InventoryEffectOutcomeInternalProblemSchema, + invalid: InventoryEffectOutcomeInvalidProblemSchema, + notFound: InventoryEffectOutcomeNotFoundProblemSchema, + policyConflict: InventoryEffectOutcomePolicyConflictProblemSchema, + policyIneligible: InventoryEffectOutcomePolicyProblemSchema, + unavailable: InventoryEffectOutcomeUnavailableProblemSchema, +}); + +export const mapInventoryEffectOutcomeDomainError = ( + error: InventoryEffectOutcomeDomainError, +): InventoryEffectOutcomeDomainConflictProblem | InventoryEffectOutcomeDomainUnavailableProblem => { + const unavailable = Schema.is(InventoryEffectLedgerUnavailable)(error); + return unavailable + ? InventoryEffectOutcomeDomainUnavailableProblemSchema.make({ + detail: 'The inventory operation outcome cannot be resolved safely.', + reasonCode: 'inventory_effect_ledger_unavailable', + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Inventory operation outcome unavailable', + type: 'https://ontos.dev/problems/inventory-effect-outcome-unavailable', + }) + : InventoryEffectOutcomeDomainConflictProblemSchema.make({ + detail: 'The inventory operation identity is already bound to different owner intent.', + reasonCode: Schema.is(InventoryEffectLedgerConflict)(error) + ? 'inventory_effect_ledger_conflict' + : 'inventory_effect_ledger_rejected', + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 409, + title: 'Inventory operation identity conflict', + type: 'https://ontos.dev/problems/inventory-effect-outcome-conflict', + }); +}; + +export const inventoryEffectOutcomeReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'inventoryEffectOutcome', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapInventoryEffectOutcomeDomainError, + problems, + registration: inventoryEffectOutcomeRead, + }), + ), +); diff --git a/app/verticals/inventory/api/inventory-reconciliation-evidence-read-server.ts b/app/verticals/inventory/api/inventory-reconciliation-evidence-read-server.ts new file mode 100644 index 000000000..1c27fe497 --- /dev/null +++ b/app/verticals/inventory/api/inventory-reconciliation-evidence-read-server.ts @@ -0,0 +1,80 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + InventoryReconciliationEvidenceAuthenticationProblemSchema, + InventoryReconciliationEvidenceDomainPolicyProblemSchema, + InventoryReconciliationEvidenceDomainUnavailableProblemSchema, + InventoryReconciliationEvidenceForbiddenProblemSchema, + InventoryReconciliationEvidenceInternalProblemSchema, + InventoryReconciliationEvidenceInvalidProblemSchema, + InventoryReconciliationEvidenceNotFoundProblemSchema, + InventoryReconciliationEvidencePolicyConflictProblemSchema, + InventoryReconciliationEvidencePolicyProblemSchema, + InventoryReconciliationEvidenceUnavailableProblemSchema, +} from '../shared/apis/inventory-reconciliation-evidence.ts'; +import type { + InventoryReconciliationEvidenceDomainPolicyProblem, + InventoryReconciliationEvidenceDomainUnavailableProblem, +} from '../shared/apis/inventory-reconciliation-evidence.ts'; +import { InventoryReconciliationEvidenceRejected } from '../shared/domain/inventory-reconciliation-evidence-rejected.ts'; +import { InventoryReconciliationEvidenceUnavailable } from '../shared/domain/inventory-reconciliation-evidence-unavailable.ts'; +import { inventoryReconciliationEvidenceRead } from '../src/api/inventory-reconciliation-evidence.read.ts'; +import type { InventoryReconciliationEvidenceDomainError } from '../src/api/inventory-reconciliation-evidence.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: InventoryReconciliationEvidenceAuthenticationProblemSchema, + forbidden: InventoryReconciliationEvidenceForbiddenProblemSchema, + internal: InventoryReconciliationEvidenceInternalProblemSchema, + invalid: InventoryReconciliationEvidenceInvalidProblemSchema, + notFound: InventoryReconciliationEvidenceNotFoundProblemSchema, + policyConflict: InventoryReconciliationEvidencePolicyConflictProblemSchema, + policyIneligible: InventoryReconciliationEvidencePolicyProblemSchema, + unavailable: InventoryReconciliationEvidenceUnavailableProblemSchema, +}); + +export const mapInventoryReconciliationEvidenceDomainError = ( + error: InventoryReconciliationEvidenceDomainError, +): InventoryReconciliationEvidenceDomainPolicyProblem | InventoryReconciliationEvidenceDomainUnavailableProblem => { + if (Schema.is(InventoryReconciliationEvidenceRejected)(error)) { + return InventoryReconciliationEvidenceDomainPolicyProblemSchema.make({ + detail: 'The requested Inventory evidence is not eligible for this historical lookup.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 422, + title: 'Inventory reconciliation evidence rejected', + type: 'https://ontos.dev/problems/inventory-reconciliation-evidence-rejected', + }); + } + const reasonCode = Schema.is(InventoryReconciliationEvidenceUnavailable)(error) + ? error.code + : 'inventory_reconciliation_evidence_unavailable'; + return InventoryReconciliationEvidenceDomainUnavailableProblemSchema.make({ + detail: 'Inventory reconciliation evidence cannot be read safely.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Inventory reconciliation evidence unavailable', + type: 'https://ontos.dev/problems/inventory-reconciliation-evidence-unavailable', + }); +}; + +export const inventoryReconciliationEvidenceReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'inventoryReconciliationEvidence', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapInventoryReconciliationEvidenceDomainError, + problems, + registration: inventoryReconciliationEvidenceRead, + }), + ), +); diff --git a/app/verticals/inventory/api/inventory-reservation-detail-read-server.ts b/app/verticals/inventory/api/inventory-reservation-detail-read-server.ts new file mode 100644 index 000000000..5aee4c0b1 --- /dev/null +++ b/app/verticals/inventory/api/inventory-reservation-detail-read-server.ts @@ -0,0 +1,102 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + InventoryReservationDetailAuthenticationProblemSchema, + InventoryReservationDetailDomainConflictProblemSchema, + InventoryReservationDetailDomainPolicyProblemSchema, + InventoryReservationDetailDomainUnavailableProblemSchema, + InventoryReservationDetailForbiddenProblemSchema, + InventoryReservationDetailInternalProblemSchema, + InventoryReservationDetailInvalidProblemSchema, + InventoryReservationDetailNotFoundProblemSchema, + InventoryReservationDetailPolicyConflictProblemSchema, + InventoryReservationDetailPolicyProblemSchema, + InventoryReservationDetailUnavailableProblemSchema, +} from '../shared/apis/inventory-reservation-detail.ts'; +import type { + InventoryReservationDetailDomainConflictProblem, + InventoryReservationDetailDomainPolicyProblem, + InventoryReservationDetailDomainUnavailableProblem, +} from '../shared/apis/inventory-reservation-detail.ts'; +import { InventoryObligationRejected } from '../shared/domain/inventory-obligation.ts'; +import { InventoryObligationPersistenceUnavailable } from '../shared/domain/inventory-obligation-persistence-unavailable.ts'; +import { inventoryReservationDetailRead } from '../src/api/inventory-reservation-detail.read.ts'; +import type { InventoryReservationDetailDomainError } from '../src/api/inventory-reservation-detail.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: InventoryReservationDetailAuthenticationProblemSchema, + forbidden: InventoryReservationDetailForbiddenProblemSchema, + internal: InventoryReservationDetailInternalProblemSchema, + invalid: InventoryReservationDetailInvalidProblemSchema, + notFound: InventoryReservationDetailNotFoundProblemSchema, + policyConflict: InventoryReservationDetailPolicyConflictProblemSchema, + policyIneligible: InventoryReservationDetailPolicyProblemSchema, + unavailable: InventoryReservationDetailUnavailableProblemSchema, +}); + +export const mapInventoryReservationDetailDomainError = ( + error: InventoryReservationDetailDomainError, +): + | InventoryReservationDetailDomainConflictProblem + | InventoryReservationDetailDomainPolicyProblem + | InventoryReservationDetailDomainUnavailableProblem => { + if (Schema.is(InventoryObligationRejected)(error)) { + if ( + new Set([ + 'ATTEMPT_ALREADY_BOUND', + 'OBLIGATION_IDENTITY_CONFLICT', + 'ORDER_COMMIT_BINDING_CONFLICT', + 'RESERVATION_NOT_PROVISIONAL', + ]).has(error.reason) + ) { + return InventoryReservationDetailDomainConflictProblemSchema.make({ + detail: 'The requested Reservation conflicts with its durable Inventory state.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal of the declared status-specific problem constructor; expires: 2027-03-31. + status: 409, + title: 'Inventory Reservation conflict', + type: 'https://ontos.dev/problems/inventory-reservation-conflict', + }); + } + return InventoryReservationDetailDomainPolicyProblemSchema.make({ + detail: 'The requested Reservation cannot be represented safely.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal of the declared status-specific problem constructor; expires: 2027-03-31. + status: 422, + title: 'Inventory Reservation rejected', + type: 'https://ontos.dev/problems/inventory-reservation-rejected', + }); + } + const reasonCode = Schema.is(InventoryObligationPersistenceUnavailable)(error) + ? error.code + : 'inventory_obligation_persistence_unavailable'; + return InventoryReservationDetailDomainUnavailableProblemSchema.make({ + detail: 'Inventory Reservation state is temporarily unavailable.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Inventory Reservation unavailable', + type: 'https://ontos.dev/problems/inventory-reservation-unavailable', + }); +}; + +export const inventoryReservationDetailReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'inventoryReservationDetail', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapInventoryReservationDetailDomainError, + problems, + registration: inventoryReservationDetailRead, + }), + ), +); diff --git a/app/verticals/inventory/api/inventory-source-conflict-detail-read-server.ts b/app/verticals/inventory/api/inventory-source-conflict-detail-read-server.ts new file mode 100644 index 000000000..2d6880a23 --- /dev/null +++ b/app/verticals/inventory/api/inventory-source-conflict-detail-read-server.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + InventorySourceConflictDetailAuthenticationProblemSchema, + InventorySourceConflictDetailDomainUnavailableProblemSchema, + InventorySourceConflictDetailForbiddenProblemSchema, + InventorySourceConflictDetailInternalProblemSchema, + InventorySourceConflictDetailInvalidProblemSchema, + InventorySourceConflictDetailNotFoundProblemSchema, + InventorySourceConflictDetailPolicyConflictProblemSchema, + InventorySourceConflictDetailPolicyProblemSchema, + InventorySourceConflictDetailUnavailableProblemSchema, +} from '../shared/apis/inventory-source-conflict-detail.ts'; +import type { InventorySourceConflictDetailDomainUnavailableProblem } from '../shared/apis/inventory-source-conflict-detail.ts'; +import { InventorySourceConflictUnavailable } from '../shared/domain/inventory-source-conflict-unavailable.ts'; +import { inventorySourceConflictDetailRead } from '../src/api/inventory-source-conflict-detail.read.ts'; +import type { InventorySourceConflictDetailDomainError } from '../src/api/inventory-source-conflict-detail.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: InventorySourceConflictDetailAuthenticationProblemSchema, + forbidden: InventorySourceConflictDetailForbiddenProblemSchema, + internal: InventorySourceConflictDetailInternalProblemSchema, + invalid: InventorySourceConflictDetailInvalidProblemSchema, + notFound: InventorySourceConflictDetailNotFoundProblemSchema, + policyConflict: InventorySourceConflictDetailPolicyConflictProblemSchema, + policyIneligible: InventorySourceConflictDetailPolicyProblemSchema, + unavailable: InventorySourceConflictDetailUnavailableProblemSchema, +}); + +const mapInventorySourceConflictDetailDomainError = ( + error: InventorySourceConflictDetailDomainError, +): InventorySourceConflictDetailDomainUnavailableProblem => { + const reasonCode = Schema.is(InventorySourceConflictUnavailable)(error) + ? error.code + : 'inventory_source_conflict_unavailable'; + return InventorySourceConflictDetailDomainUnavailableProblemSchema.make({ + detail: 'Inventory Source Conflict evidence cannot be read safely.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Inventory Source Conflict unavailable', + type: 'https://ontos.dev/problems/inventory-source-conflict-unavailable', + }); +}; + +export const inventorySourceConflictDetailReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'inventorySourceConflictDetail', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapInventorySourceConflictDetailDomainError, + problems, + registration: inventorySourceConflictDetailRead, + }), + ), +); diff --git a/app/verticals/inventory/api/recover-inventory-effect-action-problems.ts b/app/verticals/inventory/api/recover-inventory-effect-action-problems.ts new file mode 100644 index 000000000..0a9ded0d1 --- /dev/null +++ b/app/verticals/inventory/api/recover-inventory-effect-action-problems.ts @@ -0,0 +1,200 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug recover-inventory-effect +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + RecoverInventoryEffectActionAlreadyCommittedProblemSchema, + RecoverInventoryEffectActionAuthenticationProblemSchema, + RecoverInventoryEffectActionCommitIndeterminateProblemSchema, + RecoverInventoryEffectActionConflictProblemSchema, + RecoverInventoryEffectActionForbiddenProblemSchema, + RecoverInventoryEffectActionIneligibleProblemSchema, + RecoverInventoryEffectActionInternalProblemSchema, + RecoverInventoryEffectActionInvalidProblemSchema, + RecoverInventoryEffectActionNotFoundProblemSchema, + RecoverInventoryEffectActionPreconditionProblemSchema, + RecoverInventoryEffectActionSchemaErrorMiddleware, + RecoverInventoryEffectActionUnavailableProblemSchema, +} from '../shared/apis/recover-inventory-effect-action.ts'; +import type { RecoverInventoryEffectActionProblem } from '../shared/apis/recover-inventory-effect-action.ts'; +import { recoverInventoryEffectAction } from '../src/actions/recover-inventory-effect.action.ts'; + +type DomainError = typeof recoverInventoryEffectAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + RecoverInventoryEffectActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const recoverInventoryEffectActionProblem = { + authentication: (): ProblemOf<'RecoverInventoryEffectActionAuthenticationProblem'> => + RecoverInventoryEffectActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'RecoverInventoryEffectActionConflictProblem'>['code'], + ): ProblemOf<'RecoverInventoryEffectActionConflictProblem'> => + RecoverInventoryEffectActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'RecoverInventoryEffectActionForbiddenProblem'>['code'], + ): ProblemOf<'RecoverInventoryEffectActionForbiddenProblem'> => + RecoverInventoryEffectActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'RecoverInventoryEffectActionIneligibleProblem'>['code'], + ): ProblemOf<'RecoverInventoryEffectActionIneligibleProblem'> => + RecoverInventoryEffectActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'RecoverInventoryEffectActionInternalProblem'> => + RecoverInventoryEffectActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'RecoverInventoryEffectActionInvalidProblem'> => + RecoverInventoryEffectActionInvalidProblemSchema.make({ + detail: 'The recover-inventory-effect Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'RecoverInventoryEffectActionNotFoundProblem'>['code'], + ): ProblemOf<'RecoverInventoryEffectActionNotFoundProblem'> => + RecoverInventoryEffectActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'RecoverInventoryEffectActionPreconditionProblem'> => + RecoverInventoryEffectActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'RecoverInventoryEffectActionUnavailableProblem'>['code'], + ): ProblemOf<'RecoverInventoryEffectActionUnavailableProblem'> => + RecoverInventoryEffectActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): RecoverInventoryEffectActionProblem => + Match.value(error).pipe( + Match.tags({ + InventoryEffectLedgerConflict: () => + recoverInventoryEffectActionProblem.conflict('inventory_effect_ledger_conflict'), + InventoryEffectLedgerRejected: () => + recoverInventoryEffectActionProblem.ineligible('inventory_effect_ledger_rejected'), + InventoryEffectLedgerUnavailable: () => + recoverInventoryEffectActionProblem.unavailable('inventory_effect_ledger_unavailable'), + InventoryEffectRecoveryRejected: () => + recoverInventoryEffectActionProblem.ineligible('inventory_effect_recovery_rejected'), + RecoverInventoryEffectActionRejected: () => + recoverInventoryEffectActionProblem.ineligible('recover_inventory_effect_action_rejected'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): RecoverInventoryEffectActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + RecoverInventoryEffectActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: recoverInventoryEffectActionProblem.internal, + ActionCommitIndeterminate: (failure) => + RecoverInventoryEffectActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: recoverInventoryEffectActionProblem.internal, + ActionIdempotencyKeyRequired: recoverInventoryEffectActionProblem.precondition, + ActionInvocationNotFound: (failure) => recoverInventoryEffectActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => recoverInventoryEffectActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => recoverInventoryEffectActionProblem.conflict(failure.code), + ActionPayloadValidationError: recoverInventoryEffectActionProblem.invalid, + ActionPermissionCheckError: (failure) => recoverInventoryEffectActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => recoverInventoryEffectActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => recoverInventoryEffectActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => recoverInventoryEffectActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => recoverInventoryEffectActionProblem.conflict(failure.code), + ActionResultValidationError: recoverInventoryEffectActionProblem.internal, + ActionTransactionError: (failure) => recoverInventoryEffectActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: recoverInventoryEffectActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => recoverInventoryEffectActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => recoverInventoryEffectActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: recoverInventoryEffectActionProblem.authentication, + OperationContextDenied: (failure) => recoverInventoryEffectActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => recoverInventoryEffectActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => recoverInventoryEffectActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(recoverInventoryEffectAction.descriptor.domainErrorSchema); +export const mapRecoverInventoryEffectActionProblem = ( + error: ActionCoreError | DomainError, +): RecoverInventoryEffectActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const recoverInventoryEffectActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + RecoverInventoryEffectActionSchemaErrorMiddleware, + () => Effect.fail(recoverInventoryEffectActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/recover-inventory-effect-action-server.ts b/app/verticals/inventory/api/recover-inventory-effect-action-server.ts new file mode 100644 index 000000000..59b89a1b4 --- /dev/null +++ b/app/verticals/inventory/api/recover-inventory-effect-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug recover-inventory-effect +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { recoverInventoryEffectAction } from '../src/actions/recover-inventory-effect.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + recoverInventoryEffectActionProblem, + recoverInventoryEffectActionSchemaErrorLive, + mapRecoverInventoryEffectActionProblem, +} from './recover-inventory-effect-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: recoverInventoryEffectActionProblem.authentication, + unavailable: () => recoverInventoryEffectActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('RecoverInventoryEffectActionServer.execute')(function* executeRecoverInventoryEffect( + payload: typeof recoverInventoryEffectAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(recoverInventoryEffectActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(recoverInventoryEffectAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(recoverInventoryEffectActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: recoverInventoryEffectActionProblem.internal, + invalidCorrelationProblem: recoverInventoryEffectActionProblem.invalid, + mapError: mapRecoverInventoryEffectActionProblem, + payload: decoded, + registration: recoverInventoryEffectAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const recoverInventoryEffectActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'recoverInventoryEffectAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(recoverInventoryEffectActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/release-inventory-reservation-action-problems.ts b/app/verticals/inventory/api/release-inventory-reservation-action-problems.ts new file mode 100644 index 000000000..c2fc5bc51 --- /dev/null +++ b/app/verticals/inventory/api/release-inventory-reservation-action-problems.ts @@ -0,0 +1,194 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug release-inventory-reservation +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + ReleaseInventoryReservationActionAlreadyCommittedProblemSchema, + ReleaseInventoryReservationActionAuthenticationProblemSchema, + ReleaseInventoryReservationActionCommitIndeterminateProblemSchema, + ReleaseInventoryReservationActionConflictProblemSchema, + ReleaseInventoryReservationActionForbiddenProblemSchema, + ReleaseInventoryReservationActionIneligibleProblemSchema, + ReleaseInventoryReservationActionInternalProblemSchema, + ReleaseInventoryReservationActionInvalidProblemSchema, + ReleaseInventoryReservationActionNotFoundProblemSchema, + ReleaseInventoryReservationActionPreconditionProblemSchema, + ReleaseInventoryReservationActionSchemaErrorMiddleware, + ReleaseInventoryReservationActionUnavailableProblemSchema, +} from '../shared/apis/release-inventory-reservation-action.ts'; +import type { ReleaseInventoryReservationActionProblem } from '../shared/apis/release-inventory-reservation-action.ts'; +import { releaseInventoryReservationAction } from '../src/actions/release-inventory-reservation.action.ts'; + +type DomainError = typeof releaseInventoryReservationAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + ReleaseInventoryReservationActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const releaseInventoryReservationActionProblem = { + authentication: (): ProblemOf<'ReleaseInventoryReservationActionAuthenticationProblem'> => + ReleaseInventoryReservationActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'ReleaseInventoryReservationActionConflictProblem'>['code'], + ): ProblemOf<'ReleaseInventoryReservationActionConflictProblem'> => + ReleaseInventoryReservationActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'ReleaseInventoryReservationActionForbiddenProblem'>['code'], + ): ProblemOf<'ReleaseInventoryReservationActionForbiddenProblem'> => + ReleaseInventoryReservationActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'ReleaseInventoryReservationActionIneligibleProblem'>['code'], + ): ProblemOf<'ReleaseInventoryReservationActionIneligibleProblem'> => + ReleaseInventoryReservationActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'ReleaseInventoryReservationActionInternalProblem'> => + ReleaseInventoryReservationActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'ReleaseInventoryReservationActionInvalidProblem'> => + ReleaseInventoryReservationActionInvalidProblemSchema.make({ + detail: 'The release-inventory-reservation Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'ReleaseInventoryReservationActionNotFoundProblem'>['code'], + ): ProblemOf<'ReleaseInventoryReservationActionNotFoundProblem'> => + ReleaseInventoryReservationActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'ReleaseInventoryReservationActionPreconditionProblem'> => + ReleaseInventoryReservationActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'ReleaseInventoryReservationActionUnavailableProblem'>['code'], + ): ProblemOf<'ReleaseInventoryReservationActionUnavailableProblem'> => + ReleaseInventoryReservationActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): ReleaseInventoryReservationActionProblem => + Match.value(error).pipe( + Match.tags({ + InventoryReservationReleaseRejected: () => + releaseInventoryReservationActionProblem.ineligible('inventory_reservation_release_rejected'), + InventoryReservationReleaseUnavailable: () => + releaseInventoryReservationActionProblem.unavailable('inventory_reservation_release_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): ReleaseInventoryReservationActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + ReleaseInventoryReservationActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: releaseInventoryReservationActionProblem.internal, + ActionCommitIndeterminate: (failure) => + ReleaseInventoryReservationActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: releaseInventoryReservationActionProblem.internal, + ActionIdempotencyKeyRequired: releaseInventoryReservationActionProblem.precondition, + ActionInvocationNotFound: (failure) => releaseInventoryReservationActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => releaseInventoryReservationActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => releaseInventoryReservationActionProblem.conflict(failure.code), + ActionPayloadValidationError: releaseInventoryReservationActionProblem.invalid, + ActionPermissionCheckError: (failure) => releaseInventoryReservationActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => releaseInventoryReservationActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => releaseInventoryReservationActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => releaseInventoryReservationActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => releaseInventoryReservationActionProblem.conflict(failure.code), + ActionResultValidationError: releaseInventoryReservationActionProblem.internal, + ActionTransactionError: (failure) => releaseInventoryReservationActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: releaseInventoryReservationActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => releaseInventoryReservationActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => releaseInventoryReservationActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: releaseInventoryReservationActionProblem.authentication, + OperationContextDenied: (failure) => releaseInventoryReservationActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => releaseInventoryReservationActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => releaseInventoryReservationActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(releaseInventoryReservationAction.descriptor.domainErrorSchema); +export const mapReleaseInventoryReservationActionProblem = ( + error: ActionCoreError | DomainError, +): ReleaseInventoryReservationActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const releaseInventoryReservationActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + ReleaseInventoryReservationActionSchemaErrorMiddleware, + () => Effect.fail(releaseInventoryReservationActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/release-inventory-reservation-action-server.ts b/app/verticals/inventory/api/release-inventory-reservation-action-server.ts new file mode 100644 index 000000000..1f2bc806e --- /dev/null +++ b/app/verticals/inventory/api/release-inventory-reservation-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug release-inventory-reservation +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { releaseInventoryReservationAction } from '../src/actions/release-inventory-reservation.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + releaseInventoryReservationActionProblem, + releaseInventoryReservationActionSchemaErrorLive, + mapReleaseInventoryReservationActionProblem, +} from './release-inventory-reservation-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: releaseInventoryReservationActionProblem.authentication, + unavailable: () => releaseInventoryReservationActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('ReleaseInventoryReservationActionServer.execute')( + function* executeReleaseInventoryReservation( + payload: typeof releaseInventoryReservationAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(releaseInventoryReservationActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(releaseInventoryReservationAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(releaseInventoryReservationActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: releaseInventoryReservationActionProblem.internal, + invalidCorrelationProblem: releaseInventoryReservationActionProblem.invalid, + mapError: mapReleaseInventoryReservationActionProblem, + payload: decoded, + registration: releaseInventoryReservationAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const releaseInventoryReservationActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'releaseInventoryReservationAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(releaseInventoryReservationActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/reservation-confirmation-verification-read-server.ts b/app/verticals/inventory/api/reservation-confirmation-verification-read-server.ts new file mode 100644 index 000000000..5e00935b9 --- /dev/null +++ b/app/verticals/inventory/api/reservation-confirmation-verification-read-server.ts @@ -0,0 +1,105 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + ReservationConfirmationVerificationAuthenticationProblemSchema, + ReservationConfirmationVerificationDomainConflictProblemSchema, + ReservationConfirmationVerificationDomainPolicyProblemSchema, + ReservationConfirmationVerificationDomainUnavailableProblemSchema, + ReservationConfirmationVerificationForbiddenProblemSchema, + ReservationConfirmationVerificationInternalProblemSchema, + ReservationConfirmationVerificationInvalidProblemSchema, + ReservationConfirmationVerificationNotFoundProblemSchema, + ReservationConfirmationVerificationPolicyConflictProblemSchema, + ReservationConfirmationVerificationPolicyProblemSchema, + ReservationConfirmationVerificationUnavailableProblemSchema, +} from '../shared/apis/reservation-confirmation-verification.ts'; +import type { + ReservationConfirmationVerificationDomainConflictProblem, + ReservationConfirmationVerificationDomainPolicyProblem, + ReservationConfirmationVerificationDomainUnavailableProblem, +} from '../shared/apis/reservation-confirmation-verification.ts'; +import { + ReservationConfirmationRejected, + ReservationConfirmationUnavailable, +} from '../shared/domain/reservation-confirmation.ts'; +import { reservationConfirmationVerificationRead } from '../src/api/reservation-confirmation-verification.read.ts'; +import type { ReservationConfirmationVerificationDomainError } from '../src/api/reservation-confirmation-verification.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: ReservationConfirmationVerificationAuthenticationProblemSchema, + forbidden: ReservationConfirmationVerificationForbiddenProblemSchema, + internal: ReservationConfirmationVerificationInternalProblemSchema, + invalid: ReservationConfirmationVerificationInvalidProblemSchema, + notFound: ReservationConfirmationVerificationNotFoundProblemSchema, + policyConflict: ReservationConfirmationVerificationPolicyConflictProblemSchema, + policyIneligible: ReservationConfirmationVerificationPolicyProblemSchema, + unavailable: ReservationConfirmationVerificationUnavailableProblemSchema, +}); + +export const mapReservationConfirmationVerificationDomainError = ( + error: ReservationConfirmationVerificationDomainError, +): + | ReservationConfirmationVerificationDomainConflictProblem + | ReservationConfirmationVerificationDomainPolicyProblem + | ReservationConfirmationVerificationDomainUnavailableProblem => { + if (Schema.is(ReservationConfirmationRejected)(error)) { + if ( + new Set([ + 'CONFIRMATION_IDENTITY_CONFLICT', + 'RESERVATION_SCOPE_MISMATCH', + 'REVISION_CONFLICT', + 'SIBLING_CONFIRMATION_FORBIDDEN', + 'TERMINAL_HEALTH_STATE', + ]).has(error.reason) + ) { + return ReservationConfirmationVerificationDomainConflictProblemSchema.make({ + detail: 'The Confirmation does not belong to the requested Reservation and Attempt state.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal of the declared status-specific problem constructor; expires: 2027-03-31. + status: 409, + title: 'Reservation Confirmation conflict', + type: 'https://ontos.dev/problems/reservation-confirmation-conflict', + }); + } + return ReservationConfirmationVerificationDomainPolicyProblemSchema.make({ + detail: 'The Reservation Confirmation cannot be verified safely.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal of the declared status-specific problem constructor; expires: 2027-03-31. + status: 422, + title: 'Reservation Confirmation rejected', + type: 'https://ontos.dev/problems/reservation-confirmation-rejected', + }); + } + const reasonCode = Schema.is(ReservationConfirmationUnavailable)(error) + ? error.code + : 'reservation_confirmation_unavailable'; + return ReservationConfirmationVerificationDomainUnavailableProblemSchema.make({ + detail: 'Reservation Confirmation evidence is temporarily unavailable.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Reservation Confirmation unavailable', + type: 'https://ontos.dev/problems/reservation-confirmation-unavailable', + }); +}; + +export const reservationConfirmationVerificationReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'reservationConfirmationVerification', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapReservationConfirmationVerificationDomainError, + problems, + registration: reservationConfirmationVerificationRead, + }), + ), +); diff --git a/app/verticals/inventory/api/resolve-inventory-source-conflict-action-problems.ts b/app/verticals/inventory/api/resolve-inventory-source-conflict-action-problems.ts new file mode 100644 index 000000000..890f7e67a --- /dev/null +++ b/app/verticals/inventory/api/resolve-inventory-source-conflict-action-problems.ts @@ -0,0 +1,199 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug resolve-inventory-source-conflict +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + ResolveInventorySourceConflictActionAlreadyCommittedProblemSchema, + ResolveInventorySourceConflictActionAuthenticationProblemSchema, + ResolveInventorySourceConflictActionCommitIndeterminateProblemSchema, + ResolveInventorySourceConflictActionConflictProblemSchema, + ResolveInventorySourceConflictActionForbiddenProblemSchema, + ResolveInventorySourceConflictActionIneligibleProblemSchema, + ResolveInventorySourceConflictActionInternalProblemSchema, + ResolveInventorySourceConflictActionInvalidProblemSchema, + ResolveInventorySourceConflictActionNotFoundProblemSchema, + ResolveInventorySourceConflictActionPreconditionProblemSchema, + ResolveInventorySourceConflictActionSchemaErrorMiddleware, + ResolveInventorySourceConflictActionUnavailableProblemSchema, +} from '../shared/apis/resolve-inventory-source-conflict-action.ts'; +import type { ResolveInventorySourceConflictActionProblem } from '../shared/apis/resolve-inventory-source-conflict-action.ts'; +import { resolveInventorySourceConflictAction } from '../src/actions/resolve-inventory-source-conflict.action.ts'; + +type DomainError = typeof resolveInventorySourceConflictAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + ResolveInventorySourceConflictActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const resolveInventorySourceConflictActionProblem = { + authentication: (): ProblemOf<'ResolveInventorySourceConflictActionAuthenticationProblem'> => + ResolveInventorySourceConflictActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'ResolveInventorySourceConflictActionConflictProblem'>['code'], + ): ProblemOf<'ResolveInventorySourceConflictActionConflictProblem'> => + ResolveInventorySourceConflictActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'ResolveInventorySourceConflictActionForbiddenProblem'>['code'], + ): ProblemOf<'ResolveInventorySourceConflictActionForbiddenProblem'> => + ResolveInventorySourceConflictActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'ResolveInventorySourceConflictActionIneligibleProblem'>['code'], + ): ProblemOf<'ResolveInventorySourceConflictActionIneligibleProblem'> => + ResolveInventorySourceConflictActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'ResolveInventorySourceConflictActionInternalProblem'> => + ResolveInventorySourceConflictActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'ResolveInventorySourceConflictActionInvalidProblem'> => + ResolveInventorySourceConflictActionInvalidProblemSchema.make({ + detail: 'The resolve-inventory-source-conflict Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'ResolveInventorySourceConflictActionNotFoundProblem'>['code'], + ): ProblemOf<'ResolveInventorySourceConflictActionNotFoundProblem'> => + ResolveInventorySourceConflictActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'ResolveInventorySourceConflictActionPreconditionProblem'> => + ResolveInventorySourceConflictActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'ResolveInventorySourceConflictActionUnavailableProblem'>['code'], + ): ProblemOf<'ResolveInventorySourceConflictActionUnavailableProblem'> => + ResolveInventorySourceConflictActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): ResolveInventorySourceConflictActionProblem => + Match.value(error).pipe( + Match.tags({ + InventorySourceConflictNotFound: () => + resolveInventorySourceConflictActionProblem.notFound('inventory_source_conflict_not_found'), + InventorySourceConflictRejected: () => + resolveInventorySourceConflictActionProblem.conflict('inventory_source_conflict_rejected'), + InventorySourceConflictUnavailable: () => + resolveInventorySourceConflictActionProblem.unavailable('inventory_source_conflict_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): ResolveInventorySourceConflictActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + ResolveInventorySourceConflictActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: resolveInventorySourceConflictActionProblem.internal, + ActionCommitIndeterminate: (failure) => + ResolveInventorySourceConflictActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: resolveInventorySourceConflictActionProblem.internal, + ActionIdempotencyKeyRequired: resolveInventorySourceConflictActionProblem.precondition, + ActionInvocationNotFound: (failure) => resolveInventorySourceConflictActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => + resolveInventorySourceConflictActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => resolveInventorySourceConflictActionProblem.conflict(failure.code), + ActionPayloadValidationError: resolveInventorySourceConflictActionProblem.invalid, + ActionPermissionCheckError: (failure) => resolveInventorySourceConflictActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => resolveInventorySourceConflictActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => resolveInventorySourceConflictActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => resolveInventorySourceConflictActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => resolveInventorySourceConflictActionProblem.conflict(failure.code), + ActionResultValidationError: resolveInventorySourceConflictActionProblem.internal, + ActionTransactionError: (failure) => resolveInventorySourceConflictActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: resolveInventorySourceConflictActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => + resolveInventorySourceConflictActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => resolveInventorySourceConflictActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: resolveInventorySourceConflictActionProblem.authentication, + OperationContextDenied: (failure) => resolveInventorySourceConflictActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => resolveInventorySourceConflictActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => resolveInventorySourceConflictActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(resolveInventorySourceConflictAction.descriptor.domainErrorSchema); +export const mapResolveInventorySourceConflictActionProblem = ( + error: ActionCoreError | DomainError, +): ResolveInventorySourceConflictActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const resolveInventorySourceConflictActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + ResolveInventorySourceConflictActionSchemaErrorMiddleware, + () => Effect.fail(resolveInventorySourceConflictActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/resolve-inventory-source-conflict-action-server.ts b/app/verticals/inventory/api/resolve-inventory-source-conflict-action-server.ts new file mode 100644 index 000000000..1f5e9a93b --- /dev/null +++ b/app/verticals/inventory/api/resolve-inventory-source-conflict-action-server.ts @@ -0,0 +1,56 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug resolve-inventory-source-conflict +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { resolveInventorySourceConflictAction } from '../src/actions/resolve-inventory-source-conflict.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + resolveInventorySourceConflictActionProblem, + resolveInventorySourceConflictActionSchemaErrorLive, + mapResolveInventorySourceConflictActionProblem, +} from './resolve-inventory-source-conflict-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: resolveInventorySourceConflictActionProblem.authentication, + unavailable: () => resolveInventorySourceConflictActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('ResolveInventorySourceConflictActionServer.execute')( + function* executeResolveInventorySourceConflict( + payload: typeof resolveInventorySourceConflictAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, + ) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(resolveInventorySourceConflictActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(resolveInventorySourceConflictAction.descriptor.payloadSchema)( + payload, + ).pipe(Effect.mapError(resolveInventorySourceConflictActionProblem.invalid)); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: resolveInventorySourceConflictActionProblem.internal, + invalidCorrelationProblem: resolveInventorySourceConflictActionProblem.invalid, + mapError: mapResolveInventorySourceConflictActionProblem, + payload: decoded, + registration: resolveInventorySourceConflictAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); + }, +); + +export const resolveInventorySourceConflictActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'resolveInventorySourceConflictAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(resolveInventorySourceConflictActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/select-inventory-backend-action-problems.ts b/app/verticals/inventory/api/select-inventory-backend-action-problems.ts new file mode 100644 index 000000000..f6ffcdcd9 --- /dev/null +++ b/app/verticals/inventory/api/select-inventory-backend-action-problems.ts @@ -0,0 +1,194 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug select-inventory-backend +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + SelectInventoryBackendActionAlreadyCommittedProblemSchema, + SelectInventoryBackendActionAuthenticationProblemSchema, + SelectInventoryBackendActionCommitIndeterminateProblemSchema, + SelectInventoryBackendActionConflictProblemSchema, + SelectInventoryBackendActionForbiddenProblemSchema, + SelectInventoryBackendActionIneligibleProblemSchema, + SelectInventoryBackendActionInternalProblemSchema, + SelectInventoryBackendActionInvalidProblemSchema, + SelectInventoryBackendActionNotFoundProblemSchema, + SelectInventoryBackendActionPreconditionProblemSchema, + SelectInventoryBackendActionSchemaErrorMiddleware, + SelectInventoryBackendActionUnavailableProblemSchema, +} from '../shared/apis/select-inventory-backend-action.ts'; +import type { SelectInventoryBackendActionProblem } from '../shared/apis/select-inventory-backend-action.ts'; +import { selectInventoryBackendAction } from '../src/actions/select-inventory-backend.action.ts'; + +type DomainError = typeof selectInventoryBackendAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + SelectInventoryBackendActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const selectInventoryBackendActionProblem = { + authentication: (): ProblemOf<'SelectInventoryBackendActionAuthenticationProblem'> => + SelectInventoryBackendActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'SelectInventoryBackendActionConflictProblem'>['code'], + ): ProblemOf<'SelectInventoryBackendActionConflictProblem'> => + SelectInventoryBackendActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'SelectInventoryBackendActionForbiddenProblem'>['code'], + ): ProblemOf<'SelectInventoryBackendActionForbiddenProblem'> => + SelectInventoryBackendActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'SelectInventoryBackendActionIneligibleProblem'>['code'], + ): ProblemOf<'SelectInventoryBackendActionIneligibleProblem'> => + SelectInventoryBackendActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'SelectInventoryBackendActionInternalProblem'> => + SelectInventoryBackendActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'SelectInventoryBackendActionInvalidProblem'> => + SelectInventoryBackendActionInvalidProblemSchema.make({ + detail: 'The select-inventory-backend Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'SelectInventoryBackendActionNotFoundProblem'>['code'], + ): ProblemOf<'SelectInventoryBackendActionNotFoundProblem'> => + SelectInventoryBackendActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'SelectInventoryBackendActionPreconditionProblem'> => + SelectInventoryBackendActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'SelectInventoryBackendActionUnavailableProblem'>['code'], + ): ProblemOf<'SelectInventoryBackendActionUnavailableProblem'> => + SelectInventoryBackendActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): SelectInventoryBackendActionProblem => + Match.value(error).pipe( + Match.tags({ + InventoryBackendConfigurationPersistenceUnavailable: () => + selectInventoryBackendActionProblem.unavailable('inventory_backend_configuration_persistence_unavailable'), + InventoryBackendSelectionRejected: () => + selectInventoryBackendActionProblem.ineligible('inventory_backend_selection_rejected'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): SelectInventoryBackendActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + SelectInventoryBackendActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: selectInventoryBackendActionProblem.internal, + ActionCommitIndeterminate: (failure) => + SelectInventoryBackendActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: selectInventoryBackendActionProblem.internal, + ActionIdempotencyKeyRequired: selectInventoryBackendActionProblem.precondition, + ActionInvocationNotFound: (failure) => selectInventoryBackendActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => selectInventoryBackendActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => selectInventoryBackendActionProblem.conflict(failure.code), + ActionPayloadValidationError: selectInventoryBackendActionProblem.invalid, + ActionPermissionCheckError: (failure) => selectInventoryBackendActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => selectInventoryBackendActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => selectInventoryBackendActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => selectInventoryBackendActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => selectInventoryBackendActionProblem.conflict(failure.code), + ActionResultValidationError: selectInventoryBackendActionProblem.internal, + ActionTransactionError: (failure) => selectInventoryBackendActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: selectInventoryBackendActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => selectInventoryBackendActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => selectInventoryBackendActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: selectInventoryBackendActionProblem.authentication, + OperationContextDenied: (failure) => selectInventoryBackendActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => selectInventoryBackendActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => selectInventoryBackendActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(selectInventoryBackendAction.descriptor.domainErrorSchema); +export const mapSelectInventoryBackendActionProblem = ( + error: ActionCoreError | DomainError, +): SelectInventoryBackendActionProblem => (isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error)); + +export const selectInventoryBackendActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + SelectInventoryBackendActionSchemaErrorMiddleware, + () => Effect.fail(selectInventoryBackendActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/select-inventory-backend-action-server.ts b/app/verticals/inventory/api/select-inventory-backend-action-server.ts new file mode 100644 index 000000000..bb4241210 --- /dev/null +++ b/app/verticals/inventory/api/select-inventory-backend-action-server.ts @@ -0,0 +1,54 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug select-inventory-backend +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { selectInventoryBackendAction } from '../src/actions/select-inventory-backend.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + selectInventoryBackendActionProblem, + selectInventoryBackendActionSchemaErrorLive, + mapSelectInventoryBackendActionProblem, +} from './select-inventory-backend-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: selectInventoryBackendActionProblem.authentication, + unavailable: () => selectInventoryBackendActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('SelectInventoryBackendActionServer.execute')(function* executeSelectInventoryBackend( + payload: typeof selectInventoryBackendAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(selectInventoryBackendActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(selectInventoryBackendAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(selectInventoryBackendActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: selectInventoryBackendActionProblem.internal, + invalidCorrelationProblem: selectInventoryBackendActionProblem.invalid, + mapError: mapSelectInventoryBackendActionProblem, + payload: decoded, + registration: selectInventoryBackendAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const selectInventoryBackendActionApiLive = HttpApiBuilder.group( + inventoryApi, + 'selectInventoryBackendAction', + (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => + execute(payload, headers['idempotency-key'], request), + ), +).pipe(Layer.provide(selectInventoryBackendActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/stock-issue-action-problems.ts b/app/verticals/inventory/api/stock-issue-action-problems.ts new file mode 100644 index 000000000..e544dbce9 --- /dev/null +++ b/app/verticals/inventory/api/stock-issue-action-problems.ts @@ -0,0 +1,191 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-issue +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + StockIssueActionAlreadyCommittedProblemSchema, + StockIssueActionAuthenticationProblemSchema, + StockIssueActionCommitIndeterminateProblemSchema, + StockIssueActionConflictProblemSchema, + StockIssueActionForbiddenProblemSchema, + StockIssueActionIneligibleProblemSchema, + StockIssueActionInternalProblemSchema, + StockIssueActionInvalidProblemSchema, + StockIssueActionNotFoundProblemSchema, + StockIssueActionPreconditionProblemSchema, + StockIssueActionSchemaErrorMiddleware, + StockIssueActionUnavailableProblemSchema, +} from '../shared/apis/stock-issue-action.ts'; +import type { StockIssueActionProblem } from '../shared/apis/stock-issue-action.ts'; +import { stockIssueAction } from '../src/actions/stock-issue.action.ts'; + +type DomainError = typeof stockIssueAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const stockIssueActionProblem = { + authentication: (): ProblemOf<'StockIssueActionAuthenticationProblem'> => + StockIssueActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'StockIssueActionConflictProblem'>['code'], + ): ProblemOf<'StockIssueActionConflictProblem'> => + StockIssueActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'StockIssueActionForbiddenProblem'>['code'], + ): ProblemOf<'StockIssueActionForbiddenProblem'> => + StockIssueActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'StockIssueActionIneligibleProblem'>['code'], + ): ProblemOf<'StockIssueActionIneligibleProblem'> => + StockIssueActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'StockIssueActionInternalProblem'> => + StockIssueActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'StockIssueActionInvalidProblem'> => + StockIssueActionInvalidProblemSchema.make({ + detail: 'The stock-issue Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'StockIssueActionNotFoundProblem'>['code'], + ): ProblemOf<'StockIssueActionNotFoundProblem'> => + StockIssueActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'StockIssueActionPreconditionProblem'> => + StockIssueActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'StockIssueActionUnavailableProblem'>['code'], + ): ProblemOf<'StockIssueActionUnavailableProblem'> => + StockIssueActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): StockIssueActionProblem => + Match.value(error).pipe( + Match.tags({ + PhysicalStockEffectConflict: () => stockIssueActionProblem.conflict('physical_stock_effect_conflict'), + PhysicalStockEffectIndeterminate: () => + stockIssueActionProblem.unavailable('physical_stock_effect_indeterminate'), + PhysicalStockEffectRejected: () => stockIssueActionProblem.ineligible('physical_stock_effect_rejected'), + PhysicalStockEffectUnavailable: () => stockIssueActionProblem.unavailable('physical_stock_effect_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): StockIssueActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + StockIssueActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: stockIssueActionProblem.internal, + ActionCommitIndeterminate: (failure) => + StockIssueActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: stockIssueActionProblem.internal, + ActionIdempotencyKeyRequired: stockIssueActionProblem.precondition, + ActionInvocationNotFound: (failure) => stockIssueActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => stockIssueActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => stockIssueActionProblem.conflict(failure.code), + ActionPayloadValidationError: stockIssueActionProblem.invalid, + ActionPermissionCheckError: (failure) => stockIssueActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => stockIssueActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => stockIssueActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => stockIssueActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => stockIssueActionProblem.conflict(failure.code), + ActionResultValidationError: stockIssueActionProblem.internal, + ActionTransactionError: (failure) => stockIssueActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: stockIssueActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => stockIssueActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => stockIssueActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: stockIssueActionProblem.authentication, + OperationContextDenied: (failure) => stockIssueActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => stockIssueActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => stockIssueActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(stockIssueAction.descriptor.domainErrorSchema); +export const mapStockIssueActionProblem = (error: ActionCoreError | DomainError): StockIssueActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const stockIssueActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + StockIssueActionSchemaErrorMiddleware, + () => Effect.fail(stockIssueActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/stock-issue-action-server.ts b/app/verticals/inventory/api/stock-issue-action-server.ts new file mode 100644 index 000000000..1b9fcd5b1 --- /dev/null +++ b/app/verticals/inventory/api/stock-issue-action-server.ts @@ -0,0 +1,49 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-issue +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { stockIssueAction } from '../src/actions/stock-issue.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + stockIssueActionProblem, + stockIssueActionSchemaErrorLive, + mapStockIssueActionProblem, +} from './stock-issue-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: stockIssueActionProblem.authentication, + unavailable: () => stockIssueActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('StockIssueActionServer.execute')(function* executeStockIssue( + payload: typeof stockIssueAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(stockIssueActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(stockIssueAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(stockIssueActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: stockIssueActionProblem.internal, + invalidCorrelationProblem: stockIssueActionProblem.invalid, + mapError: mapStockIssueActionProblem, + payload: decoded, + registration: stockIssueAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const stockIssueActionApiLive = HttpApiBuilder.group(inventoryApi, 'stockIssueAction', (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => execute(payload, headers['idempotency-key'], request)), +).pipe(Layer.provide(stockIssueActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/stock-receipt-action-problems.ts b/app/verticals/inventory/api/stock-receipt-action-problems.ts new file mode 100644 index 000000000..486e71513 --- /dev/null +++ b/app/verticals/inventory/api/stock-receipt-action-problems.ts @@ -0,0 +1,194 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-receipt +import type { ActionCoreError } from '@app/core-runtime'; +import { Effect, HttpApiMiddleware } from '@modern-js/bff-effect/effect-edge'; +import { Match, Schema } from 'effect'; +import { + StockReceiptActionAlreadyCommittedProblemSchema, + StockReceiptActionAuthenticationProblemSchema, + StockReceiptActionCommitIndeterminateProblemSchema, + StockReceiptActionConflictProblemSchema, + StockReceiptActionForbiddenProblemSchema, + StockReceiptActionIneligibleProblemSchema, + StockReceiptActionInternalProblemSchema, + StockReceiptActionInvalidProblemSchema, + StockReceiptActionNotFoundProblemSchema, + StockReceiptActionPreconditionProblemSchema, + StockReceiptActionSchemaErrorMiddleware, + StockReceiptActionUnavailableProblemSchema, +} from '../shared/apis/stock-receipt-action.ts'; +import type { StockReceiptActionProblem } from '../shared/apis/stock-receipt-action.ts'; +import { stockReceiptAction } from '../src/actions/stock-receipt.action.ts'; + +type DomainError = typeof stockReceiptAction.descriptor.domainErrorSchema.Type; +type ProblemOf = Extract< + StockReceiptActionProblem, + { readonly _tag: Tag } +>; + +const problemStatus = { + authentication: 401, + conflict: 409, + forbidden: 403, + ineligible: 422, + internal: 500, + invalid: 400, + notFound: 404, + precondition: 428, + rateLimited: 429, + timeout: 504, + unavailable: 503, +} as const; + +export const stockReceiptActionProblem = { + authentication: (): ProblemOf<'StockReceiptActionAuthenticationProblem'> => + StockReceiptActionAuthenticationProblemSchema.make({ + detail: 'A valid audience-scoped Bearer assertion is required.', + status: problemStatus.authentication, + title: 'Authentication required', + type: 'https://ontos.dev/problems/operation-authentication-required', + }), + conflict: ( + code: ProblemOf<'StockReceiptActionConflictProblem'>['code'], + ): ProblemOf<'StockReceiptActionConflictProblem'> => + StockReceiptActionConflictProblemSchema.make({ + code, + detail: 'The Action conflicts with current state.', + status: problemStatus.conflict, + title: 'Action conflict', + type: 'https://ontos.dev/problems/action-conflict', + }), + forbidden: ( + code: ProblemOf<'StockReceiptActionForbiddenProblem'>['code'], + ): ProblemOf<'StockReceiptActionForbiddenProblem'> => + StockReceiptActionForbiddenProblemSchema.make({ + code, + detail: 'The principal is not permitted to perform this Action.', + status: problemStatus.forbidden, + title: 'Action forbidden', + type: 'https://ontos.dev/problems/action-forbidden', + }), + ineligible: ( + code: ProblemOf<'StockReceiptActionIneligibleProblem'>['code'], + ): ProblemOf<'StockReceiptActionIneligibleProblem'> => + StockReceiptActionIneligibleProblemSchema.make({ + code, + detail: 'The request is not eligible for this Action.', + status: problemStatus.ineligible, + title: 'Action ineligible', + type: 'https://ontos.dev/problems/action-ineligible', + }), + internal: (): ProblemOf<'StockReceiptActionInternalProblem'> => + StockReceiptActionInternalProblemSchema.make({ + detail: 'The Action could not be completed.', + status: problemStatus.internal, + title: 'Action failed', + type: 'https://ontos.dev/problems/action-failed', + }), + invalid: (): ProblemOf<'StockReceiptActionInvalidProblem'> => + StockReceiptActionInvalidProblemSchema.make({ + detail: 'The stock-receipt Action request is invalid.', + status: problemStatus.invalid, + title: 'Invalid Action request', + type: 'https://ontos.dev/problems/action-invalid', + }), + notFound: ( + code: ProblemOf<'StockReceiptActionNotFoundProblem'>['code'], + ): ProblemOf<'StockReceiptActionNotFoundProblem'> => + StockReceiptActionNotFoundProblemSchema.make({ + code, + detail: 'The requested resource was not found.', + status: problemStatus.notFound, + title: 'Resource not found', + type: 'https://ontos.dev/problems/action-resource-not-found', + }), + precondition: (): ProblemOf<'StockReceiptActionPreconditionProblem'> => + StockReceiptActionPreconditionProblemSchema.make({ + detail: 'An Idempotency-Key header is required.', + status: problemStatus.precondition, + title: 'Idempotency key required', + type: 'https://ontos.dev/problems/idempotency-key-required', + }), + unavailable: ( + code: ProblemOf<'StockReceiptActionUnavailableProblem'>['code'], + ): ProblemOf<'StockReceiptActionUnavailableProblem'> => + StockReceiptActionUnavailableProblemSchema.make({ + code, + detail: 'The Action capability is temporarily unavailable.', + retryable: true, + status: problemStatus.unavailable, + title: 'Action unavailable', + type: 'https://ontos.dev/problems/action-unavailable', + }), +} as const; + +const mapDomainProblem = (error: DomainError): StockReceiptActionProblem => + Match.value(error).pipe( + Match.tags({ + PhysicalStockEffectConflict: () => stockReceiptActionProblem.conflict('physical_stock_effect_conflict'), + PhysicalStockEffectIndeterminate: () => + stockReceiptActionProblem.unavailable('physical_stock_effect_indeterminate'), + PhysicalStockEffectRejected: () => stockReceiptActionProblem.ineligible('physical_stock_effect_rejected'), + PhysicalStockEffectUnavailable: () => stockReceiptActionProblem.unavailable('physical_stock_effect_unavailable'), + }), + Match.exhaustive, + ); + +const mapCoreProblem = (error: ActionCoreError): StockReceiptActionProblem => + Match.value(error).pipe( + Match.tags({ + ActionAlreadyCommitted: (failure) => + StockReceiptActionAlreadyCommittedProblemSchema.make({ + code: failure.code, + detail: 'This Action is already committed. Refresh governed reads.', + invocationId: failure.invocationId, + resolution: 'REFRESH_GOVERNED_READS', + retryCommand: false, + status: problemStatus.conflict, + title: 'Action already committed', + type: 'https://ontos.dev/problems/action-already-committed', + }), + ActionCollectorError: stockReceiptActionProblem.internal, + ActionCommitIndeterminate: (failure) => + StockReceiptActionCommitIndeterminateProblemSchema.make({ + detail: 'The Action commit is uncertain. Resolve this invocation before another attempt.', + invocationId: failure.invocationId, + resolution: 'RESOLVE_COMMIT', + retryCommand: false, + status: problemStatus.unavailable, + title: 'Action commit uncertain', + type: 'https://ontos.dev/problems/action-commit-indeterminate', + }), + ActionHandlerExecutionError: stockReceiptActionProblem.internal, + ActionIdempotencyKeyRequired: stockReceiptActionProblem.precondition, + ActionInvocationNotFound: (failure) => stockReceiptActionProblem.notFound(failure.code), + ActionInvocationPersistenceError: (failure) => stockReceiptActionProblem.unavailable(failure.code), + ActionInvocationStateError: (failure) => stockReceiptActionProblem.conflict(failure.code), + ActionPayloadValidationError: stockReceiptActionProblem.invalid, + ActionPermissionCheckError: (failure) => stockReceiptActionProblem.unavailable(failure.code), + ActionPermissionDenied: (failure) => stockReceiptActionProblem.forbidden(failure.code), + ActionPolicyDenied: (failure) => stockReceiptActionProblem.ineligible(failure.code), + ActionPolicyEvaluationError: (failure) => stockReceiptActionProblem.unavailable(failure.code), + ActionRequestHashConflict: (failure) => stockReceiptActionProblem.conflict(failure.code), + ActionResultValidationError: stockReceiptActionProblem.internal, + ActionTransactionError: (failure) => stockReceiptActionProblem.unavailable(failure.code), + ActionTrustedContextValidationError: stockReceiptActionProblem.authentication, + ModuleStateCheckUnavailableError: (failure) => stockReceiptActionProblem.unavailable(failure.code), + ModuleStateDeniedError: (failure) => stockReceiptActionProblem.forbidden(failure.code), + OperationAuthenticationRequired: stockReceiptActionProblem.authentication, + OperationContextDenied: (failure) => stockReceiptActionProblem.forbidden(failure.code), + OperationContextInvalid: (failure) => stockReceiptActionProblem.forbidden(failure.code), + OperationContextUnavailable: (failure) => stockReceiptActionProblem.unavailable(failure.code), + }), + Match.exhaustive, + ); + +const isDomainError = Schema.is(stockReceiptAction.descriptor.domainErrorSchema); +export const mapStockReceiptActionProblem = (error: ActionCoreError | DomainError): StockReceiptActionProblem => + isDomainError(error) ? mapDomainProblem(error) : mapCoreProblem(error); + +export const stockReceiptActionSchemaErrorLive = HttpApiMiddleware.layerSchemaErrorTransform( + StockReceiptActionSchemaErrorMiddleware, + () => Effect.fail(stockReceiptActionProblem.invalid()), +); diff --git a/app/verticals/inventory/api/stock-receipt-action-server.ts b/app/verticals/inventory/api/stock-receipt-action-server.ts new file mode 100644 index 000000000..b034130ff --- /dev/null +++ b/app/verticals/inventory/api/stock-receipt-action-server.ts @@ -0,0 +1,49 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-receipt +import { Effect, HttpApiBuilder, Layer } from '@modern-js/bff-effect/effect-edge'; +import type { HttpServerRequest } from 'effect/unstable/http'; +import { Redacted, Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { stockReceiptAction } from '../src/actions/stock-receipt.action.ts'; +import { bindActionHttpRunner } from './action-http-runner.ts'; +import { + stockReceiptActionProblem, + stockReceiptActionSchemaErrorLive, + mapStockReceiptActionProblem, +} from './stock-receipt-action-problems.ts'; + +const runActionHttp = bindActionHttpRunner({ + authentication: stockReceiptActionProblem.authentication, + unavailable: () => stockReceiptActionProblem.unavailable('operation_context_unavailable'), +}); + +const execute = Effect.fn('StockReceiptActionServer.execute')(function* executeStockReceipt( + payload: typeof stockReceiptAction.descriptor.payloadSchema.Encoded, + idempotencyKey: string | undefined, + request: HttpServerRequest.HttpServerRequest, +) { + const correlationId = request.headers['x-correlation-id']; + if (correlationId !== undefined && correlationId.length > 200) { + return yield* Effect.fail(stockReceiptActionProblem.invalid()); + } + const decoded = yield* Schema.decodeEffect(stockReceiptAction.descriptor.payloadSchema)(payload).pipe( + Effect.mapError(stockReceiptActionProblem.invalid), + ); + return yield* runActionHttp({ + endpointHeaders: { idempotencyKey, traceId: request.headers['x-trace-id'] }, + internalProblem: stockReceiptActionProblem.internal, + invalidCorrelationProblem: stockReceiptActionProblem.invalid, + mapError: mapStockReceiptActionProblem, + payload: decoded, + registration: stockReceiptAction, + requestHeaders: { + authorization: Redacted.make(request.headers['authorization']), + 'x-correlation-id': correlationId, + }, + }); +}); + +export const stockReceiptActionApiLive = HttpApiBuilder.group(inventoryApi, 'stockReceiptAction', (handlers) => + handlers.handle('execute', ({ headers, payload, request }) => execute(payload, headers['idempotency-key'], request)), +).pipe(Layer.provide(stockReceiptActionSchemaErrorLive)); diff --git a/app/verticals/inventory/api/stock-sharing-eligibility-resolution-read-server.ts b/app/verticals/inventory/api/stock-sharing-eligibility-resolution-read-server.ts new file mode 100644 index 000000000..bce6806ef --- /dev/null +++ b/app/verticals/inventory/api/stock-sharing-eligibility-resolution-read-server.ts @@ -0,0 +1,80 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedReadHttpHandler } from '@app/core-runtime/http/governed-read'; +import { makeGovernedReadProblems } from '@app/shared-contracts/server/effect-bff-runtime'; +import { HttpApiBuilder } from '@modern-js/bff-effect/effect-edge'; +import { Schema } from 'effect'; +import { inventoryApi } from '../shared/api.ts'; +import { + StockSharingEligibilityResolutionAuthenticationProblemSchema, + StockSharingEligibilityResolutionDomainPolicyProblemSchema, + StockSharingEligibilityResolutionDomainUnavailableProblemSchema, + StockSharingEligibilityResolutionForbiddenProblemSchema, + StockSharingEligibilityResolutionInternalProblemSchema, + StockSharingEligibilityResolutionInvalidProblemSchema, + StockSharingEligibilityResolutionNotFoundProblemSchema, + StockSharingEligibilityResolutionPolicyConflictProblemSchema, + StockSharingEligibilityResolutionPolicyProblemSchema, + StockSharingEligibilityResolutionUnavailableProblemSchema, +} from '../shared/apis/stock-sharing-eligibility-resolution.ts'; +import type { + StockSharingEligibilityResolutionDomainPolicyProblem, + StockSharingEligibilityResolutionDomainUnavailableProblem, +} from '../shared/apis/stock-sharing-eligibility-resolution.ts'; +import { StockSharingEligibilityRejected } from '../shared/domain/stock-sharing-eligibility.ts'; +import { StockSharingEligibilityUnavailable } from '../shared/domain/stock-sharing-eligibility-unavailable.ts'; +import { stockSharingEligibilityResolutionRead } from '../src/api/stock-sharing-eligibility-resolution.read.ts'; +import type { StockSharingEligibilityResolutionDomainError } from '../src/api/stock-sharing-eligibility-resolution.read.ts'; +import { authenticateOperationPrincipal } from './auth/action-principal.ts'; + +const problems = makeGovernedReadProblems({ + authentication: StockSharingEligibilityResolutionAuthenticationProblemSchema, + forbidden: StockSharingEligibilityResolutionForbiddenProblemSchema, + internal: StockSharingEligibilityResolutionInternalProblemSchema, + invalid: StockSharingEligibilityResolutionInvalidProblemSchema, + notFound: StockSharingEligibilityResolutionNotFoundProblemSchema, + policyConflict: StockSharingEligibilityResolutionPolicyConflictProblemSchema, + policyIneligible: StockSharingEligibilityResolutionPolicyProblemSchema, + unavailable: StockSharingEligibilityResolutionUnavailableProblemSchema, +}); + +export const mapStockSharingEligibilityResolutionDomainError = ( + error: StockSharingEligibilityResolutionDomainError, +): StockSharingEligibilityResolutionDomainPolicyProblem | StockSharingEligibilityResolutionDomainUnavailableProblem => { + if (Schema.is(StockSharingEligibilityRejected)(error)) { + return StockSharingEligibilityResolutionDomainPolicyProblemSchema.make({ + detail: 'Stock sharing eligibility was not established for the requested Position and Commerce context.', + reasonCode: error.reason, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 422, + title: 'Stock sharing eligibility not established', + type: 'https://ontos.dev/problems/stock-sharing-eligibility-not-established', + }); + } + const reasonCode = Schema.is(StockSharingEligibilityUnavailable)(error) + ? error.code + : 'stock_sharing_eligibility_unavailable'; + return StockSharingEligibilityResolutionDomainUnavailableProblemSchema.make({ + detail: 'Stock sharing eligibility cannot be resolved safely.', + reasonCode, + retryable: true, + // oxlint-disable-next-line effect-native/no-hand-built-problem-details -- Checked literal field of the declared status-specific problem constructor; expires: 2027-03-31. + status: 503, + title: 'Stock sharing eligibility unavailable', + type: 'https://ontos.dev/problems/stock-sharing-eligibility-unavailable', + }); +}; + +export const stockSharingEligibilityResolutionReadApiLive = HttpApiBuilder.group( + inventoryApi, + 'stockSharingEligibilityResolution', + (handlers) => + handlers.handle( + 'execute', + makeGovernedReadHttpHandler({ + authenticatePrincipal: authenticateOperationPrincipal, + mapDomainError: mapStockSharingEligibilityResolutionDomainError, + problems, + registration: stockSharingEligibilityResolutionRead, + }), + ), +); diff --git a/app/verticals/inventory/backend-federation.config.ts b/app/verticals/inventory/backend-federation.config.ts new file mode 100644 index 000000000..21d4c4a9c --- /dev/null +++ b/app/verticals/inventory/backend-federation.config.ts @@ -0,0 +1,44 @@ +import { createRequire } from 'node:module'; + +import { createModuleFederationConfig } from '@module-federation/modern-js-v3'; +import { decodeUnknownSync, String as SchemaString, Struct } from 'effect/Schema'; + +import { dependencies } from './package.json'; + +const require = createRequire(import.meta.url); +const PackageVersionSchema = Struct({ version: SchemaString }); +const packageVersion = (specifier: string): string => + decodeUnknownSync(PackageVersionSchema)(require(specifier)).version; +const bffVersion = packageVersion('@modern-js/plugin-bff/package.json'); +const effectVersion = packageVersion('effect/package.json'); + +const moduleFederationConfig: Parameters[0] = createModuleFederationConfig({ + dts: false, + exposes: { + './effect-api': './api/effect-api.ts', + }, + filename: 'backendRemoteEntry.cjs', + library: { + type: 'commonjs-module', + }, + name: 'verticalInventoryBackend', + shared: { + '@modern-js/plugin-bff': { + requiredVersion: bffVersion, + singleton: true, + treeShaking: false, + }, + '@module-federation/runtime': { + requiredVersion: dependencies['@module-federation/runtime'], + singleton: true, + treeShaking: false, + }, + effect: { + requiredVersion: effectVersion, + singleton: true, + treeShaking: false, + }, + }, +}); + +export default moduleFederationConfig; diff --git a/app/verticals/inventory/drizzle.config.ts b/app/verticals/inventory/drizzle.config.ts new file mode 100644 index 000000000..cf899ac7c --- /dev/null +++ b/app/verticals/inventory/drizzle.config.ts @@ -0,0 +1,7 @@ +import { defineWorkspaceDrizzleConfig } from '../../packages/core-runtime/src/environment/drizzle-config.ts'; + +export default defineWorkspaceDrizzleConfig({ + out: './drizzle', + schema: './src/database/schema.ts', + table: '__drizzle_migrations_inventory', +}); diff --git a/app/verticals/inventory/drizzle/20260924093258_inventory-foundation/migration.sql b/app/verticals/inventory/drizzle/20260924093258_inventory-foundation/migration.sql new file mode 100644 index 000000000..3795dbfb3 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924093258_inventory-foundation/migration.sql @@ -0,0 +1,79 @@ +CREATE SCHEMA "inventory"; +--> statement-breakpoint +CREATE TABLE "inventory"."stock_items" ( + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "exact_selection_kind" text NOT NULL, + "exact_selection_meaning_id" text NOT NULL, + "lifecycle_state" text DEFAULT 'CURRENT' NOT NULL, + "retired_at" timestamp with time zone, + "revision" integer DEFAULT 1 NOT NULL, + "stock_item_id" uuid PRIMARY KEY, + "stock_unit_module_id" text NOT NULL, + "stock_unit_resource_id" uuid NOT NULL, + "stock_unit_resource_type" text NOT NULL, + "stock_unit_tenant_id" uuid NOT NULL, + "tenant_id" uuid NOT NULL, + CONSTRAINT "inventory_stock_items_meaning_ck" CHECK (char_length(btrim("exact_selection_meaning_id")) between 1 and 300 and "exact_selection_kind" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')), + CONSTRAINT "inventory_stock_items_unit_ck" CHECK ("stock_unit_module_id" = 'commerce.catalog' and "stock_unit_resource_type" = 'commerce.catalog.product-unit' and "stock_unit_tenant_id" = "tenant_id"), + CONSTRAINT "inventory_stock_items_revision_ck" CHECK ("revision" >= 1), + CONSTRAINT "inventory_stock_items_lifecycle_ck" CHECK ("lifecycle_state" in ('CURRENT', 'RETIRED')), + CONSTRAINT "inventory_stock_items_retirement_ck" CHECK (("lifecycle_state" = 'CURRENT' and "retired_at" is null) or ("lifecycle_state" = 'RETIRED' and "retired_at" is not null)) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_items" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_location_revisions" ( + "stock_location_revision_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "stock_location_id" uuid NOT NULL, + "revision" integer NOT NULL, + "snapshot" jsonb NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_location_revisions_scope_id_uk" UNIQUE("tenant_id","stock_location_revision_id"), + CONSTRAINT "inventory_stock_location_revisions_number_uk" UNIQUE("tenant_id","stock_location_id","revision"), + CONSTRAINT "inventory_stock_location_revisions_revision_ck" CHECK ("revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_location_revisions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_locations" ( + "stock_location_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "display_name" text NOT NULL, + "scope_kind" text NOT NULL, + "physical_site_keys" jsonb NOT NULL, + "address_evidence" jsonb, + "lifecycle_state" text NOT NULL, + "successor_stock_location_id" uuid, + "transition_reason" text, + "transitioned_at" timestamp with time zone, + "current_revision" integer DEFAULT 1 NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_locations_scope_id_uk" UNIQUE("tenant_id","stock_location_id"), + CONSTRAINT "inventory_stock_locations_revision_ck" CHECK ("current_revision" >= 1), + CONSTRAINT "inventory_stock_locations_display_name_ck" CHECK ("display_name" = btrim("display_name") and length("display_name") between 1 and 300), + CONSTRAINT "inventory_stock_locations_scope_kind_ck" CHECK ("scope_kind" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')), + CONSTRAINT "inventory_stock_locations_site_keys_ck" CHECK (jsonb_typeof("physical_site_keys") = 'array' and jsonb_array_length("physical_site_keys") <= 100 and ("scope_kind" <> 'PHYSICAL_SITE' or jsonb_array_length("physical_site_keys") = 1)), + CONSTRAINT "inventory_stock_locations_lifecycle_ck" CHECK ("lifecycle_state" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')), + CONSTRAINT "inventory_stock_locations_successor_ck" CHECK ((("lifecycle_state" in ('ACTIVE', 'RETIRED')) and "successor_stock_location_id" is null) or (("lifecycle_state" in ('REPLACED', 'MERGED')) and "successor_stock_location_id" is not null and "successor_stock_location_id" <> "stock_location_id")), + CONSTRAINT "inventory_stock_locations_transition_ck" CHECK (("lifecycle_state" = 'ACTIVE' and "transition_reason" is null and "transitioned_at" is null) or ("lifecycle_state" <> 'ACTIVE' and "transition_reason" = btrim("transition_reason") and length("transition_reason") between 1 and 1000 and "transitioned_at" is not null)) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_locations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_items_scope_id_uk" ON "inventory"."stock_items" ("tenant_id","stock_item_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_items_exact_meaning_uk" ON "inventory"."stock_items" ("tenant_id","exact_selection_meaning_id");--> statement-breakpoint +CREATE INDEX "inventory_stock_items_current_idx" ON "inventory"."stock_items" ("tenant_id","lifecycle_state") WHERE "lifecycle_state" = 'CURRENT';--> statement-breakpoint +CREATE INDEX "inventory_stock_locations_lifecycle_idx" ON "inventory"."stock_locations" ("tenant_id","lifecycle_state");--> statement-breakpoint +ALTER TABLE "inventory"."stock_location_revisions" ADD CONSTRAINT "inventory_stock_location_revisions_location_fk" FOREIGN KEY ("tenant_id","stock_location_id") REFERENCES "inventory"."stock_locations"("tenant_id","stock_location_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_locations" ADD CONSTRAINT "inventory_stock_locations_successor_fk" FOREIGN KEY ("tenant_id","successor_stock_location_id") REFERENCES "inventory"."stock_locations"("tenant_id","stock_location_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_stock_items_tenant_select" ON "inventory"."stock_items" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_items"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_items_tenant_insert" ON "inventory"."stock_items" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_items"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_items_tenant_update" ON "inventory"."stock_items" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_items"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_items"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_items_tenant_delete" ON "inventory"."stock_items" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_items"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_location_revisions_tenant_select" ON "inventory"."stock_location_revisions" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_location_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_location_revisions_tenant_insert" ON "inventory"."stock_location_revisions" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_location_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_location_revisions_tenant_update" ON "inventory"."stock_location_revisions" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_location_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_location_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_location_revisions_tenant_delete" ON "inventory"."stock_location_revisions" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_location_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_locations_tenant_select" ON "inventory"."stock_locations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_locations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_locations_tenant_insert" ON "inventory"."stock_locations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_locations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_locations_tenant_update" ON "inventory"."stock_locations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_locations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_locations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_locations_tenant_delete" ON "inventory"."stock_locations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_locations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924093258_inventory-foundation/snapshot.json b/app/verticals/inventory/drizzle/20260924093258_inventory-foundation/snapshot.json new file mode 100644 index 000000000..e6b0a3642 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924093258_inventory-foundation/snapshot.json @@ -0,0 +1,900 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "04b1b7e7-de86-422e-ab9c-69156215f4a8", + "prevIds": [ + "00000000-0000-0000-0000-000000000000" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924093308_enforce-inventory-identities/migration.sql b/app/verticals/inventory/drizzle/20260924093308_enforce-inventory-identities/migration.sql new file mode 100644 index 000000000..f47e328fd --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924093308_enforce-inventory-identities/migration.sql @@ -0,0 +1,83 @@ +-- Drizzle models RLS enablement and policies, but PostgreSQL FORCE ROW LEVEL SECURITY is explicit. +ALTER TABLE "inventory"."stock_items" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_location_revisions" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_locations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +REVOKE CREATE ON SCHEMA "inventory" FROM PUBLIC; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_item_meaning_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION 'Stock Items are durable and cannot be deleted' + USING ERRCODE = '55000'; + END IF; + IF NEW.stock_item_id IS DISTINCT FROM OLD.stock_item_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.exact_selection_kind IS DISTINCT FROM OLD.exact_selection_kind + OR NEW.exact_selection_meaning_id IS DISTINCT FROM OLD.exact_selection_meaning_id + OR NEW.stock_unit_module_id IS DISTINCT FROM OLD.stock_unit_module_id + OR NEW.stock_unit_resource_id IS DISTINCT FROM OLD.stock_unit_resource_id + OR NEW.stock_unit_resource_type IS DISTINCT FROM OLD.stock_unit_resource_type + OR NEW.stock_unit_tenant_id IS DISTINCT FROM OLD.stock_unit_tenant_id + THEN + RAISE EXCEPTION 'Stock Item identity, exact Selection meaning, and exact Unit identity are immutable' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_items_immutable_meaning_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_items_immutable_meaning_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_items" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_item_meaning_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_location_identity_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION 'Stock Locations are durable and cannot be deleted' + USING ERRCODE = '55000'; + END IF; + IF NEW.stock_location_id IS DISTINCT FROM OLD.stock_location_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + THEN + RAISE EXCEPTION 'Stock Location identity and Tenant are immutable' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_locations_immutable_identity_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_locations_immutable_identity_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_locations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_location_identity_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_location_revision_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + RAISE EXCEPTION 'Stock Location revision history is append-only' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_location_revisions_append_only_ck'; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_location_revisions_append_only_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_location_revisions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_location_revision_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_item_meaning_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_location_identity_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_location_revision_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924093308_enforce-inventory-identities/snapshot.json b/app/verticals/inventory/drizzle/20260924093308_enforce-inventory-identities/snapshot.json new file mode 100644 index 000000000..7343c7e4e --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924093308_enforce-inventory-identities/snapshot.json @@ -0,0 +1,900 @@ +{ + "id": "b69487ba-beaa-4ed0-bf7c-726868e0237a", + "prevIds": [ + "04b1b7e7-de86-422e-ab9c-69156215f4a8" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924095013_lazy_micromax/migration.sql b/app/verticals/inventory/drizzle/20260924095013_lazy_micromax/migration.sql new file mode 100644 index 000000000..a7dd74698 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924095013_lazy_micromax/migration.sql @@ -0,0 +1,22 @@ +CREATE TABLE "inventory"."backend_configurations" ( + "backend_id" text NOT NULL, + "backend_kind" text NOT NULL, + "configuration_id" uuid PRIMARY KEY, + "customer_configuration_id" text NOT NULL, + "exact_reservation_capability" text NOT NULL, + "revision" integer DEFAULT 1 NOT NULL, + "selected_at" timestamp with time zone NOT NULL, + "tenant_id" uuid NOT NULL, + CONSTRAINT "inventory_backend_configurations_identity_ck" CHECK (length(btrim("backend_id")) between 1 and 300 and length(btrim("customer_configuration_id")) between 1 and 300), + CONSTRAINT "inventory_backend_configurations_backend_ck" CHECK ("backend_kind" in ('external_business_system', 'ontos_wms')), + CONSTRAINT "inventory_backend_configurations_capability_ck" CHECK ("exact_reservation_capability" in ('SUPPORTED', 'UNSUPPORTED') and ("backend_kind" <> 'ontos_wms' or "exact_reservation_capability" = 'SUPPORTED')), + CONSTRAINT "inventory_backend_configurations_revision_ck" CHECK ("revision" = 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."backend_configurations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_backend_configurations_scope_id_uk" ON "inventory"."backend_configurations" ("tenant_id","configuration_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_backend_configurations_customer_uk" ON "inventory"."backend_configurations" ("tenant_id","customer_configuration_id");--> statement-breakpoint +CREATE POLICY "inventory_backend_configurations_tenant_select" ON "inventory"."backend_configurations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."backend_configurations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_backend_configurations_tenant_insert" ON "inventory"."backend_configurations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."backend_configurations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_backend_configurations_tenant_update" ON "inventory"."backend_configurations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."backend_configurations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."backend_configurations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_backend_configurations_tenant_delete" ON "inventory"."backend_configurations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."backend_configurations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); diff --git a/app/verticals/inventory/drizzle/20260924095013_lazy_micromax/snapshot.json b/app/verticals/inventory/drizzle/20260924095013_lazy_micromax/snapshot.json new file mode 100644 index 000000000..f32e42425 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924095013_lazy_micromax/snapshot.json @@ -0,0 +1,1156 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "086258f7-ae0e-4b31-a17e-5faa7d6caa28", + "prevIds": [ + "b69487ba-beaa-4ed0-bf7c-726868e0237a" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924100926_enforce-backend-configuration-authority/migration.sql b/app/verticals/inventory/drizzle/20260924100926_enforce-backend-configuration-authority/migration.sql new file mode 100644 index 000000000..79b5ea61f --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924100926_enforce-backend-configuration-authority/migration.sql @@ -0,0 +1,23 @@ +-- Drizzle models RLS enablement and policies, but PostgreSQL FORCE ROW LEVEL SECURITY is explicit. +ALTER TABLE "inventory"."backend_configurations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_backend_configuration_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION 'Inventory Backend configurations are durable and cannot be deleted' + USING ERRCODE = '55000'; + END IF; + RAISE EXCEPTION 'Inventory Backend identity, authority, and capability require explicit cutover' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_backend_configurations_explicit_cutover_ck'; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_backend_configurations_explicit_cutover_trg" +BEFORE UPDATE OR DELETE ON "inventory"."backend_configurations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_backend_configuration_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_backend_configuration_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924100926_enforce-backend-configuration-authority/snapshot.json b/app/verticals/inventory/drizzle/20260924100926_enforce-backend-configuration-authority/snapshot.json new file mode 100644 index 000000000..d0094fbe0 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924100926_enforce-backend-configuration-authority/snapshot.json @@ -0,0 +1,1156 @@ +{ + "id": "c22124a2-999b-49d2-b935-41ab866a8008", + "prevIds": [ + "086258f7-ae0e-4b31-a17e-5faa7d6caa28" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924122636_inventory-stock-positions-and-catalog-bindings/migration.sql b/app/verticals/inventory/drizzle/20260924122636_inventory-stock-positions-and-catalog-bindings/migration.sql new file mode 100644 index 000000000..19b1b4537 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924122636_inventory-stock-positions-and-catalog-bindings/migration.sql @@ -0,0 +1,304 @@ +CREATE TABLE "inventory"."catalog_to_stock_binding_history" ( + "binding_history_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "binding_id" uuid NOT NULL, + "revision" integer NOT NULL, + "snapshot" jsonb NOT NULL, + "ended_at" timestamp with time zone NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_catalog_to_stock_binding_history_revision_ck" CHECK ("revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_binding_history" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."catalog_to_stock_bindings" ( + "binding_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "catalog_selection" jsonb NOT NULL, + "exact_selection_meaning_id" text NOT NULL, + "exact_selection_kind" text NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_unit_module_id" text NOT NULL, + "stock_unit_resource_id" uuid NOT NULL, + "stock_unit_resource_type" text NOT NULL, + "stock_unit_tenant_id" uuid NOT NULL, + "current_revision" integer DEFAULT 1 NOT NULL, + "effective_from" timestamp with time zone NOT NULL, + CONSTRAINT "inventory_catalog_to_stock_bindings_meaning_ck" CHECK (char_length(btrim("exact_selection_meaning_id")) between 1 and 300 and "exact_selection_kind" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')), + CONSTRAINT "inventory_catalog_to_stock_bindings_unit_ck" CHECK ("stock_unit_module_id" = 'commerce.catalog' and "stock_unit_resource_type" = 'commerce.catalog.product-unit' and "stock_unit_tenant_id" = "tenant_id"), + CONSTRAINT "inventory_catalog_to_stock_bindings_revision_ck" CHECK ("current_revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_bindings" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_positions" ( + "stock_position_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_location_id" uuid NOT NULL, + "stock_unit_module_id" text NOT NULL, + "stock_unit_resource_id" uuid NOT NULL, + "stock_unit_resource_type" text NOT NULL, + "stock_unit_tenant_id" uuid NOT NULL, + "lifecycle_state" text DEFAULT 'CURRENT' NOT NULL, + "on_hand_state" text NOT NULL, + "on_hand_amount" numeric(38,9), + "on_hand_evidence_ref" text, + "on_hand_observed_at" timestamp with time zone, + "owner_configuration_id" uuid NOT NULL, + "revision" integer DEFAULT 1 NOT NULL, + "ended_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_positions_customer_configuration_ck" CHECK ("customer_configuration_id" = btrim("customer_configuration_id") and length("customer_configuration_id") between 1 and 300), + CONSTRAINT "inventory_stock_positions_unit_ck" CHECK ("stock_unit_module_id" = 'commerce.catalog' and "stock_unit_resource_type" = 'commerce.catalog.product-unit' and "stock_unit_tenant_id" = "tenant_id"), + CONSTRAINT "inventory_stock_positions_lifecycle_ck" CHECK ("lifecycle_state" in ('CURRENT', 'HISTORICAL')), + CONSTRAINT "inventory_stock_positions_ended_at_ck" CHECK (("lifecycle_state" = 'CURRENT' and "ended_at" is null) or ("lifecycle_state" = 'HISTORICAL' and "ended_at" is not null)), + CONSTRAINT "inventory_stock_positions_historical_on_hand_ck" CHECK (not ("lifecycle_state" = 'HISTORICAL' and "on_hand_state" = 'CURRENT')), + CONSTRAINT "inventory_stock_positions_on_hand_state_ck" CHECK ("on_hand_state" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')), + CONSTRAINT "inventory_stock_positions_on_hand_value_ck" CHECK ((("on_hand_state" in ('CURRENT', 'STALE')) and "on_hand_amount" is not null and "on_hand_amount" >= 0 and "on_hand_evidence_ref" is not null and "on_hand_observed_at" is not null) or (("on_hand_state" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and "on_hand_amount" is null and "on_hand_evidence_ref" is null and "on_hand_observed_at" is null)), + CONSTRAINT "inventory_stock_positions_revision_ck" CHECK ("revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_positions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_catalog_to_stock_binding_history_scope_id_uk" ON "inventory"."catalog_to_stock_binding_history" ("tenant_id","binding_history_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_catalog_to_stock_binding_history_revision_uk" ON "inventory"."catalog_to_stock_binding_history" ("tenant_id","binding_id","revision");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_catalog_to_stock_bindings_scope_id_uk" ON "inventory"."catalog_to_stock_bindings" ("tenant_id","binding_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_catalog_to_stock_bindings_selection_meaning_uk" ON "inventory"."catalog_to_stock_bindings" ("tenant_id","exact_selection_meaning_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_catalog_to_stock_bindings_stock_item_uk" ON "inventory"."catalog_to_stock_bindings" ("tenant_id","stock_item_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_positions_scope_id_uk" ON "inventory"."stock_positions" ("tenant_id","stock_position_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_positions_current_scope_uk" ON "inventory"."stock_positions" ("tenant_id","customer_configuration_id","stock_item_id","stock_location_id") WHERE "lifecycle_state" = 'CURRENT';--> statement-breakpoint +CREATE INDEX "inventory_stock_positions_item_idx" ON "inventory"."stock_positions" ("tenant_id","stock_item_id");--> statement-breakpoint +CREATE INDEX "inventory_stock_positions_location_idx" ON "inventory"."stock_positions" ("tenant_id","stock_location_id");--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_binding_history" ADD CONSTRAINT "inventory_catalog_to_stock_binding_history_binding_fk" FOREIGN KEY ("tenant_id","binding_id") REFERENCES "inventory"."catalog_to_stock_bindings"("tenant_id","binding_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_bindings" ADD CONSTRAINT "inventory_catalog_to_stock_bindings_stock_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_positions" ADD CONSTRAINT "inventory_stock_positions_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_positions" ADD CONSTRAINT "inventory_stock_positions_location_fk" FOREIGN KEY ("tenant_id","stock_location_id") REFERENCES "inventory"."stock_locations"("tenant_id","stock_location_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_positions" ADD CONSTRAINT "inventory_stock_positions_backend_configuration_fk" FOREIGN KEY ("tenant_id","owner_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_binding_history_tenant_select" ON "inventory"."catalog_to_stock_binding_history" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."catalog_to_stock_binding_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_binding_history_tenant_insert" ON "inventory"."catalog_to_stock_binding_history" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."catalog_to_stock_binding_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_binding_history_tenant_update" ON "inventory"."catalog_to_stock_binding_history" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."catalog_to_stock_binding_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."catalog_to_stock_binding_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_binding_history_tenant_delete" ON "inventory"."catalog_to_stock_binding_history" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."catalog_to_stock_binding_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_bindings_tenant_select" ON "inventory"."catalog_to_stock_bindings" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."catalog_to_stock_bindings"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_bindings_tenant_insert" ON "inventory"."catalog_to_stock_bindings" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."catalog_to_stock_bindings"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_bindings_tenant_update" ON "inventory"."catalog_to_stock_bindings" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."catalog_to_stock_bindings"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."catalog_to_stock_bindings"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_catalog_to_stock_bindings_tenant_delete" ON "inventory"."catalog_to_stock_bindings" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."catalog_to_stock_bindings"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_positions_tenant_select" ON "inventory"."stock_positions" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_positions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_positions_tenant_insert" ON "inventory"."stock_positions" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_positions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_positions_tenant_update" ON "inventory"."stock_positions" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_positions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_positions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_positions_tenant_delete" ON "inventory"."stock_positions" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_positions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +-- Drizzle models policy creation but not PostgreSQL FORCE ROW LEVEL SECURITY. +ALTER TABLE "inventory"."catalog_to_stock_binding_history" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_bindings" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_positions" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_position_scope_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION 'Stock Positions are durable and cannot be deleted' + USING ERRCODE = '55000'; + END IF; + IF NEW.stock_position_id IS DISTINCT FROM OLD.stock_position_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.stock_item_id IS DISTINCT FROM OLD.stock_item_id + OR NEW.stock_location_id IS DISTINCT FROM OLD.stock_location_id + OR NEW.stock_unit_module_id IS DISTINCT FROM OLD.stock_unit_module_id + OR NEW.stock_unit_resource_id IS DISTINCT FROM OLD.stock_unit_resource_id + OR NEW.stock_unit_resource_type IS DISTINCT FROM OLD.stock_unit_resource_type + OR NEW.stock_unit_tenant_id IS DISTINCT FROM OLD.stock_unit_tenant_id + THEN + RAISE EXCEPTION 'Stock Position identity, scope, and exact Unit are immutable' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_positions_immutable_scope_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_positions_immutable_scope_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_positions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_position_scope_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_position_stock_item_unit"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."stock_items" AS stock_item + WHERE stock_item.tenant_id = NEW.tenant_id + AND stock_item.stock_item_id = NEW.stock_item_id + AND stock_item.stock_unit_module_id = NEW.stock_unit_module_id + AND stock_item.stock_unit_resource_id = NEW.stock_unit_resource_id + AND stock_item.stock_unit_resource_type = NEW.stock_unit_resource_type + AND stock_item.stock_unit_tenant_id = NEW.stock_unit_tenant_id + ) THEN + RAISE EXCEPTION 'Stock Position Unit must exactly match its Stock Item Unit' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_positions_exact_item_unit_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_positions_exact_item_unit_trg" +BEFORE INSERT OR UPDATE ON "inventory"."stock_positions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_position_stock_item_unit"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_position_owner_configuration"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."backend_configurations" AS backend_configuration + WHERE backend_configuration.tenant_id = NEW.tenant_id + AND backend_configuration.configuration_id = NEW.owner_configuration_id + AND backend_configuration.customer_configuration_id = NEW.customer_configuration_id + ) THEN + RAISE EXCEPTION 'Stock Position ON_HAND owner must be the selected Customer Configuration Inventory Backend' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_positions_owner_configuration_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_positions_owner_configuration_trg" +BEFORE INSERT OR UPDATE ON "inventory"."stock_positions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_position_owner_configuration"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_catalog_to_stock_binding_history_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + RAISE EXCEPTION 'Catalog-to-Stock Binding history is append-only' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_catalog_to_stock_binding_history_append_only_ck'; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_catalog_to_stock_binding_history_no_update_trg" +BEFORE UPDATE ON "inventory"."catalog_to_stock_binding_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_catalog_to_stock_binding_history_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_catalog_to_stock_binding_history_no_delete_trg" +BEFORE DELETE ON "inventory"."catalog_to_stock_binding_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_catalog_to_stock_binding_history_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_catalog_to_stock_binding_compatibility"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +DECLARE + target_lifecycle_state text; + target_exact_selection_meaning_id text; + target_exact_selection_kind text; + target_stock_unit_module_id text; + target_stock_unit_resource_id uuid; + target_stock_unit_resource_type text; + target_stock_unit_tenant_id uuid; +BEGIN + SELECT + stock_item.lifecycle_state, + stock_item.exact_selection_meaning_id, + stock_item.exact_selection_kind, + stock_item.stock_unit_module_id, + stock_item.stock_unit_resource_id, + stock_item.stock_unit_resource_type, + stock_item.stock_unit_tenant_id + INTO + target_lifecycle_state, + target_exact_selection_meaning_id, + target_exact_selection_kind, + target_stock_unit_module_id, + target_stock_unit_resource_id, + target_stock_unit_resource_type, + target_stock_unit_tenant_id + FROM "inventory"."stock_items" AS stock_item + WHERE stock_item.tenant_id = NEW.tenant_id + AND stock_item.stock_item_id = NEW.stock_item_id + FOR UPDATE; + + IF NOT FOUND THEN + RAISE EXCEPTION 'Catalog-to-Stock Binding target Stock Item does not exist in the Tenant' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_catalog_to_stock_bindings_target_missing_ck'; + END IF; + IF target_lifecycle_state IS DISTINCT FROM 'CURRENT' THEN + RAISE EXCEPTION 'Catalog-to-Stock Binding target Stock Item must be Current' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_catalog_to_stock_bindings_target_current_ck'; + END IF; + IF target_exact_selection_meaning_id IS DISTINCT FROM NEW.exact_selection_meaning_id + OR target_exact_selection_kind IS DISTINCT FROM NEW.exact_selection_kind + THEN + RAISE EXCEPTION 'Catalog-to-Stock Binding meaning must exactly match its Stock Item' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_catalog_to_stock_bindings_target_meaning_ck'; + END IF; + IF target_stock_unit_module_id IS DISTINCT FROM NEW.stock_unit_module_id + OR target_stock_unit_resource_id IS DISTINCT FROM NEW.stock_unit_resource_id + OR target_stock_unit_resource_type IS DISTINCT FROM NEW.stock_unit_resource_type + OR target_stock_unit_tenant_id IS DISTINCT FROM NEW.stock_unit_tenant_id + THEN + RAISE EXCEPTION 'Catalog-to-Stock Binding Unit must exactly match its Stock Item' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_catalog_to_stock_bindings_target_unit_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_catalog_to_stock_bindings_compatibility_trg" +BEFORE INSERT OR UPDATE ON "inventory"."catalog_to_stock_bindings" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_catalog_to_stock_binding_compatibility"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."protect_current_catalog_to_stock_binding_target"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF (NEW.lifecycle_state IS DISTINCT FROM OLD.lifecycle_state + OR NEW.exact_selection_meaning_id IS DISTINCT FROM OLD.exact_selection_meaning_id + OR NEW.exact_selection_kind IS DISTINCT FROM OLD.exact_selection_kind + OR NEW.stock_unit_module_id IS DISTINCT FROM OLD.stock_unit_module_id + OR NEW.stock_unit_resource_id IS DISTINCT FROM OLD.stock_unit_resource_id + OR NEW.stock_unit_resource_type IS DISTINCT FROM OLD.stock_unit_resource_type + OR NEW.stock_unit_tenant_id IS DISTINCT FROM OLD.stock_unit_tenant_id) + AND EXISTS ( + SELECT 1 + FROM "inventory"."catalog_to_stock_bindings" AS binding + WHERE binding.tenant_id = OLD.tenant_id + AND binding.stock_item_id = OLD.stock_item_id + ) + THEN + RAISE EXCEPTION 'A Current Catalog-to-Stock Binding target cannot retire or change meaning or Unit' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_stock_items_current_binding_target_ck'; + END IF; + RETURN NEW; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_items_current_binding_target_trg" +BEFORE UPDATE ON "inventory"."stock_items" +FOR EACH ROW EXECUTE FUNCTION "inventory"."protect_current_catalog_to_stock_binding_target"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_position_scope_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_position_stock_item_unit"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_position_owner_configuration"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_catalog_to_stock_binding_history_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_catalog_to_stock_binding_compatibility"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."protect_current_catalog_to_stock_binding_target"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924122636_inventory-stock-positions-and-catalog-bindings/snapshot.json b/app/verticals/inventory/drizzle/20260924122636_inventory-stock-positions-and-catalog-bindings/snapshot.json new file mode 100644 index 000000000..ab259ec58 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924122636_inventory-stock-positions-and-catalog-bindings/snapshot.json @@ -0,0 +1,2306 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "ea14141f-15fa-4289-b6f8-21c0bc346f7d", + "prevIds": [ + "c22124a2-999b-49d2-b935-41ab866a8008" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "binding_id" + ], + "schemaTo": "inventory", + "tableTo": "catalog_to_stock_bindings", + "columnsTo": [ + "tenant_id", + "binding_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_binding_history_binding_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924123331_external-stock-correlations/migration.sql b/app/verticals/inventory/drizzle/20260924123331_external-stock-correlations/migration.sql new file mode 100644 index 000000000..66fcadb1d --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924123331_external-stock-correlations/migration.sql @@ -0,0 +1,137 @@ +CREATE TABLE "inventory"."external_stock_correlations" ( + "correlation_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "namespace" text NOT NULL, + "external_scope" text NOT NULL, + "identifier_kind" text NOT NULL, + "external_value" text NOT NULL, + "stock_item_id" uuid, + "stock_location_id" uuid, + "lifecycle_state" text DEFAULT 'CURRENT' NOT NULL, + "effective_from" timestamp with time zone NOT NULL, + "effective_to" timestamp with time zone, + "owner_evidence_ref" text NOT NULL, + "confirmed_at" timestamp with time zone NOT NULL, + "revision" integer DEFAULT 1 NOT NULL, + CONSTRAINT "inventory_external_stock_correlations_key_ck" CHECK (length(btrim("customer_configuration_id")) between 1 and 300 and "issuer_backend_kind" in ('external_business_system', 'ontos_wms') and length(btrim("issuer_backend_id")) between 1 and 300 and length(btrim("namespace")) between 1 and 300 and length(btrim("external_scope")) between 1 and 300 and "identifier_kind" in ('ITEM', 'LOCATION') and length(btrim("external_value")) between 1 and 300), + CONSTRAINT "inventory_external_stock_correlations_target_ck" CHECK (("identifier_kind" = 'ITEM' and "stock_item_id" is not null and "stock_location_id" is null) or ("identifier_kind" = 'LOCATION' and "stock_item_id" is null and "stock_location_id" is not null)), + CONSTRAINT "inventory_external_stock_correlations_lifecycle_ck" CHECK (("lifecycle_state" = 'CURRENT' and "effective_to" is null) or ("lifecycle_state" = 'ENDED' and "effective_to" is not null and "effective_from" < "effective_to")), + CONSTRAINT "inventory_external_stock_correlations_evidence_ck" CHECK (length(btrim("owner_evidence_ref")) between 1 and 300), + CONSTRAINT "inventory_external_stock_correlations_revision_ck" CHECK ("revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."external_stock_correlations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_external_stock_correlations_scope_id_uk" ON "inventory"."external_stock_correlations" ("tenant_id","correlation_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_external_stock_correlations_current_key_uk" ON "inventory"."external_stock_correlations" ("tenant_id","customer_configuration_id","issuer_backend_kind","issuer_backend_id","namespace","external_scope","identifier_kind","external_value") WHERE "lifecycle_state" = 'CURRENT' and "effective_to" is null;--> statement-breakpoint +CREATE INDEX "inventory_external_stock_correlations_item_idx" ON "inventory"."external_stock_correlations" ("tenant_id","stock_item_id");--> statement-breakpoint +CREATE INDEX "inventory_external_stock_correlations_location_idx" ON "inventory"."external_stock_correlations" ("tenant_id","stock_location_id");--> statement-breakpoint +ALTER TABLE "inventory"."external_stock_correlations" ADD CONSTRAINT "inventory_external_stock_correlations_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."external_stock_correlations" ADD CONSTRAINT "inventory_external_stock_correlations_location_fk" FOREIGN KEY ("tenant_id","stock_location_id") REFERENCES "inventory"."stock_locations"("tenant_id","stock_location_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_external_stock_correlations_tenant_select" ON "inventory"."external_stock_correlations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."external_stock_correlations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_external_stock_correlations_tenant_insert" ON "inventory"."external_stock_correlations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."external_stock_correlations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_external_stock_correlations_tenant_update" ON "inventory"."external_stock_correlations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."external_stock_correlations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."external_stock_correlations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_external_stock_correlations_tenant_delete" ON "inventory"."external_stock_correlations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."external_stock_correlations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."external_stock_correlations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_external_stock_correlation_identity_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_external_stock_correlations_no_delete_ck', + MESSAGE = 'Inventory External Stock Correlations are durable history and cannot be deleted'; + END IF; + + IF NEW.correlation_id IS DISTINCT FROM OLD.correlation_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.issuer_backend_kind IS DISTINCT FROM OLD.issuer_backend_kind + OR NEW.issuer_backend_id IS DISTINCT FROM OLD.issuer_backend_id + OR NEW.namespace IS DISTINCT FROM OLD.namespace + OR NEW.external_scope IS DISTINCT FROM OLD.external_scope + OR NEW.identifier_kind IS DISTINCT FROM OLD.identifier_kind + OR NEW.external_value IS DISTINCT FROM OLD.external_value + OR NEW.stock_item_id IS DISTINCT FROM OLD.stock_item_id + OR NEW.stock_location_id IS DISTINCT FROM OLD.stock_location_id + OR NEW.effective_from IS DISTINCT FROM OLD.effective_from + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_external_stock_correlations_immutable_identity_ck', + MESSAGE = 'Inventory External Stock Correlation identity and effective-from evidence are immutable'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_external_stock_correlations_immutable_identity_trg" +BEFORE UPDATE ON "inventory"."external_stock_correlations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_external_stock_correlation_identity_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_external_stock_correlations_no_delete_trg" +BEFORE DELETE ON "inventory"."external_stock_correlations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_external_stock_correlation_identity_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_external_stock_correlation_nonoverlap"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended( + pg_catalog.concat_ws( + E'\x1f', + NEW.tenant_id::text, + NEW.customer_configuration_id, + NEW.issuer_backend_kind, + NEW.issuer_backend_id, + NEW.namespace, + NEW.external_scope, + NEW.identifier_kind, + NEW.external_value + ), + 0 + ) + ); + + IF EXISTS ( + SELECT 1 + FROM "inventory"."external_stock_correlations" AS existing + WHERE existing.tenant_id = NEW.tenant_id + AND existing.customer_configuration_id = NEW.customer_configuration_id + AND existing.issuer_backend_kind = NEW.issuer_backend_kind + AND existing.issuer_backend_id = NEW.issuer_backend_id + AND existing.namespace = NEW.namespace + AND existing.external_scope = NEW.external_scope + AND existing.identifier_kind = NEW.identifier_kind + AND existing.external_value = NEW.external_value + AND existing.correlation_id <> NEW.correlation_id + AND pg_catalog.tstzrange(existing.effective_from, existing.effective_to, '[)') + && pg_catalog.tstzrange(NEW.effective_from, NEW.effective_to, '[)') + FOR UPDATE + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23P01', + CONSTRAINT = 'inventory_external_stock_correlations_effective_period_excl', + MESSAGE = 'Inventory External Stock Correlation Effective Periods cannot overlap for one exact external key'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_external_stock_correlations_nonoverlap_trg" +BEFORE INSERT OR UPDATE ON "inventory"."external_stock_correlations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_external_stock_correlation_nonoverlap"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_external_stock_correlation_identity_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_external_stock_correlation_nonoverlap"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924123331_external-stock-correlations/snapshot.json b/app/verticals/inventory/drizzle/20260924123331_external-stock-correlations/snapshot.json new file mode 100644 index 000000000..329ab0b73 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924123331_external-stock-correlations/snapshot.json @@ -0,0 +1,2822 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "840cbff4-dfb7-4480-b4be-781cc424be42", + "prevIds": [ + "ea14141f-15fa-4289-b6f8-21c0bc346f7d" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "binding_id" + ], + "schemaTo": "inventory", + "tableTo": "catalog_to_stock_bindings", + "columnsTo": [ + "tenant_id", + "binding_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_binding_history_binding_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924125055_stock-sharing-eligibility/migration.sql b/app/verticals/inventory/drizzle/20260924125055_stock-sharing-eligibility/migration.sql new file mode 100644 index 000000000..e3f0c3437 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924125055_stock-sharing-eligibility/migration.sql @@ -0,0 +1,156 @@ +CREATE TABLE "inventory"."stock_sharing_eligibilities" ( + "eligibility_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "owner_configuration_id" uuid NOT NULL, + "stock_position_id" uuid NOT NULL, + "selling_legal_entity_id" uuid NOT NULL, + "channel" text NOT NULL, + "commerce_market_id" text, + "storefront_app_id" text, + "commerce_validation_evidence_ref" text NOT NULL, + "commerce_validation_observed_at" timestamp with time zone NOT NULL, + "lifecycle_state" text DEFAULT 'CURRENT' NOT NULL, + "effective_from" timestamp with time zone NOT NULL, + "effective_to" timestamp with time zone, + "current_revision" integer DEFAULT 1 NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_sharing_eligibilities_subject_ck" CHECK ("channel" in ('B2C', 'B2B') and char_length(btrim("commerce_validation_evidence_ref")) between 1 and 300 and ("commerce_market_id" is null or char_length(btrim("commerce_market_id")) between 1 and 300) and ("storefront_app_id" is null or "storefront_app_id" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')), + CONSTRAINT "inventory_stock_sharing_eligibilities_lifecycle_ck" CHECK (("lifecycle_state" = 'CURRENT' and "effective_to" is null) or ("lifecycle_state" = 'ENDED' and "effective_to" is not null and "effective_from" < "effective_to")), + CONSTRAINT "inventory_stock_sharing_eligibilities_revision_ck" CHECK ("current_revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibilities" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_sharing_eligibility_history" ( + "history_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "eligibility_id" uuid NOT NULL, + "revision" integer NOT NULL, + "snapshot" jsonb NOT NULL, + "transition_at" timestamp with time zone NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_sharing_eligibility_history_revision_ck" CHECK ("revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibility_history" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_sharing_eligibilities_scope_id_uk" ON "inventory"."stock_sharing_eligibilities" ("tenant_id","eligibility_id");--> statement-breakpoint +CREATE INDEX "inventory_stock_sharing_eligibilities_current_position_idx" ON "inventory"."stock_sharing_eligibilities" ("tenant_id","customer_configuration_id","owner_configuration_id","stock_position_id") WHERE "lifecycle_state" = 'CURRENT' and "effective_to" is null;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_sharing_eligibility_history_scope_id_uk" ON "inventory"."stock_sharing_eligibility_history" ("tenant_id","history_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_sharing_eligibility_history_revision_uk" ON "inventory"."stock_sharing_eligibility_history" ("tenant_id","eligibility_id","revision");--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibilities" ADD CONSTRAINT "inventory_stock_sharing_eligibilities_backend_configuration_fk" FOREIGN KEY ("tenant_id","owner_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibilities" ADD CONSTRAINT "inventory_stock_sharing_eligibilities_position_fk" FOREIGN KEY ("tenant_id","stock_position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibility_history" ADD CONSTRAINT "inventory_stock_sharing_eligibility_history_eligibility_fk" FOREIGN KEY ("tenant_id","eligibility_id") REFERENCES "inventory"."stock_sharing_eligibilities"("tenant_id","eligibility_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibilities_tenant_select" ON "inventory"."stock_sharing_eligibilities" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_sharing_eligibilities"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibilities_tenant_insert" ON "inventory"."stock_sharing_eligibilities" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_sharing_eligibilities"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibilities_tenant_update" ON "inventory"."stock_sharing_eligibilities" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_sharing_eligibilities"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_sharing_eligibilities"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibilities_tenant_delete" ON "inventory"."stock_sharing_eligibilities" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_sharing_eligibilities"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibility_history_tenant_select" ON "inventory"."stock_sharing_eligibility_history" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_sharing_eligibility_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibility_history_tenant_insert" ON "inventory"."stock_sharing_eligibility_history" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_sharing_eligibility_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibility_history_tenant_update" ON "inventory"."stock_sharing_eligibility_history" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_sharing_eligibility_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_sharing_eligibility_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_sharing_eligibility_history_tenant_delete" ON "inventory"."stock_sharing_eligibility_history" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_sharing_eligibility_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibilities" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_sharing_eligibility_history" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_sharing_eligibility_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.stock_position_id + AND position.customer_configuration_id = NEW.customer_configuration_id + AND position.owner_configuration_id = NEW.owner_configuration_id + AND position.lifecycle_state = 'CURRENT' + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_sharing_eligibilities_position_scope_ck', + MESSAGE = 'Stock Sharing Eligibility requires the exact Current Stock Position scope'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS backend + WHERE backend.tenant_id = NEW.tenant_id + AND backend.configuration_id = NEW.owner_configuration_id + AND backend.customer_configuration_id = NEW.customer_configuration_id + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_sharing_eligibilities_backend_scope_ck', + MESSAGE = 'Stock Sharing Eligibility requires the selected backend for its Customer Configuration'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_sharing_eligibilities_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."stock_sharing_eligibilities" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_sharing_eligibility_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_sharing_eligibility_identity_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_sharing_eligibilities_no_delete_ck', + MESSAGE = 'Stock Sharing Eligibilities are durable and cannot be deleted'; + END IF; + + IF NEW.eligibility_id IS DISTINCT FROM OLD.eligibility_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.stock_position_id IS DISTINCT FROM OLD.stock_position_id + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_sharing_eligibilities_immutable_identity_ck', + MESSAGE = 'Stock Sharing Eligibility identity is immutable'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_sharing_eligibilities_immutable_identity_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_sharing_eligibilities" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_sharing_eligibility_identity_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_sharing_eligibility_history_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_sharing_eligibility_history_append_only_ck', + MESSAGE = 'Stock Sharing Eligibility history is append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_sharing_eligibility_history_no_update_trg" +BEFORE UPDATE ON "inventory"."stock_sharing_eligibility_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_sharing_eligibility_history_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_sharing_eligibility_history_no_delete_trg" +BEFORE DELETE ON "inventory"."stock_sharing_eligibility_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_sharing_eligibility_history_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_sharing_eligibility_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_sharing_eligibility_identity_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_sharing_eligibility_history_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924125055_stock-sharing-eligibility/snapshot.json b/app/verticals/inventory/drizzle/20260924125055_stock-sharing-eligibility/snapshot.json new file mode 100644 index 000000000..d6c5392c4 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924125055_stock-sharing-eligibility/snapshot.json @@ -0,0 +1,3488 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "056ba27a-c1b6-4c7c-af22-cd9df35a0ddb", + "prevIds": [ + "840cbff4-dfb7-4480-b4be-781cc424be42" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "binding_id" + ], + "schemaTo": "inventory", + "tableTo": "catalog_to_stock_bindings", + "columnsTo": [ + "tenant_id", + "binding_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_binding_history_binding_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924130230_physical-stock-effects/migration.sql b/app/verticals/inventory/drizzle/20260924130230_physical-stock-effects/migration.sql new file mode 100644 index 000000000..c1e7b64d2 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924130230_physical-stock-effects/migration.sql @@ -0,0 +1,325 @@ +CREATE TABLE "inventory"."physical_stock_effects" ( + "effect_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "kind" text NOT NULL, + "customer_configuration_id" text NOT NULL, + "legal_entity_id" uuid NOT NULL, + "position_id" uuid NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_location_id" uuid NOT NULL, + "unit_resource_id" uuid NOT NULL, + "quantity_amount" text NOT NULL, + "backend_configuration_id" uuid NOT NULL, + "backend_id" text NOT NULL, + "state" text DEFAULT 'REQUESTED' NOT NULL, + "request_json" jsonb NOT NULL, + "evidence_json" jsonb, + "terminal_reason" text, + "requested_at" timestamp with time zone NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_physical_stock_effects_kind_ck" CHECK ("kind" in ('RECEIPT', 'ISSUE')), + CONSTRAINT "inventory_physical_stock_effects_state_ck" CHECK ("state" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')), + CONSTRAINT "inventory_physical_stock_effects_terminal_ck" CHECK (("state" = 'REQUESTED' and "evidence_json" is null and "terminal_reason" is null) or ("state" = 'APPLIED' and "evidence_json" is not null and "terminal_reason" is null) or ("state" in ('REJECTED', 'INDETERMINATE') and "evidence_json" is null and "terminal_reason" is not null)) +); +--> statement-breakpoint +ALTER TABLE "inventory"."physical_stock_effects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_physical_stock_effects_tenant_id_uk" ON "inventory"."physical_stock_effects" ("tenant_id","effect_id");--> statement-breakpoint +CREATE INDEX "inventory_physical_stock_effects_position_idx" ON "inventory"."physical_stock_effects" ("tenant_id","position_id","requested_at");--> statement-breakpoint +ALTER TABLE "inventory"."physical_stock_effects" ADD CONSTRAINT "inventory_physical_stock_effects_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."physical_stock_effects" ADD CONSTRAINT "inventory_physical_stock_effects_backend_configuration_fk" FOREIGN KEY ("tenant_id","backend_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_physical_stock_effects_tenant_select" ON "inventory"."physical_stock_effects" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."physical_stock_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_physical_stock_effects_tenant_insert" ON "inventory"."physical_stock_effects" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."physical_stock_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_physical_stock_effects_tenant_update" ON "inventory"."physical_stock_effects" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."physical_stock_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."physical_stock_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_physical_stock_effects_tenant_delete" ON "inventory"."physical_stock_effects" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."physical_stock_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."physical_stock_effects" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_physical_stock_effect_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.position_id + AND position.customer_configuration_id = NEW.customer_configuration_id + AND position.stock_item_id = NEW.stock_item_id + AND position.stock_location_id = NEW.stock_location_id + AND position.stock_unit_resource_id = NEW.unit_resource_id + AND position.owner_configuration_id = NEW.backend_configuration_id + AND position.lifecycle_state = 'CURRENT' + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_exact_scope_ck', + MESSAGE = 'Physical Stock Effect requires its exact Current Stock Position scope'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS backend + WHERE backend.tenant_id = NEW.tenant_id + AND backend.configuration_id = NEW.backend_configuration_id + AND backend.customer_configuration_id = NEW.customer_configuration_id + AND backend.backend_id = NEW.backend_id + AND backend.backend_kind = NEW.request_json ->> 'backend' + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_exact_scope_ck', + MESSAGE = 'Physical Stock Effect requires its captured selected Inventory Backend'; + END IF; + + IF pg_catalog.jsonb_typeof(NEW.request_json) IS DISTINCT FROM 'object' + OR NEW.request_json ->> 'effectId' IS DISTINCT FROM NEW.effect_id::text + OR NEW.request_json ->> 'kind' IS DISTINCT FROM NEW.kind + OR NEW.request_json ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.request_json ->> 'legalEntityId' IS DISTINCT FROM NEW.legal_entity_id::text + OR NEW.request_json #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.request_json #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.request_json #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR NEW.request_json #>> '{stockItemRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.request_json #>> '{stockItemRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-item' + OR NEW.request_json #>> '{stockItemRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{stockItemRef,resourceId}' IS DISTINCT FROM NEW.stock_item_id::text + OR NEW.request_json #>> '{stockLocationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.request_json #>> '{stockLocationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-location' + OR NEW.request_json #>> '{stockLocationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{stockLocationRef,resourceId}' IS DISTINCT FROM NEW.stock_location_id::text + OR NEW.request_json #>> '{quantity,unitRef,moduleId}' IS DISTINCT FROM 'commerce.catalog' + OR NEW.request_json #>> '{quantity,unitRef,resourceType}' IS DISTINCT FROM 'commerce.catalog.product-unit' + OR NEW.request_json #>> '{quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{quantity,unitRef,resourceId}' IS DISTINCT FROM NEW.unit_resource_id::text + OR NEW.request_json #>> '{quantity,amount}' IS DISTINCT FROM NEW.quantity_amount + OR NEW.request_json #>> '{backendConfigurationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.request_json #>> '{backendConfigurationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.inventory-backend-configuration' + OR NEW.request_json #>> '{backendConfigurationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{backendConfigurationRef,resourceId}' IS DISTINCT FROM NEW.backend_configuration_id::text + OR NEW.request_json ->> 'backendId' IS DISTINCT FROM NEW.backend_id + OR (NEW.request_json ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_exact_scope_ck', + MESSAGE = 'Physical Stock Effect request JSON must exactly match its captured owner scope'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_physical_stock_effects_exact_scope_trg" +BEFORE INSERT ON "inventory"."physical_stock_effects" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_physical_stock_effect_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_physical_stock_effect_identity_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' + OR NEW.effect_id IS DISTINCT FROM OLD.effect_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.kind IS DISTINCT FROM OLD.kind + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.legal_entity_id IS DISTINCT FROM OLD.legal_entity_id + OR NEW.position_id IS DISTINCT FROM OLD.position_id + OR NEW.stock_item_id IS DISTINCT FROM OLD.stock_item_id + OR NEW.stock_location_id IS DISTINCT FROM OLD.stock_location_id + OR NEW.unit_resource_id IS DISTINCT FROM OLD.unit_resource_id + OR NEW.quantity_amount IS DISTINCT FROM OLD.quantity_amount + OR NEW.backend_configuration_id IS DISTINCT FROM OLD.backend_configuration_id + OR NEW.backend_id IS DISTINCT FROM OLD.backend_id + OR NEW.request_json IS DISTINCT FROM OLD.request_json + OR NEW.requested_at IS DISTINCT FROM OLD.requested_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_immutable_identity_ck', + MESSAGE = 'Physical Stock Effect identity and request evidence are immutable'; + END IF; + + IF OLD.state <> 'REQUESTED' + AND ( + NEW.state IS DISTINCT FROM OLD.state + OR NEW.evidence_json IS DISTINCT FROM OLD.evidence_json + OR NEW.terminal_reason IS DISTINCT FROM OLD.terminal_reason + OR NEW.updated_at IS DISTINCT FROM OLD.updated_at + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_terminal_transition_ck', + MESSAGE = 'Physical Stock Effect terminal outcomes are immutable'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_physical_stock_effects_immutable_identity_trg" +BEFORE UPDATE OR DELETE ON "inventory"."physical_stock_effects" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_physical_stock_effect_identity_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."read_physical_stock_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id uuid +) RETURNS TABLE(record jsonb) +LANGUAGE sql +STABLE +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ + SELECT CASE effect.state + WHEN 'REQUESTED' THEN pg_catalog.jsonb_build_object('_tag', effect.state, 'request', effect.request_json) + WHEN 'APPLIED' THEN pg_catalog.jsonb_build_object( + '_tag', effect.state, + 'evidence', effect.evidence_json, + 'request', effect.request_json + ) + ELSE pg_catalog.jsonb_build_object( + '_tag', effect.state, + 'reason', effect.terminal_reason, + 'request', effect.request_json + ) + END + FROM "inventory"."physical_stock_effects" AS effect + WHERE p_tenant_id = nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + AND p_legal_entity_id = nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + AND effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."finalize_physical_stock_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id uuid, + p_terminal jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + current_effect "inventory"."physical_stock_effects"%ROWTYPE; + terminal_tag text; + canonical_record jsonb; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Physical Stock Effect worker scope mismatch'; + END IF; + + SELECT effect.* INTO current_effect + FROM "inventory"."physical_stock_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + terminal_tag := p_terminal ->> '_tag'; + IF pg_catalog.jsonb_typeof(p_terminal) IS DISTINCT FROM 'object' + OR terminal_tag NOT IN ('APPLIED', 'REJECTED', 'INDETERMINATE') + OR p_terminal -> 'request' IS DISTINCT FROM current_effect.request_json + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 3 + OR ( + terminal_tag = 'APPLIED' + AND ( + pg_catalog.jsonb_typeof(p_terminal -> 'evidence') IS DISTINCT FROM 'object' + OR p_terminal #>> '{evidence,effectId}' IS DISTINCT FROM current_effect.effect_id::text + OR p_terminal #>> '{evidence,kind}' IS DISTINCT FROM current_effect.kind + OR p_terminal #>> '{evidence,backend}' IS DISTINCT FROM current_effect.request_json ->> 'backend' + OR p_terminal #>> '{evidence,backendId}' IS DISTINCT FROM current_effect.backend_id + OR p_terminal #>> '{evidence,backendConfigurationRef,resourceId}' IS DISTINCT FROM current_effect.backend_configuration_id::text + OR p_terminal #>> '{evidence,backendConfigurationRef,tenantId}' IS DISTINCT FROM current_effect.tenant_id::text + OR p_terminal #>> '{evidence,positionRef,resourceId}' IS DISTINCT FROM current_effect.position_id::text + OR p_terminal #>> '{evidence,positionRef,tenantId}' IS DISTINCT FROM current_effect.tenant_id::text + OR p_terminal #>> '{evidence,quantity,amount}' IS DISTINCT FROM current_effect.quantity_amount + OR p_terminal #>> '{evidence,quantity,unitRef,resourceId}' IS DISTINCT FROM current_effect.unit_resource_id::text + OR p_terminal #>> '{evidence,quantity,unitRef,tenantId}' IS DISTINCT FROM current_effect.tenant_id::text + OR coalesce(length(btrim(p_terminal #>> '{evidence,backendEvidenceRef}')), 0) NOT BETWEEN 1 AND 300 + OR coalesce(length(btrim(p_terminal #>> '{evidence,issuer}')), 0) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + terminal_tag = 'REJECTED' + AND ( + pg_catalog.jsonb_typeof(p_terminal -> 'reason') IS DISTINCT FROM 'string' + OR p_terminal ->> 'reason' NOT IN ('INSUFFICIENT_ON_HAND', 'POSITION_REJECTED', 'BACKEND_REJECTED') + ) + ) + OR ( + terminal_tag = 'INDETERMINATE' + AND ( + pg_catalog.jsonb_typeof(p_terminal -> 'reason') IS DISTINCT FROM 'string' + OR p_terminal ->> 'reason' NOT IN ('BACKEND_OUTCOME_UNKNOWN', 'EVIDENCE_UNVERIFIABLE') + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_terminal_payload_ck', + MESSAGE = 'Physical Stock Effect terminal payload must exactly match its durable request'; + END IF; + + canonical_record := CASE current_effect.state + WHEN 'REQUESTED' THEN NULL + WHEN 'APPLIED' THEN pg_catalog.jsonb_build_object( + '_tag', current_effect.state, + 'evidence', current_effect.evidence_json, + 'request', current_effect.request_json + ) + ELSE pg_catalog.jsonb_build_object( + '_tag', current_effect.state, + 'reason', current_effect.terminal_reason, + 'request', current_effect.request_json + ) + END; + + IF canonical_record IS NOT NULL THEN + IF canonical_record IS DISTINCT FROM p_terminal THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_physical_stock_effects_terminal_transition_ck', + MESSAGE = 'Physical Stock Effect terminal outcome cannot be replaced'; + END IF; + RETURN QUERY SELECT canonical_record; + RETURN; + END IF; + + UPDATE "inventory"."physical_stock_effects" AS effect + SET state = terminal_tag, + evidence_json = CASE WHEN terminal_tag = 'APPLIED' THEN p_terminal -> 'evidence' ELSE NULL END, + terminal_reason = CASE WHEN terminal_tag = 'APPLIED' THEN NULL ELSE p_terminal ->> 'reason' END, + updated_at = pg_catalog.clock_timestamp() + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id; + + RETURN QUERY SELECT p_terminal; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_physical_stock_effect_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_physical_stock_effect_identity_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."read_physical_stock_effect_for_worker"(uuid, uuid, uuid) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."finalize_physical_stock_effect_for_worker"(uuid, uuid, uuid, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."read_physical_stock_effect_for_worker"(uuid, uuid, uuid) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."finalize_physical_stock_effect_for_worker"(uuid, uuid, uuid, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924130230_physical-stock-effects/snapshot.json b/app/verticals/inventory/drizzle/20260924130230_physical-stock-effects/snapshot.json new file mode 100644 index 000000000..dc087e304 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924130230_physical-stock-effects/snapshot.json @@ -0,0 +1,3912 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "eb152f89-0e06-4056-97b5-47ab19e20180", + "prevIds": [ + "056ba27a-c1b6-4c7c-af22-cd9df35a0ddb" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "binding_id" + ], + "schemaTo": "inventory", + "tableTo": "catalog_to_stock_bindings", + "columnsTo": [ + "tenant_id", + "binding_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_binding_history_binding_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924131153_catalog-binding-history-lifecycle/migration.sql b/app/verticals/inventory/drizzle/20260924131153_catalog-binding-history-lifecycle/migration.sql new file mode 100644 index 000000000..003a5c37d --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924131153_catalog-binding-history-lifecycle/migration.sql @@ -0,0 +1,4 @@ +ALTER TABLE "inventory"."catalog_to_stock_binding_history" DROP CONSTRAINT "inventory_catalog_to_stock_binding_history_binding_fk";--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_binding_history" ADD COLUMN "transition" text NOT NULL;--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_binding_history" ADD COLUMN "owner_evidence_ref" text NOT NULL;--> statement-breakpoint +ALTER TABLE "inventory"."catalog_to_stock_binding_history" ADD CONSTRAINT "inventory_catalog_to_stock_binding_history_transition_ck" CHECK ("transition" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim("owner_evidence_ref")) between 1 and 300); \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924131153_catalog-binding-history-lifecycle/snapshot.json b/app/verticals/inventory/drizzle/20260924131153_catalog-binding-history-lifecycle/snapshot.json new file mode 100644 index 000000000..fb636f06b --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924131153_catalog-binding-history-lifecycle/snapshot.json @@ -0,0 +1,3926 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "9d2817b3-549d-4a58-bb02-e58a56e50f9f", + "prevIds": [ + "eb152f89-0e06-4056-97b5-47ab19e20180" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924133041_inventory-source-assertions/migration.sql b/app/verticals/inventory/drizzle/20260924133041_inventory-source-assertions/migration.sql new file mode 100644 index 000000000..589861cf4 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924133041_inventory-source-assertions/migration.sql @@ -0,0 +1,379 @@ +CREATE TABLE "inventory"."source_assertion_coverage" ( + "tenant_id" uuid, + "assertion_id" uuid, + "effect_id" uuid, + "relation" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_source_assertion_coverage_pk" PRIMARY KEY("tenant_id","assertion_id","effect_id"), + CONSTRAINT "inventory_source_assertion_coverage_relation_ck" CHECK ("relation" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')), + CONSTRAINT "inventory_source_assertion_coverage_evidence_ck" CHECK (length(btrim("owner_evidence_ref")) between 1 and 300) +); +--> statement-breakpoint +ALTER TABLE "inventory"."source_assertion_coverage" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."source_assertions" ( + "assertion_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "authority_configuration_id" uuid NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "issuer_authority" text NOT NULL, + "item_correlation_id" uuid NOT NULL, + "location_correlation_id" uuid NOT NULL, + "position_id" uuid NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_location_id" uuid NOT NULL, + "unit_module_id" text NOT NULL, + "unit_resource_id" uuid NOT NULL, + "unit_resource_type" text NOT NULL, + "unit_tenant_id" uuid NOT NULL, + "quantity_amount" text NOT NULL, + "fact_meaning" text NOT NULL, + "business_observed_at" timestamp with time zone NOT NULL, + "ordering_evidence_kind" text NOT NULL, + "ordering_evidence_value" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "source_reference" text NOT NULL, + "received_at" timestamp with time zone NOT NULL, + "assertion_json" jsonb NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_source_assertions_meaning_ck" CHECK ("fact_meaning" = 'ABSOLUTE_PHYSICAL_ON_HAND' and "issuer_backend_kind" = 'external_business_system'), + CONSTRAINT "inventory_source_assertions_authority_ck" CHECK ("issuer_authority" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')), + CONSTRAINT "inventory_source_assertions_unit_ck" CHECK ("unit_module_id" = 'commerce.catalog' and "unit_resource_type" = 'commerce.catalog.product-unit' and "unit_tenant_id" = "tenant_id"), + CONSTRAINT "inventory_source_assertions_text_ck" CHECK (length(btrim("customer_configuration_id")) between 1 and 300 and length(btrim("issuer_backend_id")) between 1 and 300 and length(btrim("quantity_amount")) between 1 and 50 and length(btrim("ordering_evidence_value")) between 1 and 300 and length(btrim("owner_evidence_ref")) between 1 and 300 and length(btrim("source_reference")) between 1 and 300), + CONSTRAINT "inventory_source_assertions_ordering_ck" CHECK ("ordering_evidence_kind" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')) +); +--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_source_assertions_tenant_id_uk" ON "inventory"."source_assertions" ("tenant_id","assertion_id");--> statement-breakpoint +CREATE INDEX "inventory_source_assertions_position_observed_idx" ON "inventory"."source_assertions" ("tenant_id","position_id","business_observed_at");--> statement-breakpoint +ALTER TABLE "inventory"."source_assertion_coverage" ADD CONSTRAINT "inventory_source_assertion_coverage_assertion_fk" FOREIGN KEY ("tenant_id","assertion_id") REFERENCES "inventory"."source_assertions"("tenant_id","assertion_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertion_coverage" ADD CONSTRAINT "inventory_source_assertion_coverage_effect_fk" FOREIGN KEY ("tenant_id","effect_id") REFERENCES "inventory"."physical_stock_effects"("tenant_id","effect_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ADD CONSTRAINT "inventory_source_assertions_authority_configuration_fk" FOREIGN KEY ("tenant_id","authority_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ADD CONSTRAINT "inventory_source_assertions_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ADD CONSTRAINT "inventory_source_assertions_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ADD CONSTRAINT "inventory_source_assertions_location_fk" FOREIGN KEY ("tenant_id","stock_location_id") REFERENCES "inventory"."stock_locations"("tenant_id","stock_location_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ADD CONSTRAINT "inventory_source_assertions_item_correlation_fk" FOREIGN KEY ("tenant_id","item_correlation_id") REFERENCES "inventory"."external_stock_correlations"("tenant_id","correlation_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" ADD CONSTRAINT "inventory_source_assertions_location_correlation_fk" FOREIGN KEY ("tenant_id","location_correlation_id") REFERENCES "inventory"."external_stock_correlations"("tenant_id","correlation_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_source_assertion_coverage_tenant_select" ON "inventory"."source_assertion_coverage" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."source_assertion_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertion_coverage_tenant_insert" ON "inventory"."source_assertion_coverage" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."source_assertion_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertion_coverage_tenant_update" ON "inventory"."source_assertion_coverage" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."source_assertion_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."source_assertion_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertion_coverage_tenant_delete" ON "inventory"."source_assertion_coverage" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."source_assertion_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertions_tenant_select" ON "inventory"."source_assertions" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."source_assertions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertions_tenant_insert" ON "inventory"."source_assertions" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."source_assertions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertions_tenant_update" ON "inventory"."source_assertions" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."source_assertions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."source_assertions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_assertions_tenant_delete" ON "inventory"."source_assertions" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."source_assertions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."source_assertion_coverage" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."source_assertions" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_source_assertion_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + authority_configuration "inventory"."backend_configurations"%ROWTYPE; + selected_issuer boolean; + stored_assertion jsonb; +BEGIN + IF TG_TABLE_NAME = 'source_assertions' THEN + IF pg_catalog.jsonb_typeof(NEW.assertion_json) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.assertion_json -> 'coverage') IS DISTINCT FROM 'array' + OR NEW.assertion_json ->> 'assertionId' IS DISTINCT FROM NEW.assertion_id::text + OR NEW.assertion_json ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.assertion_json ->> 'factMeaning' IS DISTINCT FROM NEW.fact_meaning + OR NEW.assertion_json ->> 'issuerAuthority' IS DISTINCT FROM NEW.issuer_authority + OR NEW.assertion_json #>> '{issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.assertion_json #>> '{issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.assertion_json #>> '{authorityConfiguration,configurationId}' IS DISTINCT FROM NEW.authority_configuration_id::text + OR NEW.assertion_json #>> '{authorityConfiguration,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{authorityConfiguration,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.assertion_json #>> '{itemCorrelationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.assertion_json #>> '{itemCorrelationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.external-stock-correlation' + OR NEW.assertion_json #>> '{itemCorrelationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{itemCorrelationRef,resourceId}' IS DISTINCT FROM NEW.item_correlation_id::text + OR NEW.assertion_json #>> '{locationCorrelationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.assertion_json #>> '{locationCorrelationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.external-stock-correlation' + OR NEW.assertion_json #>> '{locationCorrelationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{locationCorrelationRef,resourceId}' IS DISTINCT FROM NEW.location_correlation_id::text + OR NEW.assertion_json #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.assertion_json #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.assertion_json #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR NEW.assertion_json #>> '{stockItemRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.assertion_json #>> '{stockItemRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-item' + OR NEW.assertion_json #>> '{stockItemRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{stockItemRef,resourceId}' IS DISTINCT FROM NEW.stock_item_id::text + OR NEW.assertion_json #>> '{stockLocationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.assertion_json #>> '{stockLocationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-location' + OR NEW.assertion_json #>> '{stockLocationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{stockLocationRef,resourceId}' IS DISTINCT FROM NEW.stock_location_id::text + OR NEW.assertion_json #>> '{quantity,amount}' IS DISTINCT FROM NEW.quantity_amount + OR NEW.assertion_json #>> '{quantity,unitRef,moduleId}' IS DISTINCT FROM NEW.unit_module_id + OR NEW.assertion_json #>> '{quantity,unitRef,resourceType}' IS DISTINCT FROM NEW.unit_resource_type + OR NEW.assertion_json #>> '{quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.unit_tenant_id::text + OR NEW.assertion_json #>> '{quantity,unitRef,resourceId}' IS DISTINCT FROM NEW.unit_resource_id::text + OR (NEW.assertion_json ->> 'businessObservedAt')::timestamptz IS DISTINCT FROM NEW.business_observed_at + OR (NEW.assertion_json ->> 'receivedAt')::timestamptz IS DISTINCT FROM NEW.received_at + OR NEW.assertion_json #>> '{orderingEvidence,_tag}' IS DISTINCT FROM NEW.ordering_evidence_kind + OR ( + NEW.ordering_evidence_kind = 'SOURCE_REVISION' + AND ( + NEW.assertion_json #>> '{orderingEvidence,revision}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.assertion_json #> '{orderingEvidence,key}' IS NOT NULL + ) + ) + OR ( + NEW.ordering_evidence_kind = 'OWNER_ORDER_KEY' + AND ( + NEW.assertion_json #>> '{orderingEvidence,key}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.assertion_json #> '{orderingEvidence,revision}' IS NOT NULL + ) + ) + OR NEW.assertion_json ->> 'ownerEvidenceRef' IS DISTINCT FROM NEW.owner_evidence_ref + OR NEW.assertion_json ->> 'sourceReference' IS DISTINCT FROM NEW.source_reference + OR NEW.assertion_json #>> '{itemExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{itemExternalKey,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.assertion_json #>> '{itemExternalKey,issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.assertion_json #>> '{itemExternalKey,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.assertion_json #>> '{itemExternalKey,identifierKind}' IS DISTINCT FROM 'ITEM' + OR NEW.assertion_json #>> '{locationExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.assertion_json #>> '{locationExternalKey,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.assertion_json #>> '{locationExternalKey,issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.assertion_json #>> '{locationExternalKey,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.assertion_json #>> '{locationExternalKey,identifierKind}' IS DISTINCT FROM 'LOCATION' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion JSON must exactly match its relational owner scope'; + END IF; + + IF EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(NEW.assertion_json -> 'coverage') AS coverage(entry) + WHERE coverage.entry ->> 'assertionId' IS DISTINCT FROM NEW.assertion_id::text + OR coverage.entry ->> 'effectId' IS NULL + OR coverage.entry ->> 'relation' NOT IN ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN') + OR coalesce(length(btrim(coverage.entry ->> 'ownerEvidenceRef')), 0) NOT BETWEEN 1 AND 300 + ) OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(NEW.assertion_json -> 'coverage') AS coverage(entry) + ) <> ( + SELECT pg_catalog.count(DISTINCT coverage.entry ->> 'effectId') + FROM pg_catalog.jsonb_array_elements(NEW.assertion_json -> 'coverage') AS coverage(entry) + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion coverage evidence must be exact and unique'; + END IF; + + SELECT configuration.* INTO authority_configuration + FROM "inventory"."backend_configurations" AS configuration + WHERE configuration.tenant_id = NEW.tenant_id + AND configuration.configuration_id = NEW.authority_configuration_id + AND configuration.customer_configuration_id = NEW.customer_configuration_id + FOR KEY SHARE; + + IF NOT FOUND + OR NEW.assertion_json #>> '{authorityConfiguration,revision}' IS DISTINCT FROM authority_configuration.revision::text + OR (NEW.assertion_json #>> '{authorityConfiguration,selectedAt}')::timestamptz IS DISTINCT FROM authority_configuration.selected_at + OR NEW.assertion_json #>> '{authorityConfiguration,selection,backend}' IS DISTINCT FROM authority_configuration.backend_kind + OR NEW.assertion_json #>> '{authorityConfiguration,selection,backendId}' IS DISTINCT FROM authority_configuration.backend_id + OR NEW.assertion_json #>> '{authorityConfiguration,selection,exactReservationCapability}' IS DISTINCT FROM authority_configuration.exact_reservation_capability + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion authority configuration evidence is not exact'; + END IF; + + selected_issuer := authority_configuration.backend_kind = NEW.issuer_backend_kind + AND authority_configuration.backend_id = NEW.issuer_backend_id + AND NEW.business_observed_at >= authority_configuration.selected_at; + IF (NEW.issuer_authority = 'SELECTED_BACKEND' AND NOT selected_issuer) + OR (NEW.issuer_authority = 'HISTORICAL_PRE_CUTOVER_ISSUER' AND selected_issuer) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion issuer authority contradicts the captured backend configuration'; + END IF; + + PERFORM 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.position_id + AND position.customer_configuration_id = NEW.customer_configuration_id + AND position.stock_item_id = NEW.stock_item_id + AND position.stock_location_id = NEW.stock_location_id + AND position.stock_unit_module_id = NEW.unit_module_id + AND position.stock_unit_resource_id = NEW.unit_resource_id + AND position.stock_unit_resource_type = NEW.unit_resource_type + AND position.stock_unit_tenant_id = NEW.unit_tenant_id + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion Position scope is not exact'; + END IF; + + PERFORM 1 + FROM "inventory"."external_stock_correlations" AS correlation + WHERE correlation.tenant_id = NEW.tenant_id + AND correlation.correlation_id = NEW.item_correlation_id + AND correlation.customer_configuration_id = NEW.customer_configuration_id + AND correlation.issuer_backend_kind = NEW.issuer_backend_kind + AND correlation.issuer_backend_id = NEW.issuer_backend_id + AND correlation.namespace = NEW.assertion_json #>> '{itemExternalKey,namespace}' + AND correlation.external_scope = NEW.assertion_json #>> '{itemExternalKey,externalScope}' + AND correlation.identifier_kind = 'ITEM' + AND correlation.external_value = NEW.assertion_json #>> '{itemExternalKey,externalValue}' + AND correlation.stock_item_id = NEW.stock_item_id + AND correlation.stock_location_id IS NULL + AND correlation.effective_from <= NEW.business_observed_at + AND (correlation.effective_to IS NULL OR NEW.business_observed_at < correlation.effective_to) + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion Item correlation is not effective for business-observed time'; + END IF; + + PERFORM 1 + FROM "inventory"."external_stock_correlations" AS correlation + WHERE correlation.tenant_id = NEW.tenant_id + AND correlation.correlation_id = NEW.location_correlation_id + AND correlation.customer_configuration_id = NEW.customer_configuration_id + AND correlation.issuer_backend_kind = NEW.issuer_backend_kind + AND correlation.issuer_backend_id = NEW.issuer_backend_id + AND correlation.namespace = NEW.assertion_json #>> '{locationExternalKey,namespace}' + AND correlation.external_scope = NEW.assertion_json #>> '{locationExternalKey,externalScope}' + AND correlation.identifier_kind = 'LOCATION' + AND correlation.external_value = NEW.assertion_json #>> '{locationExternalKey,externalValue}' + AND correlation.stock_location_id = NEW.stock_location_id + AND correlation.stock_item_id IS NULL + AND correlation.effective_from <= NEW.business_observed_at + AND (correlation.effective_to IS NULL OR NEW.business_observed_at < correlation.effective_to) + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_exact_scope_ck', + MESSAGE = 'Inventory Source Assertion Location correlation is not effective for business-observed time'; + END IF; + + RETURN NEW; + END IF; + + SELECT assertion.assertion_json INTO stored_assertion + FROM "inventory"."source_assertions" AS assertion + JOIN "inventory"."physical_stock_effects" AS effect + ON effect.tenant_id = NEW.tenant_id + AND effect.effect_id = NEW.effect_id + AND effect.position_id = assertion.position_id + AND effect.stock_item_id = assertion.stock_item_id + AND effect.stock_location_id = assertion.stock_location_id + AND effect.unit_resource_id = assertion.unit_resource_id + AND effect.state = 'APPLIED' + WHERE assertion.tenant_id = NEW.tenant_id + AND assertion.assertion_id = NEW.assertion_id + FOR KEY SHARE OF assertion, effect; + + IF NOT FOUND OR NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(stored_assertion -> 'coverage') AS coverage(entry) + WHERE coverage.entry ->> 'assertionId' = NEW.assertion_id::text + AND coverage.entry ->> 'effectId' = NEW.effect_id::text + AND coverage.entry ->> 'relation' = NEW.relation + AND coverage.entry ->> 'ownerEvidenceRef' = NEW.owner_evidence_ref + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertion_coverage_exact_scope_ck', + MESSAGE = 'Source Coverage must match its exact Assertion, physical effect, and nested owner evidence'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_source_assertions_exact_scope_trg" +BEFORE INSERT ON "inventory"."source_assertions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_assertion_exact_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_source_assertion_coverage_exact_scope_trg" +BEFORE INSERT ON "inventory"."source_assertion_coverage" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_assertion_exact_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_source_assertion_coverage_complete"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF pg_catalog.jsonb_array_length(NEW.assertion_json -> 'coverage') IS DISTINCT FROM ( + SELECT pg_catalog.count(*)::integer + FROM "inventory"."source_assertion_coverage" AS stored + WHERE stored.tenant_id = NEW.tenant_id + AND stored.assertion_id = NEW.assertion_id + ) OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(NEW.assertion_json -> 'coverage') AS expected(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM "inventory"."source_assertion_coverage" AS stored + WHERE stored.tenant_id = NEW.tenant_id + AND stored.assertion_id = NEW.assertion_id + AND stored.effect_id::text = expected.entry ->> 'effectId' + AND stored.relation = expected.entry ->> 'relation' + AND stored.owner_evidence_ref = expected.entry ->> 'ownerEvidenceRef' + ) + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertion_coverage_complete_ck', + MESSAGE = 'Inventory Source Assertion JSON coverage and relational coverage must be an exact bijection'; + END IF; + + RETURN NULL; +END; +$$; +--> statement-breakpoint +CREATE CONSTRAINT TRIGGER "inventory_source_assertion_coverage_complete_trg" +AFTER INSERT ON "inventory"."source_assertions" +DEFERRABLE INITIALLY DEFERRED +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_assertion_coverage_complete"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_source_assertion_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_assertions_append_only_ck', + MESSAGE = 'Inventory Source Assertions and coverage evidence are append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_source_assertions_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."source_assertions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_source_assertion_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_source_assertion_coverage_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."source_assertion_coverage" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_source_assertion_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_source_assertion_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_source_assertion_coverage_complete"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_source_assertion_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924133041_inventory-source-assertions/snapshot.json b/app/verticals/inventory/drizzle/20260924133041_inventory-source-assertions/snapshot.json new file mode 100644 index 000000000..3ebdeaa21 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924133041_inventory-source-assertions/snapshot.json @@ -0,0 +1,4744 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "4a26a346-f116-4ae7-9b06-6fba0d163186", + "prevIds": [ + "9d2817b3-549d-4a58-bb02-e58a56e50f9f" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924134427_inventory-obligations/migration.sql b/app/verticals/inventory/drizzle/20260924134427_inventory-obligations/migration.sql new file mode 100644 index 000000000..dbd5bbd06 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924134427_inventory-obligations/migration.sql @@ -0,0 +1,433 @@ +CREATE TABLE "inventory"."obligation_allocations" ( + "tenant_id" uuid NOT NULL, + "obligation_id" uuid NOT NULL, + "allocation_id" text NOT NULL, + "purchase_demand_occurrence_id" text NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_position_id" uuid NOT NULL, + "allocated_amount" numeric(38,9) NOT NULL, + "unit_module_id" text NOT NULL, + "unit_resource_id" uuid NOT NULL, + "unit_resource_type" text NOT NULL, + "unit_tenant_id" uuid NOT NULL, + CONSTRAINT "inventory_obligation_allocations_meaning_ck" CHECK (char_length(btrim("allocation_id")) between 1 and 300 and "allocated_amount" >= 0 and "unit_module_id" = 'commerce.catalog' and "unit_resource_type" = 'commerce.catalog.product-unit' and "unit_tenant_id" = "tenant_id") +); +--> statement-breakpoint +ALTER TABLE "inventory"."obligation_allocations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."obligation_requirements" ( + "tenant_id" uuid NOT NULL, + "obligation_id" uuid NOT NULL, + "purchase_demand_occurrence_id" text NOT NULL, + "binding_id" uuid NOT NULL, + "catalog_selection" jsonb NOT NULL, + "exact_selection_meaning_id" text NOT NULL, + "exact_selection_meaning_kind" text NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_item_revision" integer NOT NULL, + "stock_item_snapshot" jsonb NOT NULL, + "requested_amount" numeric(38,9) NOT NULL, + "unit_module_id" text NOT NULL, + "unit_resource_id" uuid NOT NULL, + "unit_resource_type" text NOT NULL, + "unit_tenant_id" uuid NOT NULL, + CONSTRAINT "inventory_obligation_requirements_meaning_ck" CHECK (char_length(btrim("purchase_demand_occurrence_id")) between 1 and 300 and char_length(btrim("exact_selection_meaning_id")) between 1 and 300 and "exact_selection_meaning_kind" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and "stock_item_revision" >= 1 and "requested_amount" >= 0 and "unit_module_id" = 'commerce.catalog' and "unit_resource_type" = 'commerce.catalog.product-unit' and "unit_tenant_id" = "tenant_id") +); +--> statement-breakpoint +ALTER TABLE "inventory"."obligation_requirements" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."obligations" ( + "obligation_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "origin_kind" text NOT NULL, + "lifecycle_meaning" text NOT NULL, + "attempt_id" text, + "accepted_order_id" text, + "order_evidence_ref" text, + "order_evidence_observed_at" timestamp with time zone, + "source_system" text, + "source_order_id" text, + "source_obligation_id" text, + "customer_configuration_id" text NOT NULL, + "owner_configuration_id" uuid NOT NULL, + "authority_backend_kind" text NOT NULL, + "authority_backend_id" text NOT NULL, + "authority_selected_at" timestamp with time zone NOT NULL, + "authority_revision" integer DEFAULT 1 NOT NULL, + "established_at" timestamp with time zone NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_obligations_origin_ck" CHECK (("origin_kind" = 'ORDER_COMMITMENT_ATTEMPT' and "attempt_id" is not null and "source_system" is null and "source_order_id" is null and "source_obligation_id" is null) or ("origin_kind" = 'IMPORTED_PROVEN_ORDER' and "attempt_id" is null and "source_system" is not null and "source_order_id" is not null and "source_obligation_id" is not null)), + CONSTRAINT "inventory_obligations_lifecycle_ck" CHECK (("origin_kind" = 'ORDER_COMMITMENT_ATTEMPT' and (("lifecycle_meaning" = 'PROVISIONAL_RESERVATION' and "accepted_order_id" is null and "order_evidence_ref" is null and "order_evidence_observed_at" is null) or ("lifecycle_meaning" = 'COMMITTED_OBLIGATION' and "accepted_order_id" is not null and "order_evidence_ref" is not null and "order_evidence_observed_at" is not null))) or ("origin_kind" = 'IMPORTED_PROVEN_ORDER' and "lifecycle_meaning" = 'COMMITTED_OBLIGATION' and "accepted_order_id" is not null and "order_evidence_ref" is not null and "order_evidence_observed_at" is not null)), + CONSTRAINT "inventory_obligations_identity_text_ck" CHECK (char_length(btrim("customer_configuration_id")) between 1 and 300 and char_length(btrim("authority_backend_id")) between 1 and 300 and ("attempt_id" is null or char_length(btrim("attempt_id")) between 1 and 300) and ("accepted_order_id" is null or char_length(btrim("accepted_order_id")) between 1 and 300) and ("order_evidence_ref" is null or char_length(btrim("order_evidence_ref")) between 1 and 300) and ("source_system" is null or char_length(btrim("source_system")) between 1 and 300) and ("source_order_id" is null or char_length(btrim("source_order_id")) between 1 and 300) and ("source_obligation_id" is null or char_length(btrim("source_obligation_id")) between 1 and 300)), + CONSTRAINT "inventory_obligations_authority_ck" CHECK ("authority_backend_kind" in ('external_business_system', 'ontos_wms') and "authority_revision" = 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_obligation_allocations_identity_uk" ON "inventory"."obligation_allocations" ("tenant_id","obligation_id","allocation_id");--> statement-breakpoint +CREATE INDEX "inventory_obligation_allocations_position_idx" ON "inventory"."obligation_allocations" ("tenant_id","stock_position_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_obligation_requirements_occurrence_uk" ON "inventory"."obligation_requirements" ("tenant_id","obligation_id","purchase_demand_occurrence_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_obligations_scope_id_uk" ON "inventory"."obligations" ("tenant_id","obligation_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_obligations_attempt_uk" ON "inventory"."obligations" ("tenant_id","attempt_id") WHERE "origin_kind" = 'ORDER_COMMITMENT_ATTEMPT';--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_obligations_imported_lineage_uk" ON "inventory"."obligations" ("tenant_id","source_system","source_order_id","source_obligation_id") WHERE "origin_kind" = 'IMPORTED_PROVEN_ORDER';--> statement-breakpoint +ALTER TABLE "inventory"."obligation_allocations" ADD CONSTRAINT "inventory_obligation_allocations_requirement_fk" FOREIGN KEY ("tenant_id","obligation_id","purchase_demand_occurrence_id") REFERENCES "inventory"."obligation_requirements"("tenant_id","obligation_id","purchase_demand_occurrence_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."obligation_allocations" ADD CONSTRAINT "inventory_obligation_allocations_position_fk" FOREIGN KEY ("tenant_id","stock_position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."obligation_allocations" ADD CONSTRAINT "inventory_obligation_allocations_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."obligation_requirements" ADD CONSTRAINT "inventory_obligation_requirements_obligation_fk" FOREIGN KEY ("tenant_id","obligation_id") REFERENCES "inventory"."obligations"("tenant_id","obligation_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."obligation_requirements" ADD CONSTRAINT "inventory_obligation_requirements_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."obligations" ADD CONSTRAINT "inventory_obligations_backend_configuration_fk" FOREIGN KEY ("tenant_id","owner_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_obligation_allocations_tenant_select" ON "inventory"."obligation_allocations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."obligation_allocations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_allocations_tenant_insert" ON "inventory"."obligation_allocations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."obligation_allocations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_allocations_tenant_update" ON "inventory"."obligation_allocations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."obligation_allocations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."obligation_allocations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_allocations_tenant_delete" ON "inventory"."obligation_allocations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."obligation_allocations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_requirements_tenant_select" ON "inventory"."obligation_requirements" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."obligation_requirements"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_requirements_tenant_insert" ON "inventory"."obligation_requirements" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."obligation_requirements"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_requirements_tenant_update" ON "inventory"."obligation_requirements" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."obligation_requirements"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."obligation_requirements"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligation_requirements_tenant_delete" ON "inventory"."obligation_requirements" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."obligation_requirements"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligations_tenant_select" ON "inventory"."obligations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."obligations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligations_tenant_insert" ON "inventory"."obligations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."obligations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligations_tenant_update" ON "inventory"."obligations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."obligations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."obligations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_obligations_tenant_delete" ON "inventory"."obligations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."obligations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."obligation_allocations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."obligation_requirements" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_obligation_authority"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'UPDATE' + AND NEW.obligation_id IS NOT DISTINCT FROM OLD.obligation_id + AND NEW.tenant_id IS NOT DISTINCT FROM OLD.tenant_id + AND NEW.origin_kind IS NOT DISTINCT FROM OLD.origin_kind + AND NEW.attempt_id IS NOT DISTINCT FROM OLD.attempt_id + AND NEW.source_system IS NOT DISTINCT FROM OLD.source_system + AND NEW.source_order_id IS NOT DISTINCT FROM OLD.source_order_id + AND NEW.source_obligation_id IS NOT DISTINCT FROM OLD.source_obligation_id + AND NEW.customer_configuration_id IS NOT DISTINCT FROM OLD.customer_configuration_id + AND NEW.owner_configuration_id IS NOT DISTINCT FROM OLD.owner_configuration_id + AND NEW.authority_backend_kind IS NOT DISTINCT FROM OLD.authority_backend_kind + AND NEW.authority_backend_id IS NOT DISTINCT FROM OLD.authority_backend_id + AND NEW.authority_selected_at IS NOT DISTINCT FROM OLD.authority_selected_at + AND NEW.authority_revision IS NOT DISTINCT FROM OLD.authority_revision + AND NEW.established_at IS NOT DISTINCT FROM OLD.established_at + THEN + RETURN NEW; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS configuration + WHERE configuration.tenant_id = NEW.tenant_id + AND configuration.configuration_id = NEW.owner_configuration_id + AND configuration.customer_configuration_id = NEW.customer_configuration_id + AND configuration.backend_kind = NEW.authority_backend_kind + AND configuration.backend_id = NEW.authority_backend_id + AND configuration.selected_at = NEW.authority_selected_at + AND configuration.revision = NEW.authority_revision + AND configuration.exact_reservation_capability = 'SUPPORTED' + FOR UPDATE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_exact_authority_ck', + MESSAGE = 'Inventory Obligation must retain the exact selected backend configuration snapshot'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_obligations_exact_authority_trg" +BEFORE INSERT OR UPDATE ON "inventory"."obligations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_obligation_authority"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_obligation_requirement_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF pg_catalog.jsonb_typeof(NEW.catalog_selection) IS DISTINCT FROM 'object' + OR NEW.catalog_selection #>> '{productRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.catalog_selection #>> '{variantRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_path_query(NEW.catalog_selection, 'strict $.**.tenantId') AS selected(tenant_id) + WHERE selected.tenant_id #>> '{}' IS DISTINCT FROM NEW.tenant_id::text + ) + OR pg_catalog.jsonb_typeof(NEW.stock_item_snapshot) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.stock_item_snapshot -> 'exactSelectionMeaning') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.stock_item_snapshot -> 'stockItemRef') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.stock_item_snapshot -> 'unitRef') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.stock_item_snapshot -> 'createdAt') IS DISTINCT FROM 'string' + OR pg_catalog.jsonb_typeof(NEW.stock_item_snapshot -> 'revision') IS DISTINCT FROM 'number' + OR NOT pg_catalog.pg_input_is_valid(NEW.stock_item_snapshot ->> 'createdAt', 'timestamp with time zone') + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligation_requirements_exact_item_unit_ck', + MESSAGE = 'Inventory Obligation Requirement must retain exact typed selection and Stock Item provenance'; + END IF; + + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.stock_item_snapshot)) <> 7 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.stock_item_snapshot -> 'exactSelectionMeaning')) <> 2 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.stock_item_snapshot -> 'stockItemRef')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.stock_item_snapshot -> 'unitRef')) <> 4 + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligation_requirements_exact_item_unit_ck', + MESSAGE = 'Inventory Obligation Requirement Stock Item snapshot must have only canonical evidence fields'; + END IF; + + PERFORM 1 + FROM "inventory"."catalog_to_stock_bindings" AS binding + JOIN "inventory"."stock_items" AS item + ON item.tenant_id = NEW.tenant_id + AND item.stock_item_id = NEW.stock_item_id + WHERE binding.tenant_id = NEW.tenant_id + AND binding.binding_id = NEW.binding_id + AND binding.exact_selection_meaning_id = NEW.exact_selection_meaning_id + AND binding.exact_selection_kind = NEW.exact_selection_meaning_kind + AND binding.stock_item_id = NEW.stock_item_id + AND binding.stock_unit_module_id = NEW.unit_module_id + AND binding.stock_unit_resource_id = NEW.unit_resource_id + AND binding.stock_unit_resource_type = NEW.unit_resource_type + AND binding.stock_unit_tenant_id = NEW.unit_tenant_id + AND item.exact_selection_meaning_id = NEW.exact_selection_meaning_id + AND item.exact_selection_kind = NEW.exact_selection_meaning_kind + AND item.stock_unit_module_id = NEW.unit_module_id + AND item.stock_unit_resource_id = NEW.unit_resource_id + AND item.stock_unit_resource_type = NEW.unit_resource_type + AND item.stock_unit_tenant_id = NEW.unit_tenant_id + AND item.revision = NEW.stock_item_revision + AND item.lifecycle_state = 'CURRENT' + AND NEW.stock_item_snapshot #>> '{exactSelectionMeaning,id}' = item.exact_selection_meaning_id + AND NEW.stock_item_snapshot #>> '{exactSelectionMeaning,kind}' = item.exact_selection_kind + AND NEW.stock_item_snapshot #>> '{stockItemRef,moduleId}' = 'commerce.inventory' + AND NEW.stock_item_snapshot #>> '{stockItemRef,resourceType}' = 'commerce.inventory.stock-item' + AND NEW.stock_item_snapshot #>> '{stockItemRef,tenantId}' = item.tenant_id::text + AND NEW.stock_item_snapshot #>> '{stockItemRef,resourceId}' = item.stock_item_id::text + AND NEW.stock_item_snapshot #>> '{unitRef,moduleId}' = item.stock_unit_module_id + AND NEW.stock_item_snapshot #>> '{unitRef,resourceType}' = item.stock_unit_resource_type + AND NEW.stock_item_snapshot #>> '{unitRef,tenantId}' = item.stock_unit_tenant_id::text + AND NEW.stock_item_snapshot #>> '{unitRef,resourceId}' = item.stock_unit_resource_id::text + AND NEW.stock_item_snapshot ->> 'revision' = item.revision::text + AND NEW.stock_item_snapshot ->> 'lifecycle' = item.lifecycle_state + AND NEW.stock_item_snapshot -> 'retiredAt' = 'null'::jsonb + AND (NEW.stock_item_snapshot ->> 'createdAt')::timestamptz = item.created_at + FOR UPDATE OF binding, item; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligation_requirements_exact_item_unit_ck', + MESSAGE = 'Inventory Obligation Requirement must match the Current binding, immutable Item meaning, Unit, revision, and snapshot'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_obligation_requirements_exact_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."obligation_requirements" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_obligation_requirement_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_obligation_allocation_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 + FROM "inventory"."obligation_requirements" AS requirement + JOIN "inventory"."obligations" AS obligation + ON obligation.tenant_id = requirement.tenant_id + AND obligation.obligation_id = requirement.obligation_id + JOIN "inventory"."stock_positions" AS position + ON position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.stock_position_id + WHERE requirement.tenant_id = NEW.tenant_id + AND requirement.obligation_id = NEW.obligation_id + AND requirement.purchase_demand_occurrence_id = NEW.purchase_demand_occurrence_id + AND requirement.stock_item_id = NEW.stock_item_id + AND requirement.unit_module_id = NEW.unit_module_id + AND requirement.unit_resource_id = NEW.unit_resource_id + AND requirement.unit_resource_type = NEW.unit_resource_type + AND requirement.unit_tenant_id = NEW.unit_tenant_id + AND position.customer_configuration_id = obligation.customer_configuration_id + AND position.owner_configuration_id = obligation.owner_configuration_id + AND position.stock_item_id = NEW.stock_item_id + AND position.lifecycle_state = 'CURRENT' + AND position.stock_unit_module_id = NEW.unit_module_id + AND position.stock_unit_resource_id = NEW.unit_resource_id + AND position.stock_unit_resource_type = NEW.unit_resource_type + AND position.stock_unit_tenant_id = NEW.unit_tenant_id + FOR UPDATE OF requirement, obligation, position; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligation_allocations_exact_scope_ck', + MESSAGE = 'Inventory Obligation Allocation must match its Requirement and exact Position Item, Unit, and backend owner'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_obligation_allocations_exact_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."obligation_allocations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_obligation_allocation_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_obligation_requirement_coverage"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + allocation_count bigint; + allocated_total numeric(38, 9); + required_amount numeric(38, 9); +BEGIN + SELECT requirement.requested_amount, pg_catalog.count(allocation.allocation_id), coalesce(pg_catalog.sum(allocation.allocated_amount), 0) + INTO required_amount, allocation_count, allocated_total + FROM "inventory"."obligation_requirements" AS requirement + LEFT JOIN "inventory"."obligation_allocations" AS allocation + ON allocation.tenant_id = requirement.tenant_id + AND allocation.obligation_id = requirement.obligation_id + AND allocation.purchase_demand_occurrence_id = requirement.purchase_demand_occurrence_id + WHERE requirement.tenant_id = NEW.tenant_id + AND requirement.obligation_id = NEW.obligation_id + AND requirement.purchase_demand_occurrence_id = NEW.purchase_demand_occurrence_id + GROUP BY requirement.requested_amount; + + IF NOT FOUND OR allocation_count < 1 OR allocated_total IS DISTINCT FROM required_amount THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_exact_requirement_coverage_ck', + MESSAGE = 'Inventory Obligation allocations must cover every Requirement with the exact requested amount'; + END IF; + + RETURN NULL; +END; +$$; +--> statement-breakpoint +CREATE CONSTRAINT TRIGGER "inventory_obligation_requirements_exact_coverage_trg" +AFTER INSERT ON "inventory"."obligation_requirements" +DEFERRABLE INITIALLY DEFERRED +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_obligation_requirement_coverage"(); +--> statement-breakpoint +CREATE CONSTRAINT TRIGGER "inventory_obligation_allocations_exact_coverage_trg" +AFTER INSERT ON "inventory"."obligation_allocations" +DEFERRABLE INITIALLY DEFERRED +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_obligation_requirement_coverage"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_obligation_origin_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' + OR NEW.obligation_id IS DISTINCT FROM OLD.obligation_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.origin_kind IS DISTINCT FROM OLD.origin_kind + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.source_system IS DISTINCT FROM OLD.source_system + OR NEW.source_order_id IS DISTINCT FROM OLD.source_order_id + OR NEW.source_obligation_id IS DISTINCT FROM OLD.source_obligation_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.authority_backend_kind IS DISTINCT FROM OLD.authority_backend_kind + OR NEW.authority_backend_id IS DISTINCT FROM OLD.authority_backend_id + OR NEW.authority_selected_at IS DISTINCT FROM OLD.authority_selected_at + OR NEW.authority_revision IS DISTINCT FROM OLD.authority_revision + OR NEW.established_at IS DISTINCT FROM OLD.established_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR ( + OLD.origin_kind = 'IMPORTED_PROVEN_ORDER' + AND ( + NEW.lifecycle_meaning IS DISTINCT FROM OLD.lifecycle_meaning + OR NEW.accepted_order_id IS DISTINCT FROM OLD.accepted_order_id + OR NEW.order_evidence_ref IS DISTINCT FROM OLD.order_evidence_ref + OR NEW.order_evidence_observed_at IS DISTINCT FROM OLD.order_evidence_observed_at + ) + ) + OR ( + OLD.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND ( + NEW.lifecycle_meaning IS DISTINCT FROM OLD.lifecycle_meaning + OR NEW.accepted_order_id IS DISTINCT FROM OLD.accepted_order_id + OR NEW.order_evidence_ref IS DISTINCT FROM OLD.order_evidence_ref + OR NEW.order_evidence_observed_at IS DISTINCT FROM OLD.order_evidence_observed_at + ) + AND NOT ( + OLD.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND OLD.accepted_order_id IS NULL + AND OLD.order_evidence_ref IS NULL + AND OLD.order_evidence_observed_at IS NULL + AND NEW.lifecycle_meaning = 'COMMITTED_OBLIGATION' + AND NEW.accepted_order_id IS NOT NULL + AND NEW.order_evidence_ref IS NOT NULL + AND NEW.order_evidence_observed_at IS NOT NULL + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Inventory Obligation is immutable except for one runtime provisional-to-committed transition'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_obligations_immutable_origin_trg" +BEFORE UPDATE OR DELETE ON "inventory"."obligations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_obligation_origin_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_obligation_requirement_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligation_requirements_append_only_ck', + MESSAGE = 'Inventory Obligation Requirements are append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_obligation_requirements_append_only_trg" +BEFORE UPDATE OR DELETE ON "inventory"."obligation_requirements" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_obligation_requirement_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_obligation_allocation_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligation_allocations_append_only_ck', + MESSAGE = 'Inventory Obligation Allocations are append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_obligation_allocations_append_only_trg" +BEFORE UPDATE OR DELETE ON "inventory"."obligation_allocations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_obligation_allocation_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_obligation_authority"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_obligation_requirement_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_obligation_allocation_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_obligation_requirement_coverage"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_obligation_origin_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_obligation_requirement_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_obligation_allocation_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924134427_inventory-obligations/snapshot.json b/app/verticals/inventory/drizzle/20260924134427_inventory-obligations/snapshot.json new file mode 100644 index 000000000..e091e00dd --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924134427_inventory-obligations/snapshot.json @@ -0,0 +1,5867 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "bb0e3295-9906-4c6e-b98c-bf4ec4cda24d", + "prevIds": [ + "4a26a346-f116-4ae7-9b06-6fba0d163186" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924135933_inventory-source-import-ledger/migration.sql b/app/verticals/inventory/drizzle/20260924135933_inventory-source-import-ledger/migration.sql new file mode 100644 index 000000000..d49b34e69 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924135933_inventory-source-import-ledger/migration.sql @@ -0,0 +1,192 @@ +CREATE TABLE "inventory"."source_import_ledger" ( + "tenant_id" uuid, + "action_invocation_id" uuid, + "item_index" integer, + "assertion_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "fact_meaning" text NOT NULL, + "position_id" uuid NOT NULL, + "source_reference" text NOT NULL, + "ordering_evidence_kind" text NOT NULL, + "ordering_evidence_value" text NOT NULL, + "status" text NOT NULL, + "proposal_json" jsonb NOT NULL, + "outcome_json" jsonb NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_source_import_ledger_pk" PRIMARY KEY("tenant_id","action_invocation_id","item_index"), + CONSTRAINT "inventory_source_import_ledger_item_index_ck" CHECK ("item_index" >= 0), + CONSTRAINT "inventory_source_import_ledger_meaning_ck" CHECK ("fact_meaning" = 'ABSOLUTE_PHYSICAL_ON_HAND' and "issuer_backend_kind" = 'external_business_system'), + CONSTRAINT "inventory_source_import_ledger_ordering_ck" CHECK ("ordering_evidence_kind" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')), + CONSTRAINT "inventory_source_import_ledger_status_ck" CHECK ("status" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')), + CONSTRAINT "inventory_source_import_ledger_text_ck" CHECK (length(btrim("customer_configuration_id")) between 1 and 300 and length(btrim("issuer_backend_id")) between 1 and 300 and length(btrim("source_reference")) between 1 and 300 and length(btrim("ordering_evidence_value")) between 1 and 300) +); +--> statement-breakpoint +ALTER TABLE "inventory"."source_import_ledger" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE INDEX "inventory_source_import_ledger_stream_idx" ON "inventory"."source_import_ledger" ("tenant_id","customer_configuration_id","issuer_backend_kind","issuer_backend_id","fact_meaning","position_id","recorded_at");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_source_import_accepted_assertion_uk" ON "inventory"."source_import_ledger" ("tenant_id","assertion_id") WHERE "status" = 'ACCEPTED';--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_source_import_accepted_source_identity_uk" ON "inventory"."source_import_ledger" ("tenant_id","customer_configuration_id","issuer_backend_kind","issuer_backend_id","fact_meaning","position_id","source_reference") WHERE "status" = 'ACCEPTED';--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_source_import_accepted_revision_uk" ON "inventory"."source_import_ledger" ("tenant_id","customer_configuration_id","issuer_backend_kind","issuer_backend_id","fact_meaning","position_id","ordering_evidence_kind","ordering_evidence_value") WHERE "status" = 'ACCEPTED';--> statement-breakpoint +ALTER TABLE "inventory"."source_import_ledger" ADD CONSTRAINT "inventory_source_import_ledger_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_source_import_ledger_tenant_select" ON "inventory"."source_import_ledger" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."source_import_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_import_ledger_tenant_insert" ON "inventory"."source_import_ledger" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."source_import_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_import_ledger_tenant_update" ON "inventory"."source_import_ledger" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."source_import_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."source_import_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_import_ledger_tenant_delete" ON "inventory"."source_import_ledger" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."source_import_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."source_import_ledger" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_source_import_ledger_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF pg_catalog.jsonb_typeof(NEW.proposal_json) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.proposal_json -> 'issuer') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.proposal_json -> 'positionRef') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.proposal_json -> 'orderingEvidence') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.outcome_json) IS DISTINCT FROM 'object' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import ledger JSON evidence must use canonical object shapes'; + END IF; + + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json)) <> 14 + OR NOT ( + NEW.proposal_json ?& ARRAY[ + 'assertionId', 'businessObservedAt', 'coverage', 'customerConfigurationId', 'factMeaning', 'issuer', + 'itemExternalKey', 'locationExternalKey', 'orderingEvidence', 'ownerEvidenceRef', 'positionRef', + 'quantity', 'receivedAt', 'sourceReference' + ] + ) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json -> 'issuer')) <> 2 + OR NOT (NEW.proposal_json -> 'issuer' ?& ARRAY['backendId', 'backendKind']) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json -> 'positionRef')) <> 4 + OR NOT (NEW.proposal_json -> 'positionRef' ?& ARRAY['moduleId', 'resourceId', 'resourceType', 'tenantId']) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json -> 'orderingEvidence')) <> 2 + OR NEW.proposal_json ->> 'assertionId' IS DISTINCT FROM NEW.assertion_id::text + OR NEW.proposal_json ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.proposal_json #>> '{issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.proposal_json #>> '{issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.proposal_json ->> 'factMeaning' IS DISTINCT FROM NEW.fact_meaning + OR NEW.proposal_json #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.proposal_json #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.proposal_json #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.proposal_json #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR NEW.proposal_json ->> 'sourceReference' IS DISTINCT FROM NEW.source_reference + OR NEW.proposal_json #>> '{orderingEvidence,_tag}' IS DISTINCT FROM NEW.ordering_evidence_kind + OR NEW.outcome_json ->> 'assertionId' IS DISTINCT FROM NEW.assertion_id::text + OR NEW.outcome_json ->> 'status' IS DISTINCT FROM NEW.status + OR ( + NEW.ordering_evidence_kind = 'SOURCE_REVISION' + AND ( + NEW.proposal_json #>> '{orderingEvidence,revision}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.proposal_json #> '{orderingEvidence,key}' IS NOT NULL + ) + ) + OR ( + NEW.ordering_evidence_kind = 'OWNER_ORDER_KEY' + AND ( + NEW.proposal_json #>> '{orderingEvidence,key}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.proposal_json #> '{orderingEvidence,revision}' IS NOT NULL + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import ledger JSON evidence must exactly match its relational stream and outcome'; + END IF; + + IF ( + NEW.status = 'ACCEPTED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 3 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'postEffectOnHand', 'status']) + OR pg_catalog.jsonb_typeof(NEW.outcome_json -> 'postEffectOnHand') IS DISTINCT FROM 'object' + ) + ) OR ( + NEW.status = 'DUPLICATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 4 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'duplicateOfAssertionId', 'reason', 'status']) + OR NEW.outcome_json ->> 'duplicateOfAssertionId' IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) OR ( + NEW.status = 'STALE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) NOT IN (3, 4) + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'reason', 'status']) + OR ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) = 4 + AND NOT (NEW.outcome_json ? 'currentAssertionId') + ) + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) OR ( + NEW.status = 'REJECTED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 3 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'reason', 'status']) + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) OR ( + NEW.status = 'INDETERMINATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 4 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'reason', 'reconciliationRequired', 'status']) + OR NEW.outcome_json -> 'reconciliationRequired' IS DISTINCT FROM 'true'::jsonb + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import ledger outcome JSON must exactly match its status contract'; + END IF; + + IF NEW.status = 'ACCEPTED' THEN + PERFORM 1 + FROM "inventory"."source_assertions" AS assertion + WHERE assertion.tenant_id = NEW.tenant_id + AND assertion.assertion_id = NEW.assertion_id + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23503', + CONSTRAINT = 'inventory_source_import_ledger_accepted_assertion_fk', + MESSAGE = 'Accepted Inventory Source Import outcome must reference the exact persisted source assertion'; + END IF; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_source_import_ledger_exact_scope_trg" +BEFORE INSERT ON "inventory"."source_import_ledger" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_import_ledger_exact_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_source_import_ledger_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_append_only_ck', + MESSAGE = 'Inventory Source Import ledger evidence is immutable'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_source_import_ledger_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."source_import_ledger" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_source_import_ledger_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_source_import_ledger_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_source_import_ledger_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924135933_inventory-source-import-ledger/snapshot.json b/app/verticals/inventory/drizzle/20260924135933_inventory-source-import-ledger/snapshot.json new file mode 100644 index 000000000..ef7b5cce9 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924135933_inventory-source-import-ledger/snapshot.json @@ -0,0 +1,6423 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "bde2f196-766f-46dc-ad18-903d5937eb0b", + "prevIds": [ + "bb0e3295-9906-4c6e-b98c-bf4ec4cda24d" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924171606_inventory-stock-corrections/migration.sql b/app/verticals/inventory/drizzle/20260924171606_inventory-stock-corrections/migration.sql new file mode 100644 index 000000000..a5ec7564a --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924171606_inventory-stock-corrections/migration.sql @@ -0,0 +1,898 @@ +CREATE TABLE "inventory"."stock_correction_open_reconciliations" ( + "tenant_id" uuid, + "position_id" uuid, + "correction_id" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_correction_open_pk" PRIMARY KEY("tenant_id","position_id") +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_open_reconciliations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_correction_source_evidence" ( + "evidence_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "authority_configuration_id" uuid NOT NULL, + "position_id" uuid NOT NULL, + "stock_item_id" uuid NOT NULL, + "stock_location_id" uuid NOT NULL, + "unit_module_id" text NOT NULL, + "unit_resource_id" uuid NOT NULL, + "unit_resource_type" text NOT NULL, + "unit_tenant_id" uuid NOT NULL, + "quantity_amount" text NOT NULL, + "fact_meaning" text NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "business_observed_at" timestamp with time zone NOT NULL, + "ordering_evidence_kind" text NOT NULL, + "ordering_evidence_value" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "source_reference" text NOT NULL, + "received_at" timestamp with time zone NOT NULL, + "evidence_json" jsonb NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_correction_source_evidence_meaning_ck" CHECK ("fact_meaning" = 'ABSOLUTE_PHYSICAL_ON_HAND' and "issuer_backend_kind" = 'ontos_wms'), + CONSTRAINT "inventory_stock_correction_source_evidence_ordering_ck" CHECK ("ordering_evidence_kind" = 'OWNER_ORDER_KEY'), + CONSTRAINT "inventory_stock_correction_source_evidence_unit_ck" CHECK ("unit_module_id" = 'commerce.catalog' and "unit_resource_type" = 'commerce.catalog.product-unit' and "unit_tenant_id" = "tenant_id"), + CONSTRAINT "inventory_stock_correction_source_evidence_quantity_ck" CHECK ("quantity_amount" ~ '^(0|[1-9][0-9]*)(\.[0-9]*[1-9])?$' and length(split_part("quantity_amount", '.', 1)) <= 29 and (position('.' in "quantity_amount") = 0 or length(split_part("quantity_amount", '.', 2)) <= 9)), + CONSTRAINT "inventory_stock_correction_source_evidence_text_ck" CHECK ("customer_configuration_id" = btrim("customer_configuration_id") and length("customer_configuration_id") between 1 and 300 and "issuer_backend_id" = btrim("issuer_backend_id") and length("issuer_backend_id") between 1 and 300 and "ordering_evidence_value" = btrim("ordering_evidence_value") and length("ordering_evidence_value") between 1 and 300 and "owner_evidence_ref" = btrim("owner_evidence_ref") and length("owner_evidence_ref") between 1 and 300 and "source_reference" = btrim("source_reference") and length("source_reference") between 1 and 300) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_correction_source_evidence_coverage" ( + "tenant_id" uuid, + "evidence_id" uuid, + "effect_id" uuid, + "relation" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_correction_source_evidence_coverage_pk" PRIMARY KEY("tenant_id","evidence_id","effect_id"), + CONSTRAINT "inventory_stock_correction_source_evidence_coverage_relation_ck" CHECK ("relation" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')), + CONSTRAINT "inventory_stock_correction_source_evidence_coverage_evidence_ck" CHECK ("owner_evidence_ref" = btrim("owner_evidence_ref") and length("owner_evidence_ref") between 1 and 300) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_coverage" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_correction_source_evidence_current" ( + "tenant_id" uuid, + "customer_configuration_id" text, + "authority_configuration_id" uuid, + "position_id" uuid, + "evidence_id" uuid NOT NULL, + "ordering_evidence_kind" text NOT NULL, + "ordering_evidence_value" text NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_correction_source_evidence_current_pk" PRIMARY KEY("tenant_id","customer_configuration_id","authority_configuration_id","position_id"), + CONSTRAINT "inventory_stock_correction_source_evidence_current_ordering_ck" CHECK ("ordering_evidence_kind" = 'OWNER_ORDER_KEY' and length(btrim("ordering_evidence_value")) between 1 and 300) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_current" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."stock_corrections" ( + "correction_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "action_invocation_id" uuid NOT NULL, + "principal_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "position_id" uuid NOT NULL, + "source_assertion_id" uuid, + "source_evidence_id" uuid, + "authority_configuration_id" uuid NOT NULL, + "evidence_kind" text NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "source_reference" text NOT NULL, + "business_observed_at" timestamp with time zone NOT NULL, + "expected_position_revision" integer NOT NULL, + "position_revision_after" integer NOT NULL, + "state" text NOT NULL, + "corrected_quantity_amount" numeric(38,9), + "reconciles_correction_id" uuid, + "coverage_evidence_json" jsonb NOT NULL, + "evaluated_material_effect_ids_json" jsonb NOT NULL, + "record_json" jsonb NOT NULL, + "applied_at" timestamp with time zone NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_stock_corrections_customer_configuration_ck" CHECK ("customer_configuration_id" = btrim("customer_configuration_id") and length("customer_configuration_id") between 1 and 300), + CONSTRAINT "inventory_stock_corrections_provenance_text_ck" CHECK (length(btrim("issuer_backend_id")) between 1 and 300 and length(btrim("owner_evidence_ref")) between 1 and 300 and length(btrim("source_reference")) between 1 and 300), + CONSTRAINT "inventory_stock_corrections_issuer_ck" CHECK ("issuer_backend_kind" in ('external_business_system', 'ontos_wms')), + CONSTRAINT "inventory_stock_corrections_evidence_ck" CHECK (("evidence_kind" = 'EXTERNAL_SOURCE_ASSERTION' and "issuer_backend_kind" = 'external_business_system' and "source_assertion_id" is not null and "source_evidence_id" is null) or ("evidence_kind" = 'ONTOS_WMS_OWNER_EVIDENCE' and "issuer_backend_kind" = 'ontos_wms' and "source_assertion_id" is null and "source_evidence_id" is not null)), + CONSTRAINT "inventory_stock_corrections_state_ck" CHECK ("state" in ('APPLIED', 'INDETERMINATE')), + CONSTRAINT "inventory_stock_corrections_quantity_ck" CHECK (("state" = 'APPLIED' and "corrected_quantity_amount" is not null and "corrected_quantity_amount" >= 0) or ("state" = 'INDETERMINATE' and "corrected_quantity_amount" is null)), + CONSTRAINT "inventory_stock_corrections_revision_ck" CHECK ("expected_position_revision" >= 1 and "position_revision_after" = "expected_position_revision" + 1 and "position_revision_after" <= 2147483647) +); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +ALTER TABLE "inventory"."backend_configurations" ADD COLUMN "stock_correction_capability" text;--> statement-breakpoint +DROP TRIGGER "inventory_backend_configurations_explicit_cutover_trg" ON "inventory"."backend_configurations";--> statement-breakpoint +UPDATE "inventory"."backend_configurations" +SET "stock_correction_capability" = CASE + WHEN "backend_kind" = 'ontos_wms' THEN 'SUPPORTED' + ELSE 'UNSUPPORTED' +END;--> statement-breakpoint +ALTER TABLE "inventory"."backend_configurations" ALTER COLUMN "stock_correction_capability" SET NOT NULL;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_correction_open_correction_uk" ON "inventory"."stock_correction_open_reconciliations" ("tenant_id","correction_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_correction_source_evidence_tenant_id_uk" ON "inventory"."stock_correction_source_evidence" ("tenant_id","evidence_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_correction_source_evidence_scope_id_uk" ON "inventory"."stock_correction_source_evidence" ("tenant_id","customer_configuration_id","authority_configuration_id","position_id","evidence_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_correction_source_evidence_stream_order_uk" ON "inventory"."stock_correction_source_evidence" ("tenant_id","customer_configuration_id","authority_configuration_id","position_id","ordering_evidence_kind","ordering_evidence_value");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_correction_source_evidence_source_reference_uk" ON "inventory"."stock_correction_source_evidence" ("tenant_id","customer_configuration_id","authority_configuration_id","position_id","source_reference");--> statement-breakpoint +CREATE INDEX "inventory_stock_correction_source_evidence_stream_observed_idx" ON "inventory"."stock_correction_source_evidence" ("tenant_id","customer_configuration_id","authority_configuration_id","position_id","business_observed_at");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_correction_source_evidence_current_evidence_uk" ON "inventory"."stock_correction_source_evidence_current" ("tenant_id","evidence_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_corrections_tenant_id_uk" ON "inventory"."stock_corrections" ("tenant_id","correction_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_corrections_assertion_uk" ON "inventory"."stock_corrections" ("tenant_id","source_assertion_id") WHERE "source_assertion_id" is not null;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_corrections_source_evidence_uk" ON "inventory"."stock_corrections" ("tenant_id","source_evidence_id") WHERE "source_evidence_id" is not null;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_corrections_reconciles_uk" ON "inventory"."stock_corrections" ("tenant_id","reconciles_correction_id") WHERE "reconciles_correction_id" is not null;--> statement-breakpoint +CREATE INDEX "inventory_stock_corrections_position_idx" ON "inventory"."stock_corrections" ("tenant_id","position_id","applied_at");--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_open_reconciliations" ADD CONSTRAINT "inventory_stock_correction_open_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_open_reconciliations" ADD CONSTRAINT "inventory_stock_correction_open_correction_fk" FOREIGN KEY ("tenant_id","correction_id") REFERENCES "inventory"."stock_corrections"("tenant_id","correction_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence" ADD CONSTRAINT "inventory_stock_correction_source_evidence_authority_fk" FOREIGN KEY ("tenant_id","authority_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence" ADD CONSTRAINT "inventory_stock_correction_source_evidence_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence" ADD CONSTRAINT "inventory_stock_correction_source_evidence_item_fk" FOREIGN KEY ("tenant_id","stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence" ADD CONSTRAINT "inventory_stock_correction_source_evidence_location_fk" FOREIGN KEY ("tenant_id","stock_location_id") REFERENCES "inventory"."stock_locations"("tenant_id","stock_location_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_coverage" ADD CONSTRAINT "inventory_stock_correction_source_evidence_coverage_evidence_fk" FOREIGN KEY ("tenant_id","evidence_id") REFERENCES "inventory"."stock_correction_source_evidence"("tenant_id","evidence_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_coverage" ADD CONSTRAINT "inventory_stock_correction_source_evidence_coverage_effect_fk" FOREIGN KEY ("tenant_id","effect_id") REFERENCES "inventory"."physical_stock_effects"("tenant_id","effect_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_current" ADD CONSTRAINT "inventory_stock_correction_source_evidence_current_evidence_fk" FOREIGN KEY ("tenant_id","customer_configuration_id","authority_configuration_id","position_id","evidence_id") REFERENCES "inventory"."stock_correction_source_evidence"("tenant_id","customer_configuration_id","authority_configuration_id","position_id","evidence_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" ADD CONSTRAINT "inventory_stock_corrections_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" ADD CONSTRAINT "inventory_stock_corrections_assertion_fk" FOREIGN KEY ("tenant_id","source_assertion_id") REFERENCES "inventory"."source_assertions"("tenant_id","assertion_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" ADD CONSTRAINT "inventory_stock_corrections_source_evidence_fk" FOREIGN KEY ("tenant_id","source_evidence_id") REFERENCES "inventory"."stock_correction_source_evidence"("tenant_id","evidence_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" ADD CONSTRAINT "inventory_stock_corrections_authority_fk" FOREIGN KEY ("tenant_id","authority_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" ADD CONSTRAINT "inventory_stock_corrections_reconciles_fk" FOREIGN KEY ("tenant_id","reconciles_correction_id") REFERENCES "inventory"."stock_corrections"("tenant_id","correction_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."backend_configurations" ADD CONSTRAINT "inventory_backend_configurations_stock_correction_capability_ck" CHECK ("stock_correction_capability" in ('SUPPORTED', 'UNSUPPORTED') and ("backend_kind" <> 'ontos_wms' or "stock_correction_capability" = 'SUPPORTED'));--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_open_tenant_select" ON "inventory"."stock_correction_open_reconciliations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_correction_open_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_open_tenant_insert" ON "inventory"."stock_correction_open_reconciliations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_correction_open_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_open_tenant_update" ON "inventory"."stock_correction_open_reconciliations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_correction_open_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_correction_open_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_open_tenant_delete" ON "inventory"."stock_correction_open_reconciliations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_correction_open_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_tenant_select" ON "inventory"."stock_correction_source_evidence" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_tenant_insert" ON "inventory"."stock_correction_source_evidence" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_correction_source_evidence"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_tenant_update" ON "inventory"."stock_correction_source_evidence" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_correction_source_evidence"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_tenant_delete" ON "inventory"."stock_correction_source_evidence" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_coverage_tenant_select" ON "inventory"."stock_correction_source_evidence_coverage" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_coverage_tenant_insert" ON "inventory"."stock_correction_source_evidence_coverage" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_correction_source_evidence_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_coverage_tenant_update" ON "inventory"."stock_correction_source_evidence_coverage" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_correction_source_evidence_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_coverage_tenant_delete" ON "inventory"."stock_correction_source_evidence_coverage" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence_coverage"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_current_tenant_select" ON "inventory"."stock_correction_source_evidence_current" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence_current"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_current_tenant_insert" ON "inventory"."stock_correction_source_evidence_current" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_correction_source_evidence_current"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_current_tenant_update" ON "inventory"."stock_correction_source_evidence_current" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence_current"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_correction_source_evidence_current"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_correction_source_evidence_current_tenant_delete" ON "inventory"."stock_correction_source_evidence_current" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_correction_source_evidence_current"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_corrections_tenant_select" ON "inventory"."stock_corrections" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."stock_corrections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_corrections_tenant_insert" ON "inventory"."stock_corrections" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."stock_corrections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_corrections_tenant_update" ON "inventory"."stock_corrections" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."stock_corrections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."stock_corrections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_stock_corrections_tenant_delete" ON "inventory"."stock_corrections" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."stock_corrections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_open_reconciliations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_coverage" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_correction_source_evidence_current" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."stock_corrections" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."reject_backend_configuration_mutation"() +RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp +AS $function$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION 'Inventory Backend configurations are durable and cannot be deleted' + USING ERRCODE = '55000'; + END IF; + RAISE EXCEPTION 'Inventory Backend identity, authority, Reservation capability, and Stock Correction capability require explicit cutover' + USING ERRCODE = '23514', CONSTRAINT = 'inventory_backend_configurations_explicit_cutover_ck'; +END; +$function$; +--> statement-breakpoint +CREATE TRIGGER "inventory_backend_configurations_explicit_cutover_trg" +BEFORE UPDATE OR DELETE ON "inventory"."backend_configurations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_backend_configuration_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_correction_source_evidence_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_TABLE_NAME = 'stock_correction_source_evidence' THEN + PERFORM 1 + FROM "inventory"."backend_configurations" AS authority + JOIN "inventory"."stock_positions" AS position + ON position.tenant_id = authority.tenant_id + AND position.owner_configuration_id = authority.configuration_id + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.authority_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = 'ontos_wms' + AND authority.backend_id = NEW.issuer_backend_id + AND authority.stock_correction_capability = 'SUPPORTED' + AND NEW.business_observed_at >= authority.selected_at + AND position.stock_position_id = NEW.position_id + AND position.customer_configuration_id = NEW.customer_configuration_id + AND position.stock_item_id = NEW.stock_item_id + AND position.stock_location_id = NEW.stock_location_id + AND position.stock_unit_module_id = NEW.unit_module_id + AND position.stock_unit_resource_id = NEW.unit_resource_id + AND position.stock_unit_resource_type = NEW.unit_resource_type + AND position.stock_unit_tenant_id = NEW.unit_tenant_id + AND position.lifecycle_state = 'CURRENT' + FOR KEY SHARE OF authority + FOR UPDATE OF position; + + IF NOT FOUND + OR pg_catalog.jsonb_typeof(NEW.evidence_json) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.evidence_json -> 'coverage') IS DISTINCT FROM 'array' + OR NEW.evidence_json ->> 'evidenceId' IS DISTINCT FROM NEW.evidence_id::text + OR NEW.evidence_json ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.evidence_json ->> 'factMeaning' IS DISTINCT FROM NEW.fact_meaning + OR NEW.evidence_json #>> '{issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.evidence_json #>> '{issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR (NEW.evidence_json ->> 'businessObservedAt')::timestamptz IS DISTINCT FROM NEW.business_observed_at + OR NEW.evidence_json #>> '{orderingEvidence,_tag}' IS DISTINCT FROM NEW.ordering_evidence_kind + OR NEW.evidence_json #>> '{orderingEvidence,key}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.evidence_json ->> 'ownerEvidenceRef' IS DISTINCT FROM NEW.owner_evidence_ref + OR NEW.evidence_json ->> 'sourceReference' IS DISTINCT FROM NEW.source_reference + OR (NEW.evidence_json ->> 'receivedAt')::timestamptz IS DISTINCT FROM NEW.received_at + OR NEW.evidence_json #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.evidence_json #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.evidence_json #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.evidence_json #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR NEW.evidence_json #>> '{stockItemRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.evidence_json #>> '{stockItemRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-item' + OR NEW.evidence_json #>> '{stockItemRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.evidence_json #>> '{stockItemRef,resourceId}' IS DISTINCT FROM NEW.stock_item_id::text + OR NEW.evidence_json #>> '{stockLocationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.evidence_json #>> '{stockLocationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-location' + OR NEW.evidence_json #>> '{stockLocationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.evidence_json #>> '{stockLocationRef,resourceId}' IS DISTINCT FROM NEW.stock_location_id::text + OR NEW.evidence_json #>> '{quantity,amount}' IS DISTINCT FROM NEW.quantity_amount + OR NEW.evidence_json #>> '{quantity,unitRef,moduleId}' IS DISTINCT FROM NEW.unit_module_id + OR NEW.evidence_json #>> '{quantity,unitRef,resourceId}' IS DISTINCT FROM NEW.unit_resource_id::text + OR NEW.evidence_json #>> '{quantity,unitRef,resourceType}' IS DISTINCT FROM NEW.unit_resource_type + OR NEW.evidence_json #>> '{quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.unit_tenant_id::text + OR NEW.evidence_json #>> '{authorityConfiguration,configurationId}' IS DISTINCT FROM NEW.authority_configuration_id::text + OR NEW.evidence_json #>> '{authorityConfiguration,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.evidence_json #>> '{authorityConfiguration,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.evidence_json #>> '{authorityConfiguration,selection,backend}' IS DISTINCT FROM 'ontos_wms' + OR NEW.evidence_json #>> '{authorityConfiguration,selection,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.evidence_json #>> '{authorityConfiguration,selection,stockCorrectionCapability}' IS DISTINCT FROM 'SUPPORTED' + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."backend_configurations" AS exact_authority + WHERE exact_authority.tenant_id = NEW.tenant_id + AND exact_authority.configuration_id = NEW.authority_configuration_id + AND (NEW.evidence_json #>> '{authorityConfiguration,selectedAt}')::timestamptz = exact_authority.selected_at + AND (NEW.evidence_json #>> '{authorityConfiguration,revision}')::integer = exact_authority.revision + AND NEW.evidence_json #>> '{authorityConfiguration,selection,exactReservationCapability}' + = exact_authority.exact_reservation_capability + AND NEW.evidence_json #>> '{authorityConfiguration,selection,stockCorrectionCapability}' + = exact_authority.stock_correction_capability + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_source_evidence_exact_scope_ck', + MESSAGE = 'OntOS WMS Stock Correction evidence must exactly match its selected authority, Current Position, and JSON provenance'; + END IF; + + RETURN NEW; + END IF; + + PERFORM 1 + FROM "inventory"."stock_correction_source_evidence" AS evidence + JOIN "inventory"."physical_stock_effects" AS effect + ON effect.tenant_id = evidence.tenant_id + AND effect.effect_id = NEW.effect_id + WHERE evidence.tenant_id = NEW.tenant_id + AND evidence.evidence_id = NEW.evidence_id + AND effect.state = 'APPLIED' + AND effect.position_id = evidence.position_id + AND effect.stock_item_id = evidence.stock_item_id + AND effect.stock_location_id = evidence.stock_location_id + AND effect.unit_resource_id = evidence.unit_resource_id + AND EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(evidence.evidence_json -> 'coverage') AS expected(entry) + WHERE expected.entry ->> 'evidenceId' = NEW.evidence_id::text + AND expected.entry ->> 'effectId' = NEW.effect_id::text + AND expected.entry ->> 'relation' = NEW.relation + AND expected.entry ->> 'ownerEvidenceRef' = NEW.owner_evidence_ref + ) + FOR KEY SHARE OF evidence, effect; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_source_evidence_coverage_exact_scope_ck', + MESSAGE = 'OntOS WMS Stock Correction coverage must exactly match one APPLIED physical effect and JSON entry'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_correction_source_evidence_exact_scope_trg" +BEFORE INSERT ON "inventory"."stock_correction_source_evidence" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_correction_source_evidence_exact_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_correction_source_evidence_coverage_exact_scope_trg" +BEFORE INSERT ON "inventory"."stock_correction_source_evidence_coverage" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_correction_source_evidence_exact_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_correction_source_evidence_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_source_evidence_append_only_ck', + MESSAGE = 'Stock Correction source evidence and coverage are append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_correction_source_evidence_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_correction_source_evidence" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_correction_source_evidence_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_correction_source_evidence_coverage_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_correction_source_evidence_coverage" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_correction_source_evidence_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_correction_source_evidence_coverage_complete"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(NEW.evidence_json -> 'coverage') AS expected(entry) + WHERE expected.entry ->> 'evidenceId' IS DISTINCT FROM NEW.evidence_id::text + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."stock_correction_source_evidence_coverage" AS stored + WHERE stored.tenant_id = NEW.tenant_id + AND stored.evidence_id = NEW.evidence_id + AND stored.effect_id::text = expected.entry ->> 'effectId' + AND stored.relation = expected.entry ->> 'relation' + AND stored.owner_evidence_ref = expected.entry ->> 'ownerEvidenceRef' + ) + ) OR EXISTS ( + SELECT 1 + FROM "inventory"."stock_correction_source_evidence_coverage" AS stored + WHERE stored.tenant_id = NEW.tenant_id + AND stored.evidence_id = NEW.evidence_id + AND NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(NEW.evidence_json -> 'coverage') AS expected(entry) + WHERE expected.entry ->> 'evidenceId' = stored.evidence_id::text + AND expected.entry ->> 'effectId' = stored.effect_id::text + AND expected.entry ->> 'relation' = stored.relation + AND expected.entry ->> 'ownerEvidenceRef' = stored.owner_evidence_ref + ) + ) OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."stock_correction_source_evidence_coverage" AS stored + WHERE stored.tenant_id = NEW.tenant_id + AND stored.evidence_id = NEW.evidence_id + ) IS DISTINCT FROM pg_catalog.jsonb_array_length(NEW.evidence_json -> 'coverage')::bigint + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_source_evidence_coverage_complete_ck', + MESSAGE = 'OntOS WMS Stock Correction coverage JSON and child rows must form an exact bijection'; + END IF; + + RETURN NULL; +END; +$$; +--> statement-breakpoint +CREATE CONSTRAINT TRIGGER "inventory_stock_correction_source_evidence_coverage_complete_trg" +AFTER INSERT ON "inventory"."stock_correction_source_evidence" +DEFERRABLE INITIALLY DEFERRED +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_correction_source_evidence_coverage_complete"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_correction_source_evidence_current_transition"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_source_evidence_current_transition_ck', + MESSAGE = 'Current OntOS WMS Stock Correction evidence may advance but cannot be deleted'; + END IF; + + PERFORM 1 + FROM "inventory"."stock_correction_source_evidence" AS evidence + WHERE evidence.tenant_id = NEW.tenant_id + AND evidence.customer_configuration_id = NEW.customer_configuration_id + AND evidence.authority_configuration_id = NEW.authority_configuration_id + AND evidence.position_id = NEW.position_id + AND evidence.evidence_id = NEW.evidence_id + AND evidence.ordering_evidence_kind = NEW.ordering_evidence_kind + AND evidence.ordering_evidence_value = NEW.ordering_evidence_value + FOR KEY SHARE; + + IF NOT FOUND + OR NEW.ordering_evidence_kind IS DISTINCT FROM 'OWNER_ORDER_KEY' + OR ( + TG_OP = 'UPDATE' + AND ( + NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.authority_configuration_id IS DISTINCT FROM OLD.authority_configuration_id + OR NEW.position_id IS DISTINCT FROM OLD.position_id + OR NEW.evidence_id IS NOT DISTINCT FROM OLD.evidence_id + OR NEW.ordering_evidence_value <= OLD.ordering_evidence_value + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_source_evidence_current_transition_ck', + MESSAGE = 'Current OntOS WMS Stock Correction evidence must point at the exact stream and advance lexicographically'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_correction_source_evidence_current_transition_trg" +BEFORE INSERT OR UPDATE OR DELETE ON "inventory"."stock_correction_source_evidence_current" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_correction_source_evidence_current_transition"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_correction_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + source_coverage jsonb; + source_quantity_amount text; + source_stock_item_id uuid; + source_stock_location_id uuid; + source_unit_module_id text; + source_unit_resource_id uuid; + source_unit_resource_type text; + source_unit_tenant_id uuid; + source_ordering_kind text; + source_ordering_value text; + expected_effect_ids jsonb; + excluded_effect_ids jsonb; + missing_effect_ids jsonb; + unknown_effect_ids jsonb; + expected_material_effect_ids jsonb; + expected_reason_code text; + position_on_hand_state text; + position_on_hand_amount numeric(38, 9); + position_on_hand_evidence_ref text; + position_on_hand_observed_at timestamptz; + position_owner_configuration_id uuid; + position_unit_module_id text; + position_unit_resource_id uuid; + position_unit_resource_type text; + position_unit_tenant_id uuid; +BEGIN + SELECT + position.on_hand_state, + position.on_hand_amount, + position.on_hand_evidence_ref, + position.on_hand_observed_at, + position.owner_configuration_id, + position.stock_unit_module_id, + position.stock_unit_resource_id, + position.stock_unit_resource_type, + position.stock_unit_tenant_id + INTO + position_on_hand_state, + position_on_hand_amount, + position_on_hand_evidence_ref, + position_on_hand_observed_at, + position_owner_configuration_id, + position_unit_module_id, + position_unit_resource_id, + position_unit_resource_type, + position_unit_tenant_id + FROM "inventory"."backend_configurations" AS authority + JOIN "inventory"."stock_positions" AS position + ON position.tenant_id = authority.tenant_id + AND position.owner_configuration_id = authority.configuration_id + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.authority_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = NEW.issuer_backend_kind + AND authority.backend_id = NEW.issuer_backend_id + AND authority.stock_correction_capability = 'SUPPORTED' + AND position.stock_position_id = NEW.position_id + AND position.customer_configuration_id = NEW.customer_configuration_id + AND position.lifecycle_state = 'CURRENT' + AND position.revision = NEW.expected_position_revision + FOR KEY SHARE OF authority + FOR UPDATE OF position; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_corrections_exact_scope_ck', + MESSAGE = 'Stock Correction must match its exact Current Position and selected supported authority'; + END IF; + + IF NEW.evidence_kind = 'EXTERNAL_SOURCE_ASSERTION' THEN + SELECT + assertion.assertion_json -> 'coverage', + assertion.quantity_amount, + assertion.stock_item_id, + assertion.stock_location_id, + assertion.unit_module_id, + assertion.unit_resource_id, + assertion.unit_resource_type, + assertion.unit_tenant_id, + assertion.ordering_evidence_kind, + assertion.ordering_evidence_value + INTO + source_coverage, + source_quantity_amount, + source_stock_item_id, + source_stock_location_id, + source_unit_module_id, + source_unit_resource_id, + source_unit_resource_type, + source_unit_tenant_id, + source_ordering_kind, + source_ordering_value + FROM "inventory"."source_assertions" AS assertion + WHERE assertion.tenant_id = NEW.tenant_id + AND assertion.assertion_id = NEW.source_assertion_id + AND assertion.customer_configuration_id = NEW.customer_configuration_id + AND assertion.authority_configuration_id = NEW.authority_configuration_id + AND assertion.issuer_backend_kind = NEW.issuer_backend_kind + AND assertion.issuer_backend_id = NEW.issuer_backend_id + AND assertion.issuer_authority = 'SELECTED_BACKEND' + AND assertion.position_id = NEW.position_id + AND assertion.owner_evidence_ref = NEW.owner_evidence_ref + AND assertion.source_reference = NEW.source_reference + AND assertion.business_observed_at = NEW.business_observed_at + AND EXISTS ( + SELECT 1 + FROM "inventory"."source_import_ledger" AS accepted + WHERE accepted.tenant_id = assertion.tenant_id + AND accepted.assertion_id = assertion.assertion_id + AND accepted.status = 'ACCEPTED' + ) + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."source_import_ledger" AS competing + WHERE competing.tenant_id = assertion.tenant_id + AND competing.customer_configuration_id = assertion.customer_configuration_id + AND competing.issuer_backend_kind = assertion.issuer_backend_kind + AND competing.issuer_backend_id = assertion.issuer_backend_id + AND competing.fact_meaning = assertion.fact_meaning + AND competing.position_id = assertion.position_id + AND competing.status = 'ACCEPTED' + AND ( + competing.ordering_evidence_kind <> assertion.ordering_evidence_kind + OR ( + assertion.ordering_evidence_kind = 'SOURCE_REVISION' + AND assertion.ordering_evidence_value <> competing.ordering_evidence_value + AND ( + assertion.ordering_evidence_value !~ '^[0-9]+$' + OR competing.ordering_evidence_value !~ '^[0-9]+$' + OR pg_catalog.length(pg_catalog.ltrim(assertion.ordering_evidence_value, '0')) + < pg_catalog.length(pg_catalog.ltrim(competing.ordering_evidence_value, '0')) + OR ( + pg_catalog.length(pg_catalog.ltrim(assertion.ordering_evidence_value, '0')) + = pg_catalog.length(pg_catalog.ltrim(competing.ordering_evidence_value, '0')) + AND pg_catalog.ltrim(assertion.ordering_evidence_value, '0') + < pg_catalog.ltrim(competing.ordering_evidence_value, '0') + ) + ) + ) + OR ( + assertion.ordering_evidence_kind = 'OWNER_ORDER_KEY' + AND assertion.ordering_evidence_value < competing.ordering_evidence_value + ) + ) + ) + FOR KEY SHARE; + ELSE + SELECT + evidence.evidence_json -> 'coverage', + evidence.quantity_amount, + evidence.stock_item_id, + evidence.stock_location_id, + evidence.unit_module_id, + evidence.unit_resource_id, + evidence.unit_resource_type, + evidence.unit_tenant_id, + evidence.ordering_evidence_kind, + evidence.ordering_evidence_value + INTO + source_coverage, + source_quantity_amount, + source_stock_item_id, + source_stock_location_id, + source_unit_module_id, + source_unit_resource_id, + source_unit_resource_type, + source_unit_tenant_id, + source_ordering_kind, + source_ordering_value + FROM "inventory"."stock_correction_source_evidence" AS evidence + JOIN "inventory"."stock_correction_source_evidence_current" AS current_evidence + ON current_evidence.tenant_id = evidence.tenant_id + AND current_evidence.customer_configuration_id = evidence.customer_configuration_id + AND current_evidence.authority_configuration_id = evidence.authority_configuration_id + AND current_evidence.position_id = evidence.position_id + AND current_evidence.evidence_id = evidence.evidence_id + AND current_evidence.ordering_evidence_kind = evidence.ordering_evidence_kind + AND current_evidence.ordering_evidence_value = evidence.ordering_evidence_value + WHERE evidence.tenant_id = NEW.tenant_id + AND evidence.evidence_id = NEW.source_evidence_id + AND evidence.customer_configuration_id = NEW.customer_configuration_id + AND evidence.authority_configuration_id = NEW.authority_configuration_id + AND evidence.position_id = NEW.position_id + AND evidence.issuer_backend_kind = NEW.issuer_backend_kind + AND evidence.issuer_backend_id = NEW.issuer_backend_id + AND evidence.owner_evidence_ref = NEW.owner_evidence_ref + AND evidence.source_reference = NEW.source_reference + AND evidence.business_observed_at = NEW.business_observed_at + FOR KEY SHARE OF evidence, current_evidence; + END IF; + + IF NOT FOUND + OR source_stock_item_id IS DISTINCT FROM ( + SELECT position.stock_item_id FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id AND position.stock_position_id = NEW.position_id + ) + OR source_stock_location_id IS DISTINCT FROM ( + SELECT position.stock_location_id FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id AND position.stock_position_id = NEW.position_id + ) + OR source_unit_module_id IS DISTINCT FROM position_unit_module_id + OR source_unit_resource_id IS DISTINCT FROM position_unit_resource_id + OR source_unit_resource_type IS DISTINCT FROM position_unit_resource_type + OR source_unit_tenant_id IS DISTINCT FROM position_unit_tenant_id + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_corrections_exact_scope_ck', + MESSAGE = 'Stock Correction evidence must be the exact Current external assertion or OntOS WMS owner head'; + END IF; + + SELECT coalesce( + pg_catalog.jsonb_agg(pg_catalog.to_jsonb(effect.effect_id::text) ORDER BY effect.requested_at, effect.effect_id), + '[]'::jsonb + ) + INTO expected_effect_ids + FROM "inventory"."physical_stock_effects" AS effect + WHERE effect.tenant_id = NEW.tenant_id + AND effect.position_id = NEW.position_id + AND effect.stock_item_id = source_stock_item_id + AND effect.stock_location_id = source_stock_location_id + AND effect.unit_resource_id = source_unit_resource_id + AND effect.state = 'APPLIED' + AND (effect.evidence_json ->> 'appliedAt')::timestamptz >= NEW.business_observed_at; + + SELECT + coalesce(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(evaluated.effect_id) ORDER BY evaluated.ordinality) + FILTER (WHERE coverage.relation IS NULL), '[]'::jsonb), + coalesce(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(evaluated.effect_id) ORDER BY evaluated.ordinality) + FILTER (WHERE coverage.relation = 'UNKNOWN'), '[]'::jsonb), + coalesce(pg_catalog.jsonb_agg(pg_catalog.to_jsonb(evaluated.effect_id) ORDER BY evaluated.ordinality) + FILTER (WHERE coverage.relation IN ('EXCLUDES', 'PREDATES')), '[]'::jsonb) + INTO missing_effect_ids, unknown_effect_ids, excluded_effect_ids + FROM pg_catalog.jsonb_array_elements_text(expected_effect_ids) WITH ORDINALITY AS evaluated(effect_id, ordinality) + LEFT JOIN LATERAL ( + SELECT entry ->> 'relation' AS relation + FROM pg_catalog.jsonb_array_elements(source_coverage) AS entry + WHERE entry ->> 'effectId' = evaluated.effect_id + ) AS coverage ON true; + + IF pg_catalog.jsonb_array_length(missing_effect_ids) > 0 THEN + expected_material_effect_ids := missing_effect_ids; + expected_reason_code := 'MATERIAL_EFFECT_COVERAGE_MISSING'; + ELSIF pg_catalog.jsonb_array_length(unknown_effect_ids) > 0 THEN + expected_material_effect_ids := unknown_effect_ids; + expected_reason_code := 'MATERIAL_EFFECT_COVERAGE_UNKNOWN'; + ELSIF pg_catalog.jsonb_array_length(excluded_effect_ids) > 0 THEN + expected_material_effect_ids := excluded_effect_ids; + expected_reason_code := 'MATERIAL_EFFECT_EXCLUDED_OR_PREDATED'; + ELSE + expected_material_effect_ids := '[]'::jsonb; + expected_reason_code := NULL; + END IF; + + IF pg_catalog.jsonb_typeof(NEW.record_json) IS DISTINCT FROM 'object' + OR NEW.coverage_evidence_json IS DISTINCT FROM source_coverage + OR NEW.evaluated_material_effect_ids_json IS DISTINCT FROM expected_effect_ids + OR NEW.record_json -> 'coverageEvidence' IS DISTINCT FROM NEW.coverage_evidence_json + OR NEW.record_json -> 'evaluatedMaterialEffectIds' IS DISTINCT FROM NEW.evaluated_material_effect_ids_json + OR NEW.record_json ->> '_tag' IS DISTINCT FROM NEW.state + OR NEW.record_json ->> 'correctionId' IS DISTINCT FROM NEW.correction_id::text + OR NEW.record_json ->> 'actionInvocationId' IS DISTINCT FROM NEW.action_invocation_id::text + OR NEW.record_json ->> 'principalId' IS DISTINCT FROM NEW.principal_id::text + OR NEW.record_json ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.record_json ->> 'evidenceKind' IS DISTINCT FROM NEW.evidence_kind + OR NEW.record_json ->> 'sourceAssertionId' IS DISTINCT FROM NEW.source_assertion_id::text + OR NEW.record_json ->> 'sourceEvidenceId' IS DISTINCT FROM NEW.source_evidence_id::text + OR NEW.record_json ->> 'sourceReference' IS DISTINCT FROM NEW.source_reference + OR NEW.record_json ->> 'ownerEvidenceRef' IS DISTINCT FROM NEW.owner_evidence_ref + OR NEW.record_json #>> '{issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.record_json #>> '{issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.record_json #>> '{sourceOrderingEvidence,_tag}' IS DISTINCT FROM source_ordering_kind + OR ( + source_ordering_kind = 'SOURCE_REVISION' + AND NEW.record_json #>> '{sourceOrderingEvidence,revision}' IS DISTINCT FROM source_ordering_value + ) + OR ( + source_ordering_kind = 'OWNER_ORDER_KEY' + AND NEW.record_json #>> '{sourceOrderingEvidence,key}' IS DISTINCT FROM source_ordering_value + ) + OR NEW.record_json #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.record_json #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.record_json #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.record_json #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR NEW.record_json #>> '{authorityConfigurationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.record_json #>> '{authorityConfigurationRef,resourceId}' IS DISTINCT FROM NEW.authority_configuration_id::text + OR (NEW.record_json ->> 'businessObservedAt')::timestamptz IS DISTINCT FROM NEW.business_observed_at + OR (NEW.record_json ->> 'expectedPositionRevision')::integer IS DISTINCT FROM NEW.expected_position_revision + OR (NEW.record_json ->> 'positionRevisionAfter')::integer IS DISTINCT FROM NEW.position_revision_after + OR (NEW.record_json ->> 'appliedAt')::timestamptz IS DISTINCT FROM NEW.applied_at + OR NEW.record_json ->> 'reconcilesCorrectionId' IS DISTINCT FROM NEW.reconciles_correction_id::text + OR NEW.record_json #>> '{previousOnHand,_tag}' IS DISTINCT FROM position_on_hand_state + OR NEW.record_json #>> '{previousOnHand,meaning}' IS DISTINCT FROM 'ON_HAND' + OR NEW.record_json #>> '{previousOnHand,ownerConfigurationRef,resourceId}' IS DISTINCT FROM position_owner_configuration_id::text + OR ( + position_on_hand_state = 'CURRENT' + AND ( + (NEW.record_json #>> '{previousOnHand,quantity,amount}')::numeric IS DISTINCT FROM position_on_hand_amount + OR NEW.record_json #>> '{previousOnHand,evidenceRef}' IS DISTINCT FROM position_on_hand_evidence_ref + OR (NEW.record_json #>> '{previousOnHand,observedAt}')::timestamptz IS DISTINCT FROM position_on_hand_observed_at + OR NEW.record_json #>> '{previousOnHand,quantity,unitRef,resourceId}' IS DISTINCT FROM position_unit_resource_id::text + ) + ) + OR ( + position_on_hand_state = 'STALE' + AND ( + (NEW.record_json #>> '{previousOnHand,lastKnownQuantity,amount}')::numeric IS DISTINCT FROM position_on_hand_amount + OR NEW.record_json #>> '{previousOnHand,evidenceRef}' IS DISTINCT FROM position_on_hand_evidence_ref + OR (NEW.record_json #>> '{previousOnHand,lastObservedAt}')::timestamptz IS DISTINCT FROM position_on_hand_observed_at + OR NEW.record_json #>> '{previousOnHand,lastKnownQuantity,unitRef,resourceId}' IS DISTINCT FROM position_unit_resource_id::text + ) + ) + OR ( + position_on_hand_state IN ('UNKNOWN', 'MISSING', 'INDETERMINATE') + AND NEW.record_json #>> '{previousOnHand,unitRef,resourceId}' IS DISTINCT FROM position_unit_resource_id::text + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_corrections_exact_scope_ck', + MESSAGE = 'Stock Correction JSON evidence must exactly match relational provenance and evaluated APPLIED effects'; + END IF; + + IF NEW.state = 'APPLIED' THEN + IF expected_reason_code IS NOT NULL + OR source_quantity_amount::numeric IS DISTINCT FROM NEW.corrected_quantity_amount + OR NEW.record_json #>> '{correctedQuantity,amount}' IS DISTINCT FROM source_quantity_amount + OR NEW.record_json #>> '{correctedQuantity,unitRef,resourceId}' IS DISTINCT FROM source_unit_resource_id::text + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_corrections_exact_scope_ck', + MESSAGE = 'Applied Stock Correction must preserve the exact source absolute Quantity and Unit'; + END IF; + ELSIF expected_reason_code IS NULL + OR NEW.record_json -> 'materialEffectIds' IS DISTINCT FROM expected_material_effect_ids + OR NEW.record_json ->> 'reasonCode' IS DISTINCT FROM expected_reason_code + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_corrections_exact_scope_ck', + MESSAGE = 'Indeterminate Stock Correction must retain the exact material-effect reconciliation evidence'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_corrections_exact_scope_trg" +BEFORE INSERT ON "inventory"."stock_corrections" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_correction_exact_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_stock_correction_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_corrections_append_only_ck', + MESSAGE = 'Stock Correction evidence is immutable'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_corrections_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."stock_corrections" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_stock_correction_mutation"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_stock_correction_open_transition"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + replacement_reconciles uuid; + replacement_state text; + replacement_position_id uuid; +BEGIN + IF TG_OP = 'DELETE' THEN + PERFORM 1 + FROM "inventory"."stock_corrections" AS replacement + WHERE replacement.tenant_id = OLD.tenant_id + AND replacement.position_id = OLD.position_id + AND replacement.reconciles_correction_id = OLD.correction_id + AND replacement.state = 'APPLIED' + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_open_transition_ck', + MESSAGE = 'An open Stock Correction marker may be deleted only after an APPLIED reconciliation'; + END IF; + RETURN OLD; + END IF; + + SELECT correction.state, correction.position_id, correction.reconciles_correction_id + INTO replacement_state, replacement_position_id, replacement_reconciles + FROM "inventory"."stock_corrections" AS correction + WHERE correction.tenant_id = NEW.tenant_id + AND correction.correction_id = NEW.correction_id + FOR KEY SHARE; + + IF NOT FOUND + OR replacement_state IS DISTINCT FROM 'INDETERMINATE' + OR replacement_position_id IS DISTINCT FROM NEW.position_id + OR (TG_OP = 'INSERT' AND replacement_reconciles IS NULL AND EXISTS ( + SELECT 1 FROM "inventory"."stock_correction_open_reconciliations" AS current_marker + WHERE current_marker.tenant_id = NEW.tenant_id AND current_marker.position_id = NEW.position_id + )) + OR (replacement_reconciles IS NOT NULL AND NOT EXISTS ( + SELECT 1 FROM "inventory"."stock_correction_open_reconciliations" AS current_marker + WHERE current_marker.tenant_id = NEW.tenant_id + AND current_marker.position_id = NEW.position_id + AND current_marker.correction_id = replacement_reconciles + )) + OR (TG_OP = 'UPDATE' AND ( + NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.position_id IS DISTINCT FROM OLD.position_id + OR replacement_reconciles IS DISTINCT FROM OLD.correction_id + )) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_stock_correction_open_transition_ck', + MESSAGE = 'Open Stock Correction marker transitions must form one exact INDETERMINATE reconciliation chain'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_stock_correction_open_transition_trg" +BEFORE INSERT OR UPDATE OR DELETE ON "inventory"."stock_correction_open_reconciliations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_stock_correction_open_transition"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_correction_source_evidence_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_correction_source_evidence_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_correction_source_evidence_coverage_complete"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_correction_source_evidence_current_transition"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_correction_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_stock_correction_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_stock_correction_open_transition"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924171606_inventory-stock-corrections/snapshot.json b/app/verticals/inventory/drizzle/20260924171606_inventory-stock-corrections/snapshot.json new file mode 100644 index 000000000..b9c62f799 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924171606_inventory-stock-corrections/snapshot.json @@ -0,0 +1,8471 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "efe22ed3-d7e0-4c2a-a9c9-e08737a32b27", + "prevIds": [ + "bde2f196-766f-46dc-ad18-903d5937eb0b" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} diff --git a/app/verticals/inventory/drizzle/20260924181709_inventory-reservation-create-effects/migration.sql b/app/verticals/inventory/drizzle/20260924181709_inventory-reservation-create-effects/migration.sql new file mode 100644 index 000000000..7902e2456 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924181709_inventory-reservation-create-effects/migration.sql @@ -0,0 +1,868 @@ +CREATE TABLE "inventory"."reservation_create_effects" ( + "effect_id" text, + "tenant_id" uuid, + "legal_entity_id" uuid NOT NULL, + "mutation_id" uuid NOT NULL, + "attempt_id" text NOT NULL, + "reservation_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "backend_configuration_id" uuid NOT NULL, + "backend_id" text NOT NULL, + "state" text DEFAULT 'REQUESTED' NOT NULL, + "request_json" jsonb NOT NULL, + "record_json" jsonb NOT NULL, + "requested_at" timestamp with time zone NOT NULL, + "source_action_invocation_id" uuid NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_create_effects_pkey" PRIMARY KEY("tenant_id","effect_id"), + CONSTRAINT "inventory_reservation_create_effects_identity_ck" CHECK (char_length(btrim("effect_id")) between 1 and 300 and char_length(btrim("attempt_id")) between 1 and 300 and char_length(btrim("customer_configuration_id")) between 1 and 300 and char_length(btrim("backend_id")) between 1 and 300), + CONSTRAINT "inventory_reservation_create_effects_state_ck" CHECK ("state" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_create_effects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_create_effects_attempt_uk" ON "inventory"."reservation_create_effects" ("tenant_id","attempt_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_create_effects_mutation_uk" ON "inventory"."reservation_create_effects" ("tenant_id","mutation_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_create_effects_reservation_uk" ON "inventory"."reservation_create_effects" ("tenant_id","reservation_id");--> statement-breakpoint +CREATE INDEX "inventory_reservation_create_effects_state_idx" ON "inventory"."reservation_create_effects" ("tenant_id","state","updated_at");--> statement-breakpoint +ALTER TABLE "inventory"."reservation_create_effects" ADD CONSTRAINT "inventory_reservation_create_effects_backend_configuration_fk" FOREIGN KEY ("tenant_id","backend_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_reservation_create_effects_tenant_select" ON "inventory"."reservation_create_effects" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_create_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_create_effects_tenant_insert" ON "inventory"."reservation_create_effects" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_create_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_create_effects_tenant_update" ON "inventory"."reservation_create_effects" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_create_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_create_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_create_effects_tenant_delete" ON "inventory"."reservation_create_effects" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_create_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_create_effects" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_create_effect_transition"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_transition_ck', + MESSAGE = 'Inventory Reservation create-effect evidence cannot be deleted'; + END IF; + + IF pg_catalog.jsonb_typeof(NEW.request_json) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.record_json) IS DISTINCT FROM 'object' + OR NEW.record_json -> 'request' IS DISTINCT FROM NEW.request_json + OR NEW.record_json ->> '_tag' IS DISTINCT FROM NEW.state + OR NEW.request_json ->> 'effectId' IS DISTINCT FROM NEW.effect_id + OR NEW.request_json ->> 'legalEntityId' IS DISTINCT FROM NEW.legal_entity_id::text + OR NEW.request_json ->> 'mutationId' IS DISTINCT FROM NEW.mutation_id::text + OR NEW.request_json ->> 'sourceActionInvocationId' IS DISTINCT FROM NEW.source_action_invocation_id::text + OR (NEW.request_json ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + OR NEW.request_json #>> '{authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{authority,configurationId}' IS DISTINCT FROM NEW.backend_configuration_id::text + OR NEW.request_json #>> '{authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.request_json #>> '{authority,selection,backendId}' IS DISTINCT FROM NEW.backend_id + OR NEW.request_json #>> '{reservation,origin,kind}' IS DISTINCT FROM 'ORDER_COMMITMENT_ATTEMPT' + OR NEW.request_json #>> '{reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.request_json #>> '{reservation,ref,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.request_json #>> '{reservation,ref,resourceType}' IS DISTINCT FROM 'commerce.inventory.inventory-reservation' + OR NEW.request_json #>> '{reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.request_json #>> '{reservation,ref,resourceId}' IS DISTINCT FROM NEW.reservation_id::text + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.backend_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_id = NEW.backend_id + AND NEW.request_json #>> '{authority,selection,backend}' = authority.backend_kind + AND NEW.request_json #>> '{authority,selection,exactReservationCapability}' + = authority.exact_reservation_capability + AND NEW.request_json #>> '{authority,selection,stockCorrectionCapability}' + = authority.stock_correction_capability + AND (NEW.request_json #>> '{authority,selectedAt}')::timestamptz = authority.selected_at + AND (NEW.request_json #>> '{authority,revision}')::integer = authority.revision + ) + OR ( + NEW.state = 'ESTABLISHED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.record_json)) <> 4 + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.record_json ->> 'ownerEvidenceRef')), 0) + NOT BETWEEN 1 AND 300 + OR pg_catalog.jsonb_typeof(NEW.record_json -> 'reservation') IS DISTINCT FROM 'object' + OR NEW.record_json #> '{reservation,authority}' IS DISTINCT FROM NEW.request_json -> 'authority' + OR NEW.record_json #> '{reservation,origin}' IS DISTINCT FROM NEW.request_json #> '{reservation,origin}' + OR NEW.record_json #> '{reservation,ref}' IS DISTINCT FROM NEW.request_json #> '{reservation,ref}' + OR NEW.record_json #> '{reservation,requirements}' + IS DISTINCT FROM NEW.request_json #> '{reservation,requirements}' + OR NEW.record_json #>> '{reservation,lifecycleMeaning}' IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + OR (NEW.record_json #>> '{reservation,establishedAt}')::timestamptz IS NULL + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligations" AS obligation + WHERE obligation.obligation_id = NEW.reservation_id + AND obligation.tenant_id = NEW.tenant_id + AND obligation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND obligation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND obligation.attempt_id = NEW.attempt_id + AND obligation.accepted_order_id IS NULL + AND obligation.order_evidence_ref IS NULL + AND obligation.order_evidence_observed_at IS NULL + AND obligation.source_system IS NULL + AND obligation.source_order_id IS NULL + AND obligation.source_obligation_id IS NULL + AND obligation.customer_configuration_id = NEW.customer_configuration_id + AND obligation.owner_configuration_id = NEW.backend_configuration_id + AND obligation.authority_backend_kind = NEW.request_json #>> '{authority,selection,backend}' + AND obligation.authority_backend_id = NEW.backend_id + AND obligation.authority_selected_at = (NEW.request_json #>> '{authority,selectedAt}')::timestamptz + AND obligation.authority_revision = (NEW.request_json #>> '{authority,revision}')::integer + AND obligation.established_at = (NEW.record_json #>> '{reservation,establishedAt}')::timestamptz + ) + OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = NEW.tenant_id + AND stored_requirement.obligation_id = NEW.reservation_id + ) IS DISTINCT FROM pg_catalog.jsonb_array_length( + NEW.record_json #> '{reservation,requirements}' + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.record_json #> '{reservation,requirements}' + ) AS expected_requirement(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = NEW.tenant_id + AND stored_requirement.obligation_id = NEW.reservation_id + AND stored_requirement.purchase_demand_occurrence_id + = expected_requirement.entry ->> 'purchaseDemandOccurrenceId' + AND stored_requirement.binding_id + = (expected_requirement.entry #>> '{bindingRef,resourceId}')::uuid + AND stored_requirement.catalog_selection = expected_requirement.entry -> 'catalogSelection' + AND stored_requirement.exact_selection_meaning_id + = expected_requirement.entry #>> '{exactSelectionMeaning,id}' + AND stored_requirement.exact_selection_meaning_kind + = expected_requirement.entry #>> '{exactSelectionMeaning,kind}' + AND stored_requirement.stock_item_id + = (expected_requirement.entry #>> '{stockItem,stockItemRef,resourceId}')::uuid + AND stored_requirement.stock_item_revision + = (expected_requirement.entry #>> '{stockItem,revision}')::integer + AND stored_requirement.stock_item_snapshot = expected_requirement.entry -> 'stockItem' + AND stored_requirement.requested_amount = (expected_requirement.entry ->> 'quantity')::numeric + AND stored_requirement.unit_module_id = expected_requirement.entry #>> '{unitRef,moduleId}' + AND stored_requirement.unit_resource_id + = (expected_requirement.entry #>> '{unitRef,resourceId}')::uuid + AND stored_requirement.unit_resource_type = expected_requirement.entry #>> '{unitRef,resourceType}' + AND stored_requirement.unit_tenant_id + = (expected_requirement.entry #>> '{unitRef,tenantId}')::uuid + ) + ) + OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = NEW.tenant_id + AND stored_allocation.obligation_id = NEW.reservation_id + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.record_json #> '{reservation,requirements}' + ) AS expected_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + expected_requirement.entry -> 'allocations' + ) AS expected_allocation(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.record_json #> '{reservation,requirements}' + ) AS expected_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + expected_requirement.entry -> 'allocations' + ) AS expected_allocation(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = NEW.tenant_id + AND stored_allocation.obligation_id = NEW.reservation_id + AND stored_allocation.allocation_id = expected_allocation.entry ->> 'allocationId' + AND stored_allocation.purchase_demand_occurrence_id + = expected_requirement.entry ->> 'purchaseDemandOccurrenceId' + AND stored_allocation.stock_item_id + = (expected_allocation.entry #>> '{stockItemRef,resourceId}')::uuid + AND stored_allocation.stock_position_id + = (expected_allocation.entry #>> '{positionRef,resourceId}')::uuid + AND stored_allocation.allocated_amount + = (expected_allocation.entry #>> '{quantity,amount}')::numeric + AND stored_allocation.unit_module_id + = expected_allocation.entry #>> '{quantity,unitRef,moduleId}' + AND stored_allocation.unit_resource_id + = (expected_allocation.entry #>> '{quantity,unitRef,resourceId}')::uuid + AND stored_allocation.unit_resource_type + = expected_allocation.entry #>> '{quantity,unitRef,resourceType}' + AND stored_allocation.unit_tenant_id + = (expected_allocation.entry #>> '{quantity,unitRef,tenantId}')::uuid + ) + ) + ) + ) + OR ( + NEW.state = 'RECONCILIATION_REQUIRED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.record_json)) <> 5 + OR pg_catalog.jsonb_typeof(NEW.record_json -> 'constrainedAllocations') IS DISTINCT FROM 'array' + OR (NEW.record_json ->> 'observedAt')::timestamptz IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.record_json ->> 'ownerEvidenceRef')), 0) + NOT BETWEEN 1 AND 300 + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(NEW.record_json -> 'constrainedAllocations') AS observed(entry) + ) < 1 + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(NEW.record_json -> 'constrainedAllocations') AS observed(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT observed.entry ->> 'allocationId') + FROM pg_catalog.jsonb_array_elements(NEW.record_json -> 'constrainedAllocations') AS observed(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(NEW.record_json -> 'constrainedAllocations') AS observed(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + WHERE planned_allocation.entry ->> 'allocationId' = observed.entry ->> 'allocationId' + AND planned_allocation.entry -> 'stockItemRef' = observed.entry -> 'stockItemRef' + AND planned_allocation.entry -> 'positionRef' = observed.entry -> 'stockPositionRef' + AND planned_allocation.entry #> '{quantity,unitRef}' = observed.entry #> '{quantity,unitRef}' + AND (observed.entry #>> '{quantity,amount}')::numeric > 0 + AND (observed.entry #>> '{quantity,amount}')::numeric + <= (planned_allocation.entry #>> '{quantity,amount}')::numeric + ) + ) + ) + ) + OR ( + NEW.state = 'INDETERMINATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.record_json)) <> 5 + OR pg_catalog.jsonb_typeof(NEW.record_json -> 'possibleConstrainedAllocations') IS DISTINCT FROM 'array' + OR (NEW.record_json ->> 'observedAt')::timestamptz IS NULL + OR NEW.record_json ->> 'reason' IS NULL + OR NEW.record_json ->> 'reason' NOT IN ( + 'DISPATCH_PENDING', + 'BACKEND_OUTCOME_UNKNOWN', + 'EVIDENCE_UNVERIFIABLE', + 'AUTHORITY_UNAVAILABLE' + ) + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.record_json -> 'possibleConstrainedAllocations' + ) AS possible(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + ) + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.record_json -> 'possibleConstrainedAllocations' + ) AS possible(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT possible.entry ->> 'allocationId') + FROM pg_catalog.jsonb_array_elements( + NEW.record_json -> 'possibleConstrainedAllocations' + ) AS possible(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.record_json -> 'possibleConstrainedAllocations' + ) AS possible(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + WHERE planned_allocation.entry ->> 'allocationId' = possible.entry ->> 'allocationId' + AND planned_allocation.entry -> 'stockItemRef' = possible.entry -> 'stockItemRef' + AND planned_allocation.entry -> 'positionRef' = possible.entry -> 'stockPositionRef' + AND planned_allocation.entry -> 'quantity' = possible.entry -> 'quantity' + ) + ) + ) + ) + OR ( + NEW.state = 'RESOLVED_NO_RESERVATION' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.record_json)) <> 5 + OR NEW.record_json -> 'effectAbsenceProven' IS DISTINCT FROM 'true'::jsonb + OR NEW.record_json ->> 'reason' IS NULL + OR NEW.record_json ->> 'reason' NOT IN ('INSUFFICIENT_STOCK', 'BACKEND_REJECTED') + OR (NEW.record_json ->> 'observedAt')::timestamptz IS NULL + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_transition_ck', + MESSAGE = 'Inventory Reservation create-effect JSON must exactly match immutable relational request identity'; + END IF; + + IF TG_OP = 'INSERT' THEN + IF NEW.state IS DISTINCT FROM 'REQUESTED' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.record_json)) <> 2 + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_transition_ck', + MESSAGE = 'Inventory Reservation create effects must begin in REQUESTED state'; + END IF; + RETURN NEW; + END IF; + + IF NEW.effect_id IS DISTINCT FROM OLD.effect_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.legal_entity_id IS DISTINCT FROM OLD.legal_entity_id + OR NEW.mutation_id IS DISTINCT FROM OLD.mutation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.backend_configuration_id IS DISTINCT FROM OLD.backend_configuration_id + OR NEW.backend_id IS DISTINCT FROM OLD.backend_id + OR NEW.request_json IS DISTINCT FROM OLD.request_json + OR NEW.requested_at IS DISTINCT FROM OLD.requested_at + OR NEW.source_action_invocation_id IS DISTINCT FROM OLD.source_action_invocation_id + OR ( + OLD.state = 'REQUESTED' + AND NEW.state NOT IN ( + 'ESTABLISHED', + 'RECONCILIATION_REQUIRED', + 'INDETERMINATE', + 'RESOLVED_NO_RESERVATION' + ) + ) + OR ( + OLD.state IN ('RECONCILIATION_REQUIRED', 'INDETERMINATE') + AND NEW.state NOT IN ( + 'ESTABLISHED', + 'RECONCILIATION_REQUIRED', + 'INDETERMINATE', + 'RESOLVED_NO_RESERVATION' + ) + ) + OR ( + OLD.state = 'ESTABLISHED' + AND ( + NEW.state IS DISTINCT FROM 'ESTABLISHED' + OR NEW.record_json IS DISTINCT FROM OLD.record_json + ) + ) + OR ( + OLD.state = 'RESOLVED_NO_RESERVATION' + AND ( + NEW.state IS DISTINCT FROM 'RESOLVED_NO_RESERVATION' + OR NEW.record_json IS DISTINCT FROM OLD.record_json + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_transition_ck', + MESSAGE = 'Inventory Reservation create-effect transition is invalid or mutates immutable request identity'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_create_effects_transition_trg" +BEFORE INSERT OR UPDATE OR DELETE ON "inventory"."reservation_create_effects" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_create_effect_transition"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_create_effect_transition"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE FUNCTION "inventory"."read_reservation_create_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + durable_record jsonb; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory Reservation create-effect worker scope mismatch'; + END IF; + + SELECT effect.record_json + INTO durable_record + FROM "inventory"."reservation_create_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + RETURN QUERY SELECT durable_record; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."finalize_reservation_create_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text, + p_terminal jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + allocation jsonb; + current_effect "inventory"."reservation_create_effects"%ROWTYPE; + expected_allocation_count integer := 0; + requirement jsonb; + stored_count integer; + stored_obligation "inventory"."obligations"%ROWTYPE; + terminal_tag text; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory Reservation create-effect worker scope mismatch'; + END IF; + + SELECT effect.* + INTO current_effect + FROM "inventory"."reservation_create_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + terminal_tag := p_terminal ->> '_tag'; + IF pg_catalog.jsonb_typeof(p_terminal) IS DISTINCT FROM 'object' + OR terminal_tag IS NULL + OR terminal_tag NOT IN ( + 'ESTABLISHED', + 'RECONCILIATION_REQUIRED', + 'INDETERMINATE', + 'RESOLVED_NO_RESERVATION' + ) + OR p_terminal -> 'request' IS DISTINCT FROM current_effect.request_json + OR p_terminal #>> '{request,effectId}' IS DISTINCT FROM current_effect.effect_id + OR p_terminal #>> '{request,legalEntityId}' IS DISTINCT FROM current_effect.legal_entity_id::text + OR p_terminal #>> '{request,mutationId}' IS DISTINCT FROM current_effect.mutation_id::text + OR p_terminal #>> '{request,sourceActionInvocationId}' + IS DISTINCT FROM current_effect.source_action_invocation_id::text + OR p_terminal #>> '{request,authority,tenantId}' IS DISTINCT FROM current_effect.tenant_id::text + OR p_terminal #>> '{request,authority,configurationId}' + IS DISTINCT FROM current_effect.backend_configuration_id::text + OR p_terminal #>> '{request,reservation,ref,resourceId}' IS DISTINCT FROM current_effect.reservation_id::text + OR p_terminal #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM current_effect.attempt_id + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Inventory Reservation create-effect terminal payload must exactly match its durable request'; + END IF; + + IF terminal_tag = 'ESTABLISHED' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 4 + OR coalesce(pg_catalog.length(pg_catalog.btrim(p_terminal ->> 'ownerEvidenceRef')), 0) NOT BETWEEN 1 AND 300 + OR pg_catalog.jsonb_typeof(p_terminal -> 'reservation') IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal -> 'reservation')) <> 6 + OR p_terminal #> '{reservation,authority}' IS DISTINCT FROM current_effect.request_json -> 'authority' + OR p_terminal #> '{reservation,origin}' IS DISTINCT FROM current_effect.request_json #> '{reservation,origin}' + OR p_terminal #> '{reservation,ref}' IS DISTINCT FROM current_effect.request_json #> '{reservation,ref}' + OR p_terminal #> '{reservation,requirements}' + IS DISTINCT FROM current_effect.request_json #> '{reservation,requirements}' + OR p_terminal #>> '{reservation,lifecycleMeaning}' IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + OR (p_terminal #>> '{reservation,establishedAt}')::timestamptz IS NULL + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Established Inventory Reservation must exactly preserve the durable request and allocation plan'; + END IF; + ELSIF terminal_tag = 'RECONCILIATION_REQUIRED' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 5 + OR pg_catalog.jsonb_typeof(p_terminal -> 'constrainedAllocations') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_terminal -> 'constrainedAllocations') < 1 + OR (p_terminal ->> 'observedAt')::timestamptz IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(p_terminal ->> 'ownerEvidenceRef')), 0) NOT BETWEEN 1 AND 300 + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'constrainedAllocations') AS observed(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT observed.entry ->> 'allocationId') + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'constrainedAllocations') AS observed(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'constrainedAllocations') AS observed(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + WHERE planned_allocation.entry ->> 'allocationId' = observed.entry ->> 'allocationId' + AND planned_allocation.entry -> 'stockItemRef' = observed.entry -> 'stockItemRef' + AND planned_allocation.entry -> 'positionRef' = observed.entry -> 'stockPositionRef' + AND planned_allocation.entry #> '{quantity,unitRef}' = observed.entry #> '{quantity,unitRef}' + AND (observed.entry #>> '{quantity,amount}')::numeric > 0 + AND (observed.entry #>> '{quantity,amount}')::numeric + <= (planned_allocation.entry #>> '{quantity,amount}')::numeric + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Reconciliation-required Inventory Reservation evidence must remain within the durable plan'; + END IF; + ELSIF terminal_tag = 'INDETERMINATE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 5 + OR pg_catalog.jsonb_typeof(p_terminal -> 'possibleConstrainedAllocations') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_terminal -> 'possibleConstrainedAllocations') < 1 + OR (p_terminal ->> 'observedAt')::timestamptz IS NULL + OR p_terminal ->> 'reason' IS NULL + OR p_terminal ->> 'reason' NOT IN ( + 'DISPATCH_PENDING', + 'BACKEND_OUTCOME_UNKNOWN', + 'EVIDENCE_UNVERIFIABLE', + 'AUTHORITY_UNAVAILABLE' + ) + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + ) + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT possible.entry ->> 'allocationId') + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + WHERE planned_allocation.entry ->> 'allocationId' = possible.entry ->> 'allocationId' + AND planned_allocation.entry -> 'stockItemRef' = possible.entry -> 'stockItemRef' + AND planned_allocation.entry -> 'positionRef' = possible.entry -> 'stockPositionRef' + AND planned_allocation.entry -> 'quantity' = possible.entry -> 'quantity' + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Indeterminate Inventory Reservation evidence must retain bounded typed uncertainty'; + END IF; + ELSE + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 5 + OR p_terminal -> 'effectAbsenceProven' IS DISTINCT FROM 'true'::jsonb + OR (p_terminal ->> 'observedAt')::timestamptz IS NULL + OR p_terminal ->> 'reason' IS NULL + OR p_terminal ->> 'reason' NOT IN ('INSUFFICIENT_STOCK', 'BACKEND_REJECTED') + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Resolved Inventory Reservation absence must retain authoritative no-effect proof'; + END IF; + END IF; + + IF current_effect.state IN ('ESTABLISHED', 'RESOLVED_NO_RESERVATION') THEN + IF current_effect.record_json IS DISTINCT FROM p_terminal THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_transition_ck', + MESSAGE = 'Terminal Inventory Reservation create-effect evidence cannot be replaced'; + END IF; + RETURN QUERY SELECT current_effect.record_json; + RETURN; + END IF; + + IF terminal_tag = 'ESTABLISHED' THEN + INSERT INTO "inventory"."obligations" ( + obligation_id, + tenant_id, + origin_kind, + lifecycle_meaning, + attempt_id, + accepted_order_id, + order_evidence_ref, + order_evidence_observed_at, + source_system, + source_order_id, + source_obligation_id, + customer_configuration_id, + owner_configuration_id, + authority_backend_kind, + authority_backend_id, + authority_selected_at, + authority_revision, + established_at + ) VALUES ( + (p_terminal #>> '{reservation,ref,resourceId}')::uuid, + p_tenant_id, + 'ORDER_COMMITMENT_ATTEMPT', + 'PROVISIONAL_RESERVATION', + current_effect.attempt_id, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + current_effect.customer_configuration_id, + current_effect.backend_configuration_id, + current_effect.request_json #>> '{authority,selection,backend}', + current_effect.backend_id, + (current_effect.request_json #>> '{authority,selectedAt}')::timestamptz, + (current_effect.request_json #>> '{authority,revision}')::integer, + (p_terminal #>> '{reservation,establishedAt}')::timestamptz + ) + ON CONFLICT DO NOTHING; + + SELECT obligation.* + INTO stored_obligation + FROM "inventory"."obligations" AS obligation + WHERE obligation.obligation_id = current_effect.reservation_id + FOR UPDATE; + + IF NOT FOUND + OR stored_obligation.tenant_id IS DISTINCT FROM p_tenant_id + OR stored_obligation.origin_kind IS DISTINCT FROM 'ORDER_COMMITMENT_ATTEMPT' + OR stored_obligation.lifecycle_meaning IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + OR stored_obligation.attempt_id IS DISTINCT FROM current_effect.attempt_id + OR stored_obligation.accepted_order_id IS NOT NULL + OR stored_obligation.order_evidence_ref IS NOT NULL + OR stored_obligation.order_evidence_observed_at IS NOT NULL + OR stored_obligation.source_system IS NOT NULL + OR stored_obligation.source_order_id IS NOT NULL + OR stored_obligation.source_obligation_id IS NOT NULL + OR stored_obligation.customer_configuration_id IS DISTINCT FROM current_effect.customer_configuration_id + OR stored_obligation.owner_configuration_id IS DISTINCT FROM current_effect.backend_configuration_id + OR stored_obligation.authority_backend_kind + IS DISTINCT FROM current_effect.request_json #>> '{authority,selection,backend}' + OR stored_obligation.authority_backend_id IS DISTINCT FROM current_effect.backend_id + OR stored_obligation.authority_selected_at + IS DISTINCT FROM (current_effect.request_json #>> '{authority,selectedAt}')::timestamptz + OR stored_obligation.authority_revision + IS DISTINCT FROM (current_effect.request_json #>> '{authority,revision}')::integer + OR stored_obligation.established_at + IS DISTINCT FROM (p_terminal #>> '{reservation,establishedAt}')::timestamptz + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation identity is already bound to different obligation evidence'; + END IF; + + FOR requirement IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(p_terminal #> '{reservation,requirements}') AS required(entry) + LOOP + INSERT INTO "inventory"."obligation_requirements" ( + tenant_id, + obligation_id, + purchase_demand_occurrence_id, + binding_id, + catalog_selection, + exact_selection_meaning_id, + exact_selection_meaning_kind, + stock_item_id, + stock_item_revision, + stock_item_snapshot, + requested_amount, + unit_module_id, + unit_resource_id, + unit_resource_type, + unit_tenant_id + ) VALUES ( + p_tenant_id, + current_effect.reservation_id, + requirement ->> 'purchaseDemandOccurrenceId', + (requirement #>> '{bindingRef,resourceId}')::uuid, + requirement -> 'catalogSelection', + requirement #>> '{exactSelectionMeaning,id}', + requirement #>> '{exactSelectionMeaning,kind}', + (requirement #>> '{stockItem,stockItemRef,resourceId}')::uuid, + (requirement #>> '{stockItem,revision}')::integer, + requirement -> 'stockItem', + (requirement ->> 'quantity')::numeric, + requirement #>> '{unitRef,moduleId}', + (requirement #>> '{unitRef,resourceId}')::uuid, + requirement #>> '{unitRef,resourceType}', + (requirement #>> '{unitRef,tenantId}')::uuid + ) + ON CONFLICT DO NOTHING; + + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = p_tenant_id + AND stored_requirement.obligation_id = current_effect.reservation_id + AND stored_requirement.purchase_demand_occurrence_id = requirement ->> 'purchaseDemandOccurrenceId' + AND stored_requirement.binding_id = (requirement #>> '{bindingRef,resourceId}')::uuid + AND stored_requirement.catalog_selection = requirement -> 'catalogSelection' + AND stored_requirement.exact_selection_meaning_id = requirement #>> '{exactSelectionMeaning,id}' + AND stored_requirement.exact_selection_meaning_kind = requirement #>> '{exactSelectionMeaning,kind}' + AND stored_requirement.stock_item_id = (requirement #>> '{stockItem,stockItemRef,resourceId}')::uuid + AND stored_requirement.stock_item_revision = (requirement #>> '{stockItem,revision}')::integer + AND stored_requirement.stock_item_snapshot = requirement -> 'stockItem' + AND stored_requirement.requested_amount = (requirement ->> 'quantity')::numeric + AND stored_requirement.unit_module_id = requirement #>> '{unitRef,moduleId}' + AND stored_requirement.unit_resource_id = (requirement #>> '{unitRef,resourceId}')::uuid + AND stored_requirement.unit_resource_type = requirement #>> '{unitRef,resourceType}' + AND stored_requirement.unit_tenant_id = (requirement #>> '{unitRef,tenantId}')::uuid + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation requirement identity is already bound to different evidence'; + END IF; + + FOR allocation IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(requirement -> 'allocations') AS allocated(entry) + LOOP + expected_allocation_count := expected_allocation_count + 1; + INSERT INTO "inventory"."obligation_allocations" ( + tenant_id, + obligation_id, + allocation_id, + purchase_demand_occurrence_id, + stock_item_id, + stock_position_id, + allocated_amount, + unit_module_id, + unit_resource_id, + unit_resource_type, + unit_tenant_id + ) VALUES ( + p_tenant_id, + current_effect.reservation_id, + allocation ->> 'allocationId', + requirement ->> 'purchaseDemandOccurrenceId', + (allocation #>> '{stockItemRef,resourceId}')::uuid, + (allocation #>> '{positionRef,resourceId}')::uuid, + (allocation #>> '{quantity,amount}')::numeric, + allocation #>> '{quantity,unitRef,moduleId}', + (allocation #>> '{quantity,unitRef,resourceId}')::uuid, + allocation #>> '{quantity,unitRef,resourceType}', + (allocation #>> '{quantity,unitRef,tenantId}')::uuid + ) + ON CONFLICT DO NOTHING; + + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = p_tenant_id + AND stored_allocation.obligation_id = current_effect.reservation_id + AND stored_allocation.allocation_id = allocation ->> 'allocationId' + AND stored_allocation.purchase_demand_occurrence_id = requirement ->> 'purchaseDemandOccurrenceId' + AND stored_allocation.stock_item_id = (allocation #>> '{stockItemRef,resourceId}')::uuid + AND stored_allocation.stock_position_id = (allocation #>> '{positionRef,resourceId}')::uuid + AND stored_allocation.allocated_amount = (allocation #>> '{quantity,amount}')::numeric + AND stored_allocation.unit_module_id = allocation #>> '{quantity,unitRef,moduleId}' + AND stored_allocation.unit_resource_id = (allocation #>> '{quantity,unitRef,resourceId}')::uuid + AND stored_allocation.unit_resource_type = allocation #>> '{quantity,unitRef,resourceType}' + AND stored_allocation.unit_tenant_id = (allocation #>> '{quantity,unitRef,tenantId}')::uuid + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation allocation identity is already bound to different evidence'; + END IF; + END LOOP; + END LOOP; + + SELECT pg_catalog.count(*)::integer + INTO stored_count + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = p_tenant_id + AND stored_requirement.obligation_id = current_effect.reservation_id; + IF stored_count IS DISTINCT FROM pg_catalog.jsonb_array_length(p_terminal #> '{reservation,requirements}') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation requirement set must exactly match terminal evidence'; + END IF; + + SELECT pg_catalog.count(*)::integer + INTO stored_count + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = p_tenant_id + AND stored_allocation.obligation_id = current_effect.reservation_id; + IF stored_count IS DISTINCT FROM expected_allocation_count THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation allocation set must exactly match terminal evidence'; + END IF; + END IF; + + UPDATE "inventory"."reservation_create_effects" AS effect + SET state = terminal_tag, + record_json = p_terminal, + updated_at = pg_catalog.clock_timestamp() + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id; + + RETURN QUERY SELECT p_terminal; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."read_reservation_create_effect_for_worker"(uuid, uuid, text) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."finalize_reservation_create_effect_for_worker"(uuid, uuid, text, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."read_reservation_create_effect_for_worker"(uuid, uuid, text) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."finalize_reservation_create_effect_for_worker"(uuid, uuid, text, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924181709_inventory-reservation-create-effects/snapshot.json b/app/verticals/inventory/drizzle/20260924181709_inventory-reservation-create-effects/snapshot.json new file mode 100644 index 000000000..bc3e52297 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924181709_inventory-reservation-create-effects/snapshot.json @@ -0,0 +1,8887 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "cf045669-a510-46cb-ae64-5fa917ed8ce8", + "prevIds": [ + "efe22ed3-d7e0-4c2a-a9c9-e08737a32b27" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924190022_inventory-source-conflicts/migration.sql b/app/verticals/inventory/drizzle/20260924190022_inventory-source-conflicts/migration.sql new file mode 100644 index 000000000..22311125a --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924190022_inventory-source-conflicts/migration.sql @@ -0,0 +1,778 @@ +CREATE TABLE "inventory"."source_conflict_revisions" ( + "tenant_id" uuid, + "conflict_id" uuid, + "revision" integer, + "status" text NOT NULL, + "conflict_type" text NOT NULL, + "current_truth" text NOT NULL, + "customer_configuration_id" text NOT NULL, + "position_id" uuid, + "fact_meaning" text, + "detected_at" timestamp with time zone NOT NULL, + "resolved_at" timestamp with time zone, + "conflict_json" jsonb NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_source_conflict_revisions_pk" PRIMARY KEY("tenant_id","conflict_id","revision"), + CONSTRAINT "inventory_source_conflict_revision_ck" CHECK ("revision" in (1, 2)), + CONSTRAINT "inventory_source_conflict_status_ck" CHECK (("revision" = 1 and "status" = 'OPEN' and "current_truth" = 'INDETERMINATE' and "resolved_at" is null) or ("revision" = 2 and "status" = 'RESOLVED' and "current_truth" in ('CURRENT', 'CONFIGURATION_SINGULAR') and "resolved_at" is not null and "resolved_at" >= "detected_at")), + CONSTRAINT "inventory_source_conflict_type_ck" CHECK ("conflict_type" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')), + CONSTRAINT "inventory_source_conflict_scope_ck" CHECK (("conflict_type" in ('BACKEND_CONFIGURATION', 'CORRELATION') and "position_id" is null and "fact_meaning" is null) or ("conflict_type" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and "position_id" is not null and "fact_meaning" = 'ABSOLUTE_PHYSICAL_ON_HAND')), + CONSTRAINT "inventory_source_conflict_customer_configuration_ck" CHECK ("customer_configuration_id" = btrim("customer_configuration_id") and length("customer_configuration_id") between 1 and 300) +); +--> statement-breakpoint +ALTER TABLE "inventory"."source_conflict_revisions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE INDEX "inventory_source_conflict_latest_idx" ON "inventory"."source_conflict_revisions" ("tenant_id","conflict_id","revision");--> statement-breakpoint +CREATE INDEX "inventory_source_conflict_position_idx" ON "inventory"."source_conflict_revisions" ("tenant_id","position_id","status");--> statement-breakpoint +ALTER TABLE "inventory"."source_conflict_revisions" ADD CONSTRAINT "inventory_source_conflict_revisions_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_source_conflict_revisions_tenant_select" ON "inventory"."source_conflict_revisions" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."source_conflict_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_conflict_revisions_tenant_insert" ON "inventory"."source_conflict_revisions" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."source_conflict_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_conflict_revisions_tenant_update" ON "inventory"."source_conflict_revisions" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."source_conflict_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."source_conflict_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_source_conflict_revisions_tenant_delete" ON "inventory"."source_conflict_revisions" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."source_conflict_revisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."source_conflict_revisions" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_source_conflict_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + ambiguous_key jsonb; + proposal jsonb; + resolution_assertion jsonb; + source_evidence jsonb; +BEGIN + source_evidence := CASE + WHEN NEW.revision = 1 THEN NEW.conflict_json -> 'evidence' + ELSE NEW.conflict_json -> 'originalEvidence' + END; + + IF pg_catalog.jsonb_typeof(NEW.conflict_json) IS DISTINCT FROM 'object' + OR NEW.conflict_json #>> '{conflictRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.conflict_json #>> '{conflictRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.inventory-source-conflict' + OR NEW.conflict_json #>> '{conflictRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.conflict_json #>> '{conflictRef,resourceId}' IS DISTINCT FROM NEW.conflict_id::text + OR NEW.conflict_json ->> 'revision' IS DISTINCT FROM NEW.revision::text + OR NEW.conflict_json ->> 'status' IS DISTINCT FROM NEW.status + OR NEW.conflict_json ->> 'conflictType' IS DISTINCT FROM NEW.conflict_type + OR NEW.conflict_json ->> 'currentTruth' IS DISTINCT FROM NEW.current_truth + OR NEW.conflict_json #>> '{scope,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.conflict_json #>> '{authorityConfiguration,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.conflict_json #>> '{authorityConfiguration,customerConfigurationId}' + IS DISTINCT FROM NEW.customer_configuration_id + OR (NEW.conflict_json ->> 'detectedAt')::timestamptz IS DISTINCT FROM NEW.detected_at + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = (NEW.conflict_json #>> '{authorityConfiguration,configurationId}')::uuid + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = NEW.conflict_json #>> '{authorityConfiguration,selection,backend}' + AND authority.backend_id = NEW.conflict_json #>> '{authorityConfiguration,selection,backendId}' + AND authority.exact_reservation_capability + = NEW.conflict_json #>> '{authorityConfiguration,selection,exactReservationCapability}' + AND authority.stock_correction_capability + = NEW.conflict_json #>> '{authorityConfiguration,selection,stockCorrectionCapability}' + AND authority.selected_at + = (NEW.conflict_json #>> '{authorityConfiguration,selectedAt}')::timestamptz + AND authority.revision = (NEW.conflict_json #>> '{authorityConfiguration,revision}')::integer + ) + OR ( + NEW.revision = 1 + AND ( + NEW.conflict_json ? 'resolution' + OR NEW.conflict_json ? 'originalEvidence' + OR NEW.resolved_at IS NOT NULL + ) + ) + OR ( + NEW.revision = 2 + AND ( + (NEW.conflict_json #>> '{resolution,resolvedAt}')::timestamptz IS DISTINCT FROM NEW.resolved_at + OR NEW.resolved_at < NEW.detected_at + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Inventory Source Conflict JSON must exactly match relational identity, authority, lifecycle, and time'; + END IF; + + IF NEW.conflict_type = 'BACKEND_CONFIGURATION' THEN + IF NEW.position_id IS NOT NULL + OR NEW.fact_meaning IS NOT NULL + OR NEW.conflict_json #>> '{scope,_tag}' IS DISTINCT FROM 'CUSTOMER_CONFIGURATION' + OR NEW.conflict_json #>> '{scope,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR ( + NEW.revision = 2 + AND ( + NEW.current_truth IS DISTINCT FROM 'CONFIGURATION_SINGULAR' + OR NEW.conflict_json #>> '{resolution,_tag}' IS DISTINCT FROM 'BACKEND_CONFIGURATION' + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Backend Configuration conflict scope must remain Customer Configuration-wide'; + END IF; + ELSIF NEW.conflict_type = 'CORRELATION' THEN + ambiguous_key := NEW.conflict_json #> '{scope,ambiguousExternalKey}'; + proposal := source_evidence -> 'proposal'; + IF NEW.position_id IS NOT NULL + OR NEW.fact_meaning IS NOT NULL + OR NEW.conflict_json #>> '{scope,_tag}' IS DISTINCT FROM 'EXTERNAL_CORRELATION' + OR NEW.conflict_json #>> '{scope,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.conflict_json #> '{scope,ambiguousExternalKey}' + IS DISTINCT FROM source_evidence -> 'ambiguousExternalKey' + OR ambiguous_key ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + OR ambiguous_key ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR ambiguous_key #>> '{issuer,backendKind}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backend}' + OR ambiguous_key #>> '{issuer,backendId}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backendId}' + OR ambiguous_key ->> 'identifierKind' IS NULL + OR ambiguous_key ->> 'identifierKind' NOT IN ('ITEM', 'LOCATION') + OR pg_catalog.jsonb_typeof(proposal) IS DISTINCT FROM 'object' + OR proposal ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR proposal ->> 'factMeaning' IS DISTINCT FROM 'ABSOLUTE_PHYSICAL_ON_HAND' + OR proposal #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{issuer,backendKind}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backend}' + OR proposal #>> '{issuer,backendId}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backendId}' + OR (proposal ->> 'businessObservedAt')::timestamptz + < (NEW.conflict_json #>> '{authorityConfiguration,selectedAt}')::timestamptz + OR proposal #>> '{itemExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{itemExternalKey,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR proposal #>> '{itemExternalKey,identifierKind}' IS DISTINCT FROM 'ITEM' + OR proposal #>> '{itemExternalKey,issuer,backendKind}' + IS DISTINCT FROM proposal #>> '{issuer,backendKind}' + OR proposal #>> '{itemExternalKey,issuer,backendId}' + IS DISTINCT FROM proposal #>> '{issuer,backendId}' + OR proposal #>> '{locationExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{locationExternalKey,customerConfigurationId}' + IS DISTINCT FROM NEW.customer_configuration_id + OR proposal #>> '{locationExternalKey,identifierKind}' IS DISTINCT FROM 'LOCATION' + OR proposal #>> '{locationExternalKey,issuer,backendKind}' + IS DISTINCT FROM proposal #>> '{issuer,backendKind}' + OR proposal #>> '{locationExternalKey,issuer,backendId}' + IS DISTINCT FROM proposal #>> '{issuer,backendId}' + OR ( + ambiguous_key ->> 'identifierKind' = 'ITEM' + AND proposal -> 'itemExternalKey' IS DISTINCT FROM ambiguous_key + ) + OR ( + ambiguous_key ->> 'identifierKind' = 'LOCATION' + AND proposal -> 'locationExternalKey' IS DISTINCT FROM ambiguous_key + ) + OR pg_catalog.jsonb_typeof(source_evidence -> 'candidateCorrelationRefs') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(source_evidence -> 'candidateCorrelationRefs') < 2 + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(source_evidence -> 'candidateCorrelationRefs') AS candidate(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count( + DISTINCT (candidate.entry ->> 'tenantId', candidate.entry ->> 'resourceId') + ) + FROM pg_catalog.jsonb_array_elements(source_evidence -> 'candidateCorrelationRefs') AS candidate(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(source_evidence -> 'candidateCorrelationRefs') AS candidate(entry) + WHERE candidate.entry ->> 'moduleId' IS DISTINCT FROM 'commerce.inventory' + OR candidate.entry ->> 'resourceType' + IS DISTINCT FROM 'commerce.inventory.external-stock-correlation' + OR candidate.entry ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + ) + OR ( + NEW.revision = 2 + AND ( + NEW.current_truth IS DISTINCT FROM 'CURRENT' + OR NEW.conflict_json #>> '{resolution,_tag}' IS DISTINCT FROM 'CURRENT_ASSERTION' + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Correlation conflict must retain exact external-key scope without implying a Position'; + END IF; + ELSIF NEW.position_id IS NULL + OR NEW.fact_meaning IS DISTINCT FROM 'ABSOLUTE_PHYSICAL_ON_HAND' + OR NEW.conflict_json #>> '{scope,_tag}' IS DISTINCT FROM 'STOCK_POSITION_FACT' + OR NEW.conflict_json #>> '{scope,factMeaning}' IS DISTINCT FROM NEW.fact_meaning + OR NEW.conflict_json #>> '{scope,positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.conflict_json #>> '{scope,positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.conflict_json #>> '{scope,positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.conflict_json #>> '{scope,positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR ( + NEW.revision = 2 + AND ( + NEW.current_truth IS DISTINCT FROM 'CURRENT' + OR NEW.conflict_json #>> '{resolution,_tag}' IS DISTINCT FROM 'CURRENT_ASSERTION' + ) + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.position_id + AND position.customer_configuration_id = NEW.customer_configuration_id + AND NEW.conflict_json #>> '{scope,unitRef,moduleId}' = position.stock_unit_module_id + AND NEW.conflict_json #>> '{scope,unitRef,resourceId}' = position.stock_unit_resource_id::text + AND NEW.conflict_json #>> '{scope,unitRef,resourceType}' = position.stock_unit_resource_type + AND NEW.conflict_json #>> '{scope,unitRef,tenantId}' = position.stock_unit_tenant_id::text + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Inventory source fact conflict must bind the exact Position fact scope'; + END IF; + + IF NEW.conflict_type IN ('FACT_VALUE', 'ASSERTION_INTEGRITY') THEN + IF pg_catalog.jsonb_typeof(source_evidence) IS DISTINCT FROM 'array' + OR ( + NEW.conflict_type = 'FACT_VALUE' + AND pg_catalog.jsonb_array_length(source_evidence) < 2 + ) + OR ( + NEW.conflict_type = 'ASSERTION_INTEGRITY' + AND pg_catalog.jsonb_array_length(source_evidence) <> 2 + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Inventory source fact conflict evidence must retain every exact conflicting proposal'; + END IF; + + FOR proposal IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(source_evidence) AS evidence(entry) + LOOP + IF proposal ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR proposal ->> 'factMeaning' IS DISTINCT FROM 'ABSOLUTE_PHYSICAL_ON_HAND' + OR proposal #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR proposal #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR proposal #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR proposal #>> '{quantity,unitRef,moduleId}' + IS DISTINCT FROM NEW.conflict_json #>> '{scope,unitRef,moduleId}' + OR proposal #>> '{quantity,unitRef,resourceId}' + IS DISTINCT FROM NEW.conflict_json #>> '{scope,unitRef,resourceId}' + OR proposal #>> '{quantity,unitRef,resourceType}' + IS DISTINCT FROM NEW.conflict_json #>> '{scope,unitRef,resourceType}' + OR proposal #>> '{quantity,unitRef,tenantId}' + IS DISTINCT FROM NEW.conflict_json #>> '{scope,unitRef,tenantId}' + OR proposal #>> '{issuer,backendKind}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backend}' + OR proposal #>> '{issuer,backendId}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backendId}' + OR (proposal ->> 'businessObservedAt')::timestamptz + < (NEW.conflict_json #>> '{authorityConfiguration,selectedAt}')::timestamptz + OR proposal #>> '{itemExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{itemExternalKey,customerConfigurationId}' + IS DISTINCT FROM NEW.customer_configuration_id + OR proposal #>> '{itemExternalKey,identifierKind}' IS DISTINCT FROM 'ITEM' + OR proposal #>> '{itemExternalKey,issuer,backendKind}' + IS DISTINCT FROM proposal #>> '{issuer,backendKind}' + OR proposal #>> '{itemExternalKey,issuer,backendId}' + IS DISTINCT FROM proposal #>> '{issuer,backendId}' + OR proposal #>> '{locationExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR proposal #>> '{locationExternalKey,customerConfigurationId}' + IS DISTINCT FROM NEW.customer_configuration_id + OR proposal #>> '{locationExternalKey,identifierKind}' IS DISTINCT FROM 'LOCATION' + OR proposal #>> '{locationExternalKey,issuer,backendKind}' + IS DISTINCT FROM proposal #>> '{issuer,backendKind}' + OR proposal #>> '{locationExternalKey,issuer,backendId}' + IS DISTINCT FROM proposal #>> '{issuer,backendId}' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Every conflict proposal must retain the exact Position, Unit, Tenant, and selected authority'; + END IF; + END LOOP; + END IF; + + IF NEW.conflict_type = 'BACKEND_CONFIGURATION' AND ( + pg_catalog.jsonb_typeof(source_evidence) IS DISTINCT FROM 'object' + OR source_evidence -> 'selectedConfiguration' + IS DISTINCT FROM NEW.conflict_json -> 'authorityConfiguration' + OR source_evidence #>> '{attemptedSelection,backend}' IS NULL + OR source_evidence #>> '{attemptedSelection,backend}' + NOT IN ('external_business_system', 'ontos_wms') + OR source_evidence #>> '{attemptedSelection,backend}' + = NEW.conflict_json #>> '{authorityConfiguration,selection,backend}' + OR coalesce(pg_catalog.length(pg_catalog.btrim(source_evidence ->> 'ownerEvidenceRef')), 0) + NOT BETWEEN 1 AND 300 + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Backend Configuration conflict evidence must retain the selected and opposite attempted authority'; + END IF; + + IF NEW.revision = 2 THEN + IF coalesce(pg_catalog.length(pg_catalog.btrim(NEW.conflict_json #>> '{resolution,ownerEvidenceRef}')), 0) + NOT BETWEEN 1 AND 300 + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.conflict_json #>> '{resolution,principalId}')), 0) + NOT BETWEEN 1 AND 300 + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Inventory Source Conflict resolution must retain bounded owner and principal evidence'; + END IF; + + IF NEW.conflict_type = 'BACKEND_CONFIGURATION' THEN + IF NEW.conflict_json #> '{resolution,configuration}' + IS DISTINCT FROM NEW.conflict_json -> 'authorityConfiguration' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Backend Configuration resolution must prove the exact singular authority'; + END IF; + ELSE + resolution_assertion := NEW.conflict_json #> '{resolution,assertion}'; + IF pg_catalog.jsonb_typeof(resolution_assertion) IS DISTINCT FROM 'object' + OR resolution_assertion -> 'authorityConfiguration' + IS DISTINCT FROM NEW.conflict_json -> 'authorityConfiguration' + OR resolution_assertion ->> 'issuerAuthority' IS DISTINCT FROM 'SELECTED_BACKEND' + OR resolution_assertion ->> 'customerConfigurationId' + IS DISTINCT FROM NEW.customer_configuration_id + OR resolution_assertion ->> 'factMeaning' IS DISTINCT FROM 'ABSOLUTE_PHYSICAL_ON_HAND' + OR resolution_assertion #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{issuer,backendKind}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backend}' + OR resolution_assertion #>> '{issuer,backendId}' + IS DISTINCT FROM NEW.conflict_json #>> '{authorityConfiguration,selection,backendId}' + OR (resolution_assertion ->> 'businessObservedAt')::timestamptz + < (NEW.conflict_json #>> '{authorityConfiguration,selectedAt}')::timestamptz + OR resolution_assertion #>> '{itemExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{itemExternalKey,customerConfigurationId}' + IS DISTINCT FROM NEW.customer_configuration_id + OR resolution_assertion #>> '{itemExternalKey,identifierKind}' IS DISTINCT FROM 'ITEM' + OR resolution_assertion #>> '{itemExternalKey,issuer,backendKind}' + IS DISTINCT FROM resolution_assertion #>> '{issuer,backendKind}' + OR resolution_assertion #>> '{itemExternalKey,issuer,backendId}' + IS DISTINCT FROM resolution_assertion #>> '{issuer,backendId}' + OR resolution_assertion #>> '{locationExternalKey,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{locationExternalKey,customerConfigurationId}' + IS DISTINCT FROM NEW.customer_configuration_id + OR resolution_assertion #>> '{locationExternalKey,identifierKind}' IS DISTINCT FROM 'LOCATION' + OR resolution_assertion #>> '{locationExternalKey,issuer,backendKind}' + IS DISTINCT FROM resolution_assertion #>> '{issuer,backendKind}' + OR resolution_assertion #>> '{locationExternalKey,issuer,backendId}' + IS DISTINCT FROM resolution_assertion #>> '{issuer,backendId}' + OR resolution_assertion #>> '{itemCorrelationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{locationCorrelationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{stockItemRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR resolution_assertion #>> '{stockLocationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR ( + NEW.conflict_type IN ('FACT_VALUE', 'ASSERTION_INTEGRITY') + AND ( + resolution_assertion #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR resolution_assertion #> '{quantity,unitRef}' + IS DISTINCT FROM NEW.conflict_json #> '{scope,unitRef}' + ) + ) + OR ( + NEW.conflict_type = 'CORRELATION' + AND ( + CASE ambiguous_key ->> 'identifierKind' + WHEN 'ITEM' THEN resolution_assertion -> 'itemExternalKey' + ELSE resolution_assertion -> 'locationExternalKey' + END + ) IS DISTINCT FROM ambiguous_key + ) + OR ( + NEW.conflict_type = 'CORRELATION' + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."external_stock_correlations" AS repaired_correlation + WHERE repaired_correlation.tenant_id = NEW.tenant_id + AND repaired_correlation.customer_configuration_id = NEW.customer_configuration_id + AND repaired_correlation.issuer_backend_kind = ambiguous_key #>> '{issuer,backendKind}' + AND repaired_correlation.issuer_backend_id = ambiguous_key #>> '{issuer,backendId}' + AND repaired_correlation.namespace = ambiguous_key ->> 'namespace' + AND repaired_correlation.external_scope = ambiguous_key ->> 'externalScope' + AND repaired_correlation.identifier_kind = ambiguous_key ->> 'identifierKind' + AND repaired_correlation.external_value = ambiguous_key ->> 'externalValue' + AND repaired_correlation.effective_from + <= (resolution_assertion ->> 'businessObservedAt')::timestamptz + AND ( + repaired_correlation.effective_to IS NULL + OR (resolution_assertion ->> 'businessObservedAt')::timestamptz + < repaired_correlation.effective_to + ) + AND ( + ( + ambiguous_key ->> 'identifierKind' = 'ITEM' + AND repaired_correlation.correlation_id + = (resolution_assertion #>> '{itemCorrelationRef,resourceId}')::uuid + AND repaired_correlation.stock_item_id + = (resolution_assertion #>> '{stockItemRef,resourceId}')::uuid + AND repaired_correlation.stock_location_id IS NULL + ) + OR ( + ambiguous_key ->> 'identifierKind' = 'LOCATION' + AND repaired_correlation.correlation_id + = (resolution_assertion #>> '{locationCorrelationRef,resourceId}')::uuid + AND repaired_correlation.stock_location_id + = (resolution_assertion #>> '{stockLocationRef,resourceId}')::uuid + AND repaired_correlation.stock_item_id IS NULL + ) + ) + ) + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."source_assertions" AS persisted_assertion + WHERE persisted_assertion.tenant_id = NEW.tenant_id + AND persisted_assertion.assertion_id + = (resolution_assertion ->> 'assertionId')::uuid + AND persisted_assertion.assertion_json IS NOT DISTINCT FROM resolution_assertion + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = (resolution_assertion #>> '{positionRef,resourceId}')::uuid + AND position.customer_configuration_id = NEW.customer_configuration_id + AND position.owner_configuration_id + = (NEW.conflict_json #>> '{authorityConfiguration,configurationId}')::uuid + AND position.stock_item_id = (resolution_assertion #>> '{stockItemRef,resourceId}')::uuid + AND position.stock_location_id = (resolution_assertion #>> '{stockLocationRef,resourceId}')::uuid + AND position.stock_unit_module_id = resolution_assertion #>> '{quantity,unitRef,moduleId}' + AND position.stock_unit_resource_id + = (resolution_assertion #>> '{quantity,unitRef,resourceId}')::uuid + AND position.stock_unit_resource_type = resolution_assertion #>> '{quantity,unitRef,resourceType}' + AND position.stock_unit_tenant_id = (resolution_assertion #>> '{quantity,unitRef,tenantId}')::uuid + AND position.lifecycle_state = 'CURRENT' + AND position.on_hand_state = 'CURRENT' + AND position.on_hand_evidence_ref = resolution_assertion ->> 'ownerEvidenceRef' + AND position.on_hand_observed_at = (resolution_assertion ->> 'businessObservedAt')::timestamptz + AND position.on_hand_amount = (resolution_assertion #>> '{quantity,amount}')::numeric + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_exact_scope_ck', + MESSAGE = 'Current assertion resolution must prove the exact selected authority and established Position truth'; + END IF; + END IF; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_source_conflict_revision"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + previous RECORD; +BEGIN + IF TG_OP IN ('UPDATE', 'DELETE') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_immutable_ck', + MESSAGE = 'Inventory Source Conflict revisions are append-only'; + END IF; + + SELECT revision_record.* + INTO previous + FROM "inventory"."source_conflict_revisions" AS revision_record + WHERE revision_record.tenant_id = NEW.tenant_id + AND revision_record.conflict_id = NEW.conflict_id + ORDER BY revision_record.revision DESC + LIMIT 1 + FOR UPDATE; + + IF NEW.revision = 1 THEN + IF previous.revision IS NULL THEN + RETURN NEW; + END IF; + IF previous.revision = 1 + AND previous.conflict_json IS NOT DISTINCT FROM NEW.conflict_json + AND previous.status IS NOT DISTINCT FROM NEW.status + AND previous.conflict_type IS NOT DISTINCT FROM NEW.conflict_type + AND previous.current_truth IS NOT DISTINCT FROM NEW.current_truth + AND previous.customer_configuration_id IS NOT DISTINCT FROM NEW.customer_configuration_id + AND previous.position_id IS NOT DISTINCT FROM NEW.position_id + AND previous.fact_meaning IS NOT DISTINCT FROM NEW.fact_meaning + AND previous.detected_at IS NOT DISTINCT FROM NEW.detected_at + AND previous.resolved_at IS NOT DISTINCT FROM NEW.resolved_at + THEN + RETURN NEW; + END IF; + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_sequence_ck', + MESSAGE = 'Inventory Source Conflict revision one must establish one stable identity'; + END IF; + + IF NEW.revision = 2 AND previous.revision = 2 THEN + IF previous.conflict_json IS NOT DISTINCT FROM NEW.conflict_json + AND previous.status IS NOT DISTINCT FROM NEW.status + AND previous.conflict_type IS NOT DISTINCT FROM NEW.conflict_type + AND previous.current_truth IS NOT DISTINCT FROM NEW.current_truth + AND previous.customer_configuration_id IS NOT DISTINCT FROM NEW.customer_configuration_id + AND previous.position_id IS NOT DISTINCT FROM NEW.position_id + AND previous.fact_meaning IS NOT DISTINCT FROM NEW.fact_meaning + AND previous.detected_at IS NOT DISTINCT FROM NEW.detected_at + AND previous.resolved_at IS NOT DISTINCT FROM NEW.resolved_at + THEN + RETURN NEW; + END IF; + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_sequence_ck', + MESSAGE = 'Inventory Source Conflict resolution identity already has a different terminal revision'; + END IF; + + IF NEW.revision IS DISTINCT FROM 2 + OR previous.revision IS DISTINCT FROM 1 + OR NEW.conflict_type IS DISTINCT FROM previous.conflict_type + OR NEW.customer_configuration_id IS DISTINCT FROM previous.customer_configuration_id + OR NEW.position_id IS DISTINCT FROM previous.position_id + OR NEW.fact_meaning IS DISTINCT FROM previous.fact_meaning + OR NEW.detected_at IS DISTINCT FROM previous.detected_at + OR NEW.resolved_at IS NULL + OR NEW.resolved_at < NEW.detected_at + OR NEW.conflict_json -> 'conflictRef' IS DISTINCT FROM previous.conflict_json -> 'conflictRef' + OR NEW.conflict_json -> 'authorityConfiguration' IS DISTINCT FROM previous.conflict_json -> 'authorityConfiguration' + OR NEW.conflict_json -> 'scope' IS DISTINCT FROM previous.conflict_json -> 'scope' + OR NEW.conflict_json -> 'originalEvidence' IS DISTINCT FROM previous.conflict_json -> 'evidence' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_conflict_revisions_sequence_ck', + MESSAGE = 'Inventory Source Conflict resolution must be the exact immutable successor of revision one'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_source_conflict_revisions_exact_scope_trg" +BEFORE INSERT ON "inventory"."source_conflict_revisions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_conflict_exact_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_source_conflict_revisions_sequence_trg" +BEFORE INSERT ON "inventory"."source_conflict_revisions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_conflict_revision"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_source_conflict_revisions_immutable_trg" +BEFORE UPDATE OR DELETE ON "inventory"."source_conflict_revisions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_source_conflict_revision"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_source_conflict_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_source_conflict_revision"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."enforce_source_import_ledger_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF pg_catalog.jsonb_typeof(NEW.proposal_json) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.proposal_json -> 'issuer') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.proposal_json -> 'positionRef') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.proposal_json -> 'orderingEvidence') IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(NEW.outcome_json) IS DISTINCT FROM 'object' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import ledger JSON evidence must use canonical object shapes'; + END IF; + + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json)) <> 14 + OR NOT ( + NEW.proposal_json ?& ARRAY[ + 'assertionId', 'businessObservedAt', 'coverage', 'customerConfigurationId', 'factMeaning', 'issuer', + 'itemExternalKey', 'locationExternalKey', 'orderingEvidence', 'ownerEvidenceRef', 'positionRef', + 'quantity', 'receivedAt', 'sourceReference' + ] + ) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json -> 'issuer')) <> 2 + OR NOT (NEW.proposal_json -> 'issuer' ?& ARRAY['backendId', 'backendKind']) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json -> 'positionRef')) <> 4 + OR NOT (NEW.proposal_json -> 'positionRef' ?& ARRAY['moduleId', 'resourceId', 'resourceType', 'tenantId']) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.proposal_json -> 'orderingEvidence')) <> 2 + OR NEW.proposal_json ->> 'assertionId' IS DISTINCT FROM NEW.assertion_id::text + OR NEW.proposal_json ->> 'customerConfigurationId' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.proposal_json #>> '{issuer,backendKind}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.proposal_json #>> '{issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.proposal_json ->> 'factMeaning' IS DISTINCT FROM NEW.fact_meaning + OR NEW.proposal_json #>> '{positionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.proposal_json #>> '{positionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR NEW.proposal_json #>> '{positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.proposal_json #>> '{positionRef,resourceId}' IS DISTINCT FROM NEW.position_id::text + OR NEW.proposal_json ->> 'sourceReference' IS DISTINCT FROM NEW.source_reference + OR NEW.proposal_json #>> '{orderingEvidence,_tag}' IS DISTINCT FROM NEW.ordering_evidence_kind + OR NEW.outcome_json ->> 'assertionId' IS DISTINCT FROM NEW.assertion_id::text + OR NEW.outcome_json ->> 'status' IS DISTINCT FROM NEW.status + OR ( + NEW.ordering_evidence_kind = 'SOURCE_REVISION' + AND ( + NEW.proposal_json #>> '{orderingEvidence,revision}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.proposal_json #> '{orderingEvidence,key}' IS NOT NULL + ) + ) + OR ( + NEW.ordering_evidence_kind = 'OWNER_ORDER_KEY' + AND ( + NEW.proposal_json #>> '{orderingEvidence,key}' IS DISTINCT FROM NEW.ordering_evidence_value + OR NEW.proposal_json #> '{orderingEvidence,revision}' IS NOT NULL + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import ledger JSON evidence must exactly match its relational stream and outcome'; + END IF; + + IF ( + NEW.status = 'ACCEPTED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 3 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'postEffectOnHand', 'status']) + OR pg_catalog.jsonb_typeof(NEW.outcome_json -> 'postEffectOnHand') IS DISTINCT FROM 'object' + ) + ) OR ( + NEW.status = 'DUPLICATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 4 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'duplicateOfAssertionId', 'reason', 'status']) + OR NEW.outcome_json ->> 'duplicateOfAssertionId' IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) OR ( + NEW.status = 'STALE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) NOT IN (3, 4) + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'reason', 'status']) + OR ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) = 4 + AND NOT (NEW.outcome_json ? 'currentAssertionId') + ) + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) OR ( + NEW.status = 'REJECTED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 3 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'reason', 'status']) + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + ) + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import ledger outcome JSON must exactly match its status contract'; + END IF; + + IF NEW.status = 'INDETERMINATE' THEN + IF NEW.outcome_json ->> 'reason' = 'INVENTORY_SOURCE_CONFLICT' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 5 + OR NOT ( + NEW.outcome_json ?& ARRAY[ + 'assertionId', 'conflictRefs', 'reason', 'reconciliationRequired', 'status' + ] + ) + OR NEW.outcome_json -> 'reconciliationRequired' IS DISTINCT FROM 'true'::jsonb + OR pg_catalog.jsonb_typeof(NEW.outcome_json -> 'conflictRefs') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(NEW.outcome_json -> 'conflictRefs') < 1 + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(NEW.outcome_json -> 'conflictRefs') AS conflict_ref + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT conflict_ref ->> 'resourceId') + FROM pg_catalog.jsonb_array_elements(NEW.outcome_json -> 'conflictRefs') AS conflict_ref + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(NEW.outcome_json -> 'conflictRefs') AS conflict_ref + WHERE pg_catalog.jsonb_typeof(conflict_ref) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(conflict_ref)) <> 4 + OR NOT (conflict_ref ?& ARRAY['moduleId', 'resourceId', 'resourceType', 'tenantId']) + OR conflict_ref ->> 'moduleId' IS DISTINCT FROM 'commerce.inventory' + OR conflict_ref ->> 'resourceType' + IS DISTINCT FROM 'commerce.inventory.inventory-source-conflict' + OR conflict_ref ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."source_conflict_revisions" AS source_conflict + WHERE source_conflict.tenant_id = NEW.tenant_id + AND source_conflict.conflict_id::text = conflict_ref ->> 'resourceId' + AND source_conflict.revision = 1 + AND source_conflict.status = 'OPEN' + AND source_conflict.customer_configuration_id = NEW.customer_configuration_id + AND source_conflict.conflict_json -> 'conflictRef' IS NOT DISTINCT FROM conflict_ref + AND ( + ( + source_conflict.conflict_type = 'CORRELATION' + AND source_conflict.conflict_json #> '{evidence,proposal}' + IS NOT DISTINCT FROM NEW.proposal_json + ) + OR ( + source_conflict.conflict_type IN ('FACT_VALUE', 'ASSERTION_INTEGRITY') + AND EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(source_conflict.conflict_json -> 'evidence') + AS conflict_proposal + WHERE conflict_proposal IS NOT DISTINCT FROM NEW.proposal_json + ) + ) + ) + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import conflict outcome must reference exact persisted conflict evidence'; + END IF; + ELSIF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.outcome_json)) <> 4 + OR NOT (NEW.outcome_json ?& ARRAY['assertionId', 'reason', 'reconciliationRequired', 'status']) + OR NEW.outcome_json ? 'conflictRefs' + OR NEW.outcome_json -> 'reconciliationRequired' IS DISTINCT FROM 'true'::jsonb + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.outcome_json ->> 'reason')), 0) NOT BETWEEN 1 AND 300 + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_source_import_ledger_exact_scope_ck', + MESSAGE = 'Inventory Source Import reconciliation outcome must not claim source conflicts'; + END IF; + END IF; + + IF NEW.status = 'ACCEPTED' THEN + PERFORM 1 + FROM "inventory"."source_assertions" AS assertion + WHERE assertion.tenant_id = NEW.tenant_id + AND assertion.assertion_id = NEW.assertion_id + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23503', + CONSTRAINT = 'inventory_source_import_ledger_accepted_assertion_fk', + MESSAGE = 'Accepted Inventory Source Import outcome must reference the exact persisted source assertion'; + END IF; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_source_import_ledger_exact_scope"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924190022_inventory-source-conflicts/snapshot.json b/app/verticals/inventory/drizzle/20260924190022_inventory-source-conflicts/snapshot.json new file mode 100644 index 000000000..f1f1b956d --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924190022_inventory-source-conflicts/snapshot.json @@ -0,0 +1,9250 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "c663e686-bedd-4d16-b598-698391b61dac", + "prevIds": [ + "cf045669-a510-46cb-ae64-5fa917ed8ce8" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924204859_inventory-reservation-confirmations/migration.sql b/app/verticals/inventory/drizzle/20260924204859_inventory-reservation-confirmations/migration.sql new file mode 100644 index 000000000..2f9a5489a --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924204859_inventory-reservation-confirmations/migration.sql @@ -0,0 +1,556 @@ +CREATE TABLE "inventory"."reservation_confirmation_history" ( + "history_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "confirmation_id" uuid NOT NULL, + "revision" integer NOT NULL, + "health_state" text NOT NULL, + "snapshot" jsonb NOT NULL, + "transitioned_at" timestamp with time zone NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_confirmation_history_health_ck" CHECK ("health_state" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and "revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmation_history" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."reservation_confirmations" ( + "confirmation_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "reservation_id" uuid NOT NULL, + "attempt_id" text NOT NULL, + "owner_configuration_id" uuid NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "authority_effect_id" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "issued_at" timestamp with time zone NOT NULL, + "expires_at" timestamp with time zone NOT NULL, + "current_health_state" text DEFAULT 'VALID' NOT NULL, + "current_revision" integer DEFAULT 1 NOT NULL, + "snapshot" jsonb NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_confirmations_meaning_ck" CHECK (char_length(btrim("attempt_id")) between 1 and 300 and char_length(btrim("issuer_backend_id")) between 1 and 300 and char_length(btrim("authority_effect_id")) between 1 and 300 and char_length(btrim("owner_evidence_ref")) between 1 and 300 and "issuer_backend_kind" in ('external_business_system', 'ontos_wms') and "issued_at" < "expires_at"), + CONSTRAINT "inventory_reservation_confirmations_health_ck" CHECK ("current_health_state" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and "current_revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_confirmation_history_scope_id_uk" ON "inventory"."reservation_confirmation_history" ("tenant_id","history_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_confirmation_history_revision_uk" ON "inventory"."reservation_confirmation_history" ("tenant_id","confirmation_id","revision");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_confirmations_scope_id_uk" ON "inventory"."reservation_confirmations" ("tenant_id","confirmation_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_confirmations_reservation_attempt_uk" ON "inventory"."reservation_confirmations" ("tenant_id","reservation_id","attempt_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_confirmations_authority_effect_uk" ON "inventory"."reservation_confirmations" ("tenant_id","authority_effect_id");--> statement-breakpoint +CREATE INDEX "inventory_reservation_confirmations_health_rank_idx" ON "inventory"."reservation_confirmations" ("tenant_id","current_health_state","issued_at","owner_evidence_ref");--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmation_history" ADD CONSTRAINT "inventory_reservation_confirmation_history_confirmation_fk" FOREIGN KEY ("tenant_id","confirmation_id") REFERENCES "inventory"."reservation_confirmations"("tenant_id","confirmation_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmations" ADD CONSTRAINT "inventory_reservation_confirmations_reservation_fk" FOREIGN KEY ("tenant_id","reservation_id") REFERENCES "inventory"."obligations"("tenant_id","obligation_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmations" ADD CONSTRAINT "inventory_reservation_confirmations_backend_configuration_fk" FOREIGN KEY ("tenant_id","owner_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmation_history_tenant_select" ON "inventory"."reservation_confirmation_history" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_confirmation_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmation_history_tenant_insert" ON "inventory"."reservation_confirmation_history" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_confirmation_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmation_history_tenant_update" ON "inventory"."reservation_confirmation_history" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_confirmation_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_confirmation_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmation_history_tenant_delete" ON "inventory"."reservation_confirmation_history" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_confirmation_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmations_tenant_select" ON "inventory"."reservation_confirmations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_confirmations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmations_tenant_insert" ON "inventory"."reservation_confirmations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_confirmations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmations_tenant_update" ON "inventory"."reservation_confirmations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_confirmations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_confirmations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_confirmations_tenant_delete" ON "inventory"."reservation_confirmations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_confirmations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmation_history" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_confirmations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_confirmation_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + observation_tag text; +BEGIN + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 8 + OR NOT ( + NEW.snapshot ?& ARRAY[ + 'authorityEvidence', 'expiresAt', 'health', 'issuanceRank', 'issuedAt', 'ref', 'reservation', 'revision' + ] + ) + OR pg_catalog.jsonb_typeof(NEW.snapshot -> 'reservation') IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'reservation')) <> 6 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'ref')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,ref}')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,origin}')) <> 2 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,authority}')) <> 6 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,authority,selection}')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'authorityEvidence')) <> 5 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{authorityEvidence,issuer}')) <> 3 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{authorityEvidence,evidence}')) <> 8 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'health')) <> 2 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'issuanceRank')) <> 3 + OR pg_catalog.jsonb_typeof(NEW.snapshot #> '{reservation,requirements}') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(NEW.snapshot #> '{reservation,requirements}') < 1 + OR NEW.snapshot #>> '{ref,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.snapshot #>> '{ref,resourceType}' IS DISTINCT FROM 'commerce.inventory.reservation-confirmation' + OR NEW.snapshot #>> '{ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{ref,resourceId}' IS DISTINCT FROM NEW.confirmation_id::text + OR NEW.snapshot #>> '{reservation,ref,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.snapshot #>> '{reservation,ref,resourceType}' + IS DISTINCT FROM 'commerce.inventory.inventory-reservation' + OR NEW.snapshot #>> '{reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{reservation,ref,resourceId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{reservation,origin,kind}' IS DISTINCT FROM 'ORDER_COMMITMENT_ATTEMPT' + OR NEW.snapshot #>> '{reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{reservation,lifecycleMeaning}' IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_snapshot_ck', + MESSAGE = 'Reservation Confirmation snapshot identity must exactly match its relational identity'; + END IF; + + PERFORM 1 + FROM "inventory"."obligations" AS reservation + WHERE reservation.tenant_id = NEW.tenant_id + AND reservation.obligation_id = NEW.reservation_id + AND reservation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.attempt_id = NEW.attempt_id + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + AND reservation.source_system IS NULL + AND reservation.source_order_id IS NULL + AND reservation.source_obligation_id IS NULL + AND reservation.customer_configuration_id + = NEW.snapshot #>> '{reservation,authority,customerConfigurationId}' + AND reservation.owner_configuration_id = NEW.owner_configuration_id + AND reservation.authority_backend_kind = NEW.issuer_backend_kind + AND reservation.authority_backend_id = NEW.issuer_backend_id + AND reservation.authority_selected_at + = (NEW.snapshot #>> '{reservation,authority,selectedAt}')::timestamptz + AND reservation.authority_revision + = (NEW.snapshot #>> '{reservation,authority,revision}')::integer + AND reservation.established_at + = (NEW.snapshot #>> '{reservation,establishedAt}')::timestamptz + FOR UPDATE; + + IF NOT FOUND + OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = NEW.tenant_id + AND stored_requirement.obligation_id = NEW.reservation_id + ) IS DISTINCT FROM pg_catalog.jsonb_array_length(NEW.snapshot #> '{reservation,requirements}') + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS expected_requirement(entry) + WHERE (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(expected_requirement.entry)) <> 8 + OR pg_catalog.jsonb_typeof(expected_requirement.entry -> 'allocations') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(expected_requirement.entry -> 'allocations') < 1 + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(expected_requirement.entry -> 'allocations') AS allocation(entry) + WHERE (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(allocation.entry)) <> 4 + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = NEW.tenant_id + AND stored_requirement.obligation_id = NEW.reservation_id + AND stored_requirement.purchase_demand_occurrence_id + = expected_requirement.entry ->> 'purchaseDemandOccurrenceId' + AND stored_requirement.binding_id + = (expected_requirement.entry #>> '{bindingRef,resourceId}')::uuid + AND stored_requirement.catalog_selection = expected_requirement.entry -> 'catalogSelection' + AND stored_requirement.exact_selection_meaning_id + = expected_requirement.entry #>> '{exactSelectionMeaning,id}' + AND stored_requirement.exact_selection_meaning_kind + = expected_requirement.entry #>> '{exactSelectionMeaning,kind}' + AND stored_requirement.stock_item_id + = (expected_requirement.entry #>> '{stockItem,stockItemRef,resourceId}')::uuid + AND stored_requirement.stock_item_revision + = (expected_requirement.entry #>> '{stockItem,revision}')::integer + AND stored_requirement.stock_item_snapshot = expected_requirement.entry -> 'stockItem' + AND stored_requirement.requested_amount = (expected_requirement.entry ->> 'quantity')::numeric + AND stored_requirement.unit_module_id = expected_requirement.entry #>> '{unitRef,moduleId}' + AND stored_requirement.unit_resource_id + = (expected_requirement.entry #>> '{unitRef,resourceId}')::uuid + AND stored_requirement.unit_resource_type = expected_requirement.entry #>> '{unitRef,resourceType}' + AND stored_requirement.unit_tenant_id + = (expected_requirement.entry #>> '{unitRef,tenantId}')::uuid + ) + ) + OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = NEW.tenant_id + AND stored_allocation.obligation_id = NEW.reservation_id + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS expected_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + expected_requirement.entry -> 'allocations' + ) AS expected_allocation(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS expected_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + expected_requirement.entry -> 'allocations' + ) AS expected_allocation(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = NEW.tenant_id + AND stored_allocation.obligation_id = NEW.reservation_id + AND stored_allocation.allocation_id = expected_allocation.entry ->> 'allocationId' + AND stored_allocation.purchase_demand_occurrence_id + = expected_requirement.entry ->> 'purchaseDemandOccurrenceId' + AND stored_allocation.stock_item_id + = (expected_allocation.entry #>> '{stockItemRef,resourceId}')::uuid + AND stored_allocation.stock_position_id + = (expected_allocation.entry #>> '{positionRef,resourceId}')::uuid + AND stored_allocation.allocated_amount + = (expected_allocation.entry #>> '{quantity,amount}')::numeric + AND stored_allocation.unit_module_id + = expected_allocation.entry #>> '{quantity,unitRef,moduleId}' + AND stored_allocation.unit_resource_id + = (expected_allocation.entry #>> '{quantity,unitRef,resourceId}')::uuid + AND stored_allocation.unit_resource_type + = expected_allocation.entry #>> '{quantity,unitRef,resourceType}' + AND stored_allocation.unit_tenant_id + = (expected_allocation.entry #>> '{quantity,unitRef,tenantId}')::uuid + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_exact_reservation_ck', + MESSAGE = 'Reservation Confirmation must reference one exact runtime Attempt and provisional Reservation'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.owner_configuration_id + AND authority.customer_configuration_id + = NEW.snapshot #>> '{reservation,authority,customerConfigurationId}' + AND authority.backend_kind = NEW.issuer_backend_kind + AND authority.backend_id = NEW.issuer_backend_id + AND authority.exact_reservation_capability = 'SUPPORTED' + AND authority.stock_correction_capability + = NEW.snapshot #>> '{reservation,authority,selection,stockCorrectionCapability}' + AND authority.selected_at + = (NEW.snapshot #>> '{reservation,authority,selectedAt}')::timestamptz + AND authority.revision = (NEW.snapshot #>> '{reservation,authority,revision}')::integer + AND NEW.snapshot #>> '{reservation,authority,tenantId}' = NEW.tenant_id::text + AND NEW.snapshot #>> '{reservation,authority,configurationId}' = NEW.owner_configuration_id::text + AND NEW.snapshot #>> '{reservation,authority,selection,backend}' = authority.backend_kind + AND NEW.snapshot #>> '{reservation,authority,selection,backendId}' = authority.backend_id + AND NEW.snapshot #>> '{reservation,authority,selection,exactReservationCapability}' + = authority.exact_reservation_capability + FOR KEY SHARE; + + IF NOT FOUND + OR pg_catalog.jsonb_typeof(NEW.snapshot -> 'authorityEvidence') IS DISTINCT FROM 'object' + OR NEW.snapshot #>> '{authorityEvidence,kind}' + IS DISTINCT FROM 'AUTHORITATIVE_RESERVATION_EVIDENCE' + OR NEW.snapshot #>> '{authorityEvidence,operation}' IS DISTINCT FROM 'RESERVATION_CONFIRMATION' + OR NEW.snapshot #>> '{authorityEvidence,effectId}' IS DISTINCT FROM NEW.authority_effect_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.snapshot #>> '{authorityEvidence,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,origin}' IS DISTINCT FROM (CASE NEW.issuer_backend_kind + WHEN 'external_business_system' THEN 'EXTERNAL_BUSINESS_SYSTEM' + ELSE 'ONTOS_WMS' + END) + OR NEW.snapshot #>> '{authorityEvidence,evidence,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,reservationId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,customerConfigurationId}' + IS DISTINCT FROM NEW.snapshot #>> '{reservation,authority,customerConfigurationId}' + OR NEW.snapshot #>> '{authorityEvidence,evidence,ownerEvidenceRef}' + IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validFrom}')::timestamptz + IS DISTINCT FROM NEW.issued_at + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validUntil}')::timestamptz + IS DISTINCT FROM NEW.expires_at + OR pg_catalog.jsonb_typeof(NEW.snapshot #> '{authorityEvidence,evidence,allocations}') + IS DISTINCT FROM 'array' + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{authorityEvidence,evidence,allocations}' + ) AS authority_allocation(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS reservation_allocation(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{authorityEvidence,evidence,allocations}' + ) AS authority_allocation(entry) + WHERE (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(authority_allocation.entry)) <> 4 + OR NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS reservation_allocation(entry) + WHERE reservation_allocation.entry ->> 'allocationId' + = authority_allocation.entry ->> 'allocationId' + AND reservation_allocation.entry -> 'stockItemRef' + = authority_allocation.entry -> 'stockItemRef' + AND reservation_allocation.entry -> 'positionRef' + = authority_allocation.entry -> 'stockPositionRef' + AND reservation_allocation.entry -> 'quantity' + = authority_allocation.entry -> 'quantity' + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_exact_authority_ck', + MESSAGE = 'Reservation Confirmation authority evidence must exactly match the selected backend and Reservation'; + END IF; + + observation_tag := NEW.snapshot #>> '{health,observation,_tag}'; + IF observation_tag IS NULL + OR NEW.snapshot #>> '{health,observation,effectiveAt}' IS NULL + OR NEW.snapshot ->> 'issuedAt' IS NULL + OR (NEW.snapshot ->> 'issuedAt')::timestamptz IS DISTINCT FROM NEW.issued_at + OR NEW.snapshot ->> 'expiresAt' IS NULL + OR (NEW.snapshot ->> 'expiresAt')::timestamptz IS DISTINCT FROM NEW.expires_at + OR NEW.snapshot #>> '{issuanceRank,source}' IS DISTINCT FROM 'RESERVATION_AUTHORITY_EVIDENCE' + OR (NEW.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz IS DISTINCT FROM NEW.issued_at + OR NEW.snapshot #>> '{issuanceRank,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR NEW.snapshot #>> '{health,state}' IS DISTINCT FROM NEW.current_health_state + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz < NEW.issued_at + OR ( + TG_OP = 'INSERT' + AND ( + NEW.current_revision IS DISTINCT FROM 1 + OR NEW.current_health_state IS DISTINCT FROM 'VALID' + OR observation_tag IS DISTINCT FROM 'ISSUED' + ) + ) + OR ( + observation_tag = 'ISSUED' + AND ( + NEW.current_revision IS DISTINCT FROM 1 + OR NEW.current_health_state IS DISTINCT FROM 'VALID' + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz IS DISTINCT FROM NEW.issued_at + OR NEW.snapshot #>> '{health,observation,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + ) + ) + OR ( + observation_tag = 'OWNER_HEALTHY' + AND ( + NEW.current_health_state IS DISTINCT FROM 'VALID' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,ownerEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'MATERIAL_IMPAIRMENT' + AND ( + NEW.current_health_state IS DISTINCT FROM 'AT_RISK' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,ownerEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'BINDING_CORRECTION' + AND ( + NEW.current_health_state IS DISTINCT FROM 'AT_RISK' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,correctionEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'DEFINITIVE_REVOCATION' + AND ( + NEW.current_health_state IS DISTINCT FROM 'REVOKED' + OR NEW.snapshot #>> '{health,observation,decision}' IS DISTINCT FROM 'DEFINITIVE' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,ownerEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'OWNER_UNVERIFIABLE' + AND ( + NEW.current_health_state IS DISTINCT FROM 'UNVERIFIABLE' + OR NEW.snapshot #>> '{health,observation,reason}' NOT IN ( + 'OWNER_EVIDENCE_MISSING', + 'OWNER_EVIDENCE_STALE', + 'OWNER_EVIDENCE_UNAVAILABLE', + 'OWNER_EVIDENCE_INDETERMINATE' + ) + ) + ) + OR ( + observation_tag = 'VALIDITY_ELAPSED' + AND ( + NEW.current_health_state IS DISTINCT FROM 'EXPIRED' + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz < NEW.expires_at + ) + ) + OR observation_tag NOT IN ( + 'ISSUED', + 'OWNER_HEALTHY', + 'MATERIAL_IMPAIRMENT', + 'BINDING_CORRECTION', + 'DEFINITIVE_REVOCATION', + 'OWNER_UNVERIFIABLE', + 'VALIDITY_ELAPSED' + ) + OR ( + observation_tag <> 'VALIDITY_ELAPSED' + AND (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz >= NEW.expires_at + ) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{health,observation}')) + IS DISTINCT FROM (CASE observation_tag + WHEN 'DEFINITIVE_REVOCATION' THEN 4 + WHEN 'VALIDITY_ELAPSED' THEN 2 + ELSE 3 + END) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_snapshot_ck', + MESSAGE = 'Reservation Confirmation snapshot, health, validity, and revision must be exact'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_confirmation_lifecycle"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_lifecycle_ck', + MESSAGE = 'Reservation Confirmation evidence cannot be deleted'; + END IF; + + IF NEW.confirmation_id IS DISTINCT FROM OLD.confirmation_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.issuer_backend_kind IS DISTINCT FROM OLD.issuer_backend_kind + OR NEW.issuer_backend_id IS DISTINCT FROM OLD.issuer_backend_id + OR NEW.authority_effect_id IS DISTINCT FROM OLD.authority_effect_id + OR NEW.owner_evidence_ref IS DISTINCT FROM OLD.owner_evidence_ref + OR NEW.issued_at IS DISTINCT FROM OLD.issued_at + OR NEW.expires_at IS DISTINCT FROM OLD.expires_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR (NEW.snapshot - 'health' - 'revision') IS DISTINCT FROM (OLD.snapshot - 'health' - 'revision') + OR OLD.current_health_state IN ('REVOKED', 'EXPIRED') + OR NEW.current_revision IS DISTINCT FROM OLD.current_revision + 1 + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz + < (OLD.snapshot #>> '{health,observation,effectiveAt}')::timestamptz + OR ( + NEW.current_health_state = 'VALID' + AND OLD.current_health_state NOT IN ('AT_RISK', 'UNVERIFIABLE') + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_lifecycle_ck', + MESSAGE = 'Reservation Confirmation transition mutates immutable proof or violates monotonic health lifecycle'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_confirmation_history_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = NEW.tenant_id + AND confirmation.confirmation_id = NEW.confirmation_id + AND confirmation.current_revision = NEW.revision + AND confirmation.current_health_state = NEW.health_state + AND confirmation.snapshot IS NOT DISTINCT FROM NEW.snapshot + AND NEW.snapshot #>> '{ref,tenantId}' = NEW.tenant_id::text + AND NEW.snapshot #>> '{ref,resourceId}' = NEW.confirmation_id::text + AND (NEW.snapshot ->> 'revision')::integer = NEW.revision + AND NEW.snapshot #>> '{health,state}' = NEW.health_state + AND (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz = NEW.transitioned_at + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmation_history_snapshot_ck', + MESSAGE = 'Reservation Confirmation history must exactly snapshot the current validated revision'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_reservation_confirmation_history_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmation_history_append_only_ck', + MESSAGE = 'Reservation Confirmation history is append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_confirmations_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."reservation_confirmations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_confirmation_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_confirmations_lifecycle_trg" +BEFORE UPDATE OR DELETE ON "inventory"."reservation_confirmations" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_confirmation_lifecycle"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_confirmation_history_scope_trg" +BEFORE INSERT ON "inventory"."reservation_confirmation_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_confirmation_history_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_confirmation_history_no_update_trg" +BEFORE UPDATE ON "inventory"."reservation_confirmation_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_reservation_confirmation_history_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_confirmation_history_no_delete_trg" +BEFORE DELETE ON "inventory"."reservation_confirmation_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_reservation_confirmation_history_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_confirmation_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_confirmation_lifecycle"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_confirmation_history_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_reservation_confirmation_history_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924204859_inventory-reservation-confirmations/snapshot.json b/app/verticals/inventory/drizzle/20260924204859_inventory-reservation-confirmations/snapshot.json new file mode 100644 index 000000000..cc4634662 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924204859_inventory-reservation-confirmations/snapshot.json @@ -0,0 +1,9972 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "54b2df4c-16c1-416e-b87f-2c4ca6ae900a", + "prevIds": [ + "c663e686-bedd-4d16-b598-698391b61dac" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924211533_inventory-reservation-shortage-impacts/migration.sql b/app/verticals/inventory/drizzle/20260924211533_inventory-reservation-shortage-impacts/migration.sql new file mode 100644 index 000000000..1d32ee080 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924211533_inventory-reservation-shortage-impacts/migration.sql @@ -0,0 +1,1159 @@ +CREATE TABLE "inventory"."reservation_shortage_impact_decisions" ( + "tenant_id" uuid, + "change_kind" text, + "change_id" uuid, + "confirmation_id" uuid, + "priority_ordinal" integer, + "decision" text NOT NULL, + "affected_amount" numeric(38,9), + "health_before" text NOT NULL, + "health_after" text NOT NULL, + "confirmation_revision_before" integer NOT NULL, + "confirmation_revision_after" integer NOT NULL, + "rank_issued_at" timestamp with time zone NOT NULL, + "rank_owner_evidence_ref" text NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_shortage_impact_decisions_pk" PRIMARY KEY("tenant_id","change_kind","change_id","confirmation_id"), + CONSTRAINT "inventory_reservation_shortage_impact_decisions_meaning_ck" CHECK ("decision" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and "health_before" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and "health_after" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and "confirmation_revision_before" >= 1 and "confirmation_revision_after" >= "confirmation_revision_before" and char_length(btrim("rank_owner_evidence_ref")) between 1 and 300 and (("decision" = 'ORDER_UNRESOLVABLE' and "priority_ordinal" is null and "affected_amount" is null) or ("decision" in ('HONORABLE', 'SHORTAGE') and "priority_ordinal" >= 1 and "affected_amount" > 0))) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impact_decisions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."reservation_shortage_impacts" ( + "tenant_id" uuid, + "change_kind" text, + "change_id" uuid, + "physical_effect_id" uuid, + "stock_correction_id" uuid, + "position_id" uuid NOT NULL, + "position_revision" integer NOT NULL, + "available_amount" numeric(38,9) NOT NULL, + "fenced_amount" numeric(38,9) NOT NULL, + "occurred_at" timestamp with time zone NOT NULL, + "status" text NOT NULL, + "reconciliation_required" boolean NOT NULL, + "reason" text, + "decision_count" integer NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_shortage_impacts_pk" PRIMARY KEY("tenant_id","change_kind","change_id"), + CONSTRAINT "inventory_reservation_shortage_impacts_source_ck" CHECK (("change_kind" in ('RECEIPT', 'ISSUE') and "physical_effect_id" = "change_id" and "stock_correction_id" is null) or ("change_kind" = 'CORRECTION' and "stock_correction_id" = "change_id" and "physical_effect_id" is null)), + CONSTRAINT "inventory_reservation_shortage_impacts_outcome_ck" CHECK (("status" = 'DETERMINATE' and "reconciliation_required" = false and "reason" is null) or ("status" = 'INDETERMINATE' and "reconciliation_required" = true and "reason" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')), + CONSTRAINT "inventory_reservation_shortage_impacts_quantity_ck" CHECK ("position_revision" >= 1 and "available_amount" >= 0 and "fenced_amount" >= 0 and "decision_count" >= 0) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impacts" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_shortage_impact_decisions_priority_uk" ON "inventory"."reservation_shortage_impact_decisions" ("tenant_id","change_kind","change_id","priority_ordinal") WHERE "priority_ordinal" is not null;--> statement-breakpoint +CREATE INDEX "inventory_reservation_shortage_impact_decisions_confirmation_idx" ON "inventory"."reservation_shortage_impact_decisions" ("tenant_id","confirmation_id","recorded_at");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_shortage_impacts_effect_uk" ON "inventory"."reservation_shortage_impacts" ("tenant_id","physical_effect_id") WHERE "physical_effect_id" is not null;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_shortage_impacts_correction_uk" ON "inventory"."reservation_shortage_impacts" ("tenant_id","stock_correction_id") WHERE "stock_correction_id" is not null;--> statement-breakpoint +CREATE INDEX "inventory_reservation_shortage_impacts_position_time_idx" ON "inventory"."reservation_shortage_impacts" ("tenant_id","position_id","occurred_at");--> statement-breakpoint +CREATE INDEX "inventory_reservation_shortage_impacts_unresolved_idx" ON "inventory"."reservation_shortage_impacts" ("tenant_id","position_id") WHERE "status" = 'INDETERMINATE';--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impact_decisions" ADD CONSTRAINT "inventory_reservation_shortage_impact_decisions_impact_fk" FOREIGN KEY ("tenant_id","change_kind","change_id") REFERENCES "inventory"."reservation_shortage_impacts"("tenant_id","change_kind","change_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impact_decisions" ADD CONSTRAINT "inventory_reservation_shortage_impact_decisions_confirmation_fk" FOREIGN KEY ("tenant_id","confirmation_id") REFERENCES "inventory"."reservation_confirmations"("tenant_id","confirmation_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impacts" ADD CONSTRAINT "inventory_reservation_shortage_impacts_position_fk" FOREIGN KEY ("tenant_id","position_id") REFERENCES "inventory"."stock_positions"("tenant_id","stock_position_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impacts" ADD CONSTRAINT "inventory_reservation_shortage_impacts_effect_fk" FOREIGN KEY ("tenant_id","physical_effect_id") REFERENCES "inventory"."physical_stock_effects"("tenant_id","effect_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impacts" ADD CONSTRAINT "inventory_reservation_shortage_impacts_correction_fk" FOREIGN KEY ("tenant_id","stock_correction_id") REFERENCES "inventory"."stock_corrections"("tenant_id","correction_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impact_decisions_tenant_select" ON "inventory"."reservation_shortage_impact_decisions" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_shortage_impact_decisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impact_decisions_tenant_insert" ON "inventory"."reservation_shortage_impact_decisions" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_shortage_impact_decisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impact_decisions_tenant_update" ON "inventory"."reservation_shortage_impact_decisions" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_shortage_impact_decisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_shortage_impact_decisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impact_decisions_tenant_delete" ON "inventory"."reservation_shortage_impact_decisions" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_shortage_impact_decisions"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impacts_tenant_select" ON "inventory"."reservation_shortage_impacts" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_shortage_impacts"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impacts_tenant_insert" ON "inventory"."reservation_shortage_impacts" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_shortage_impacts"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impacts_tenant_update" ON "inventory"."reservation_shortage_impacts" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_shortage_impacts"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_shortage_impacts"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_shortage_impacts_tenant_delete" ON "inventory"."reservation_shortage_impacts" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_shortage_impacts"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impact_decisions" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_shortage_impacts" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_shortage_impact_source"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + expected_affected_amount numeric(38, 9); + expected_fenced_amount numeric(38, 9); + position_matches boolean; +BEGIN + IF TG_TABLE_NAME = 'reservation_shortage_impacts' THEN + PERFORM 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.position_id + AND position.lifecycle_state = 'CURRENT' + AND position.on_hand_state = 'CURRENT' + AND position.revision = NEW.position_revision + AND position.on_hand_amount = NEW.available_amount + FOR UPDATE; + + position_matches := FOUND; + + SELECT coalesce(pg_catalog.sum(allocation.allocated_amount), 0) + INTO expected_fenced_amount + FROM "inventory"."obligation_allocations" AS allocation + JOIN "inventory"."obligations" AS obligation + ON obligation.tenant_id = allocation.tenant_id + AND obligation.obligation_id = allocation.obligation_id + WHERE allocation.tenant_id = NEW.tenant_id + AND allocation.stock_position_id = NEW.position_id + AND ( + obligation.lifecycle_meaning = 'COMMITTED_OBLIGATION' + OR EXISTS ( + SELECT 1 + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = allocation.tenant_id + AND confirmation.reservation_id = allocation.obligation_id + AND confirmation.current_health_state IN ('EXPIRED', 'REVOKED') + ) + ); + + IF NOT position_matches + OR NEW.fenced_amount IS DISTINCT FROM expected_fenced_amount + OR ( + NEW.change_kind IN ('RECEIPT', 'ISSUE') + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."physical_stock_effects" AS effect + WHERE effect.tenant_id = NEW.tenant_id + AND effect.effect_id = NEW.physical_effect_id + AND effect.effect_id = NEW.change_id + AND effect.kind = NEW.change_kind + AND effect.position_id = NEW.position_id + AND effect.state = 'APPLIED' + AND effect.evidence_json ->> 'effectId' = NEW.change_id::text + AND effect.evidence_json ->> 'kind' = NEW.change_kind + AND effect.evidence_json #>> '{positionRef,tenantId}' = NEW.tenant_id::text + AND effect.evidence_json #>> '{positionRef,resourceId}' = NEW.position_id::text + AND (effect.evidence_json ->> 'appliedAt')::timestamptz = NEW.occurred_at + AND EXISTS ( + SELECT 1 + FROM "inventory"."stock_positions" AS current_position + WHERE current_position.tenant_id = NEW.tenant_id + AND current_position.stock_position_id = NEW.position_id + AND current_position.on_hand_observed_at + = (effect.evidence_json ->> 'appliedAt')::timestamptz + AND current_position.on_hand_evidence_ref + = effect.evidence_json ->> 'backendEvidenceRef' + ) + ) + ) + OR ( + NEW.change_kind = 'CORRECTION' + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."stock_corrections" AS correction + WHERE correction.tenant_id = NEW.tenant_id + AND correction.correction_id = NEW.stock_correction_id + AND correction.correction_id = NEW.change_id + AND correction.position_id = NEW.position_id + AND correction.state = 'APPLIED' + AND correction.position_revision_after = NEW.position_revision + AND correction.corrected_quantity_amount = NEW.available_amount + AND correction.applied_at = NEW.occurred_at + AND correction.record_json ->> 'correctionId' = NEW.change_id::text + AND correction.record_json #>> '{positionRef,tenantId}' = NEW.tenant_id::text + AND correction.record_json #>> '{positionRef,resourceId}' = NEW.position_id::text + AND (correction.record_json ->> 'positionRevisionAfter')::integer = NEW.position_revision + AND (correction.record_json #>> '{correctedQuantity,amount}')::numeric = NEW.available_amount + AND (correction.record_json ->> 'appliedAt')::timestamptz = NEW.occurred_at + AND EXISTS ( + SELECT 1 + FROM "inventory"."stock_positions" AS current_position + WHERE current_position.tenant_id = NEW.tenant_id + AND current_position.stock_position_id = NEW.position_id + AND current_position.on_hand_observed_at = correction.business_observed_at + AND current_position.on_hand_evidence_ref = correction.owner_evidence_ref + ) + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_exact_source_ck', + MESSAGE = 'Reservation shortage impact must reference the exact applied source and Current Position revision'; + END IF; + + RETURN NEW; + END IF; + + PERFORM 1 + FROM "inventory"."reservation_shortage_impacts" AS impact + WHERE impact.tenant_id = NEW.tenant_id + AND impact.change_kind = NEW.change_kind + AND impact.change_id = NEW.change_id + FOR KEY SHARE; + + IF NOT FOUND + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_confirmations" AS confirmation + JOIN "inventory"."reservation_shortage_impacts" AS impact + ON impact.tenant_id = NEW.tenant_id + AND impact.change_kind = NEW.change_kind + AND impact.change_id = NEW.change_id + WHERE confirmation.tenant_id = NEW.tenant_id + AND confirmation.confirmation_id = NEW.confirmation_id + AND confirmation.current_health_state = NEW.health_after + AND confirmation.current_revision = NEW.confirmation_revision_after + AND (confirmation.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz = NEW.rank_issued_at + AND confirmation.snapshot #>> '{issuanceRank,ownerEvidenceRef}' = NEW.rank_owner_evidence_ref + AND EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + confirmation.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS allocation(entry) + WHERE allocation.entry #>> '{positionRef,tenantId}' = NEW.tenant_id::text + AND allocation.entry #>> '{positionRef,resourceId}' = impact.position_id::text + ) + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_confirmation_history" AS before_history + WHERE before_history.tenant_id = NEW.tenant_id + AND before_history.confirmation_id = NEW.confirmation_id + AND before_history.revision = NEW.confirmation_revision_before + AND before_history.health_state = NEW.health_before + AND (before_history.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz = NEW.rank_issued_at + AND before_history.snapshot #>> '{issuanceRank,ownerEvidenceRef}' = NEW.rank_owner_evidence_ref + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_confirmation_history" AS after_history + WHERE after_history.tenant_id = NEW.tenant_id + AND after_history.confirmation_id = NEW.confirmation_id + AND after_history.revision = NEW.confirmation_revision_after + AND after_history.health_state = NEW.health_after + AND (after_history.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz = NEW.rank_issued_at + AND after_history.snapshot #>> '{issuanceRank,ownerEvidenceRef}' = NEW.rank_owner_evidence_ref + ) + OR ( + NEW.decision IN ('HONORABLE', 'ORDER_UNRESOLVABLE') + AND ( + NEW.health_after IS DISTINCT FROM NEW.health_before + OR NEW.confirmation_revision_after IS DISTINCT FROM NEW.confirmation_revision_before + ) + ) + OR ( + NEW.decision = 'SHORTAGE' + AND ( + ( + NEW.health_before = 'VALID' + AND ( + NEW.health_after IS DISTINCT FROM 'AT_RISK' + OR NEW.confirmation_revision_after IS DISTINCT FROM NEW.confirmation_revision_before + 1 + ) + ) + OR ( + NEW.health_before IN ('AT_RISK', 'UNVERIFIABLE') + AND ( + NEW.health_after IS DISTINCT FROM NEW.health_before + OR NEW.confirmation_revision_after IS DISTINCT FROM NEW.confirmation_revision_before + ) + ) + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impact_decisions_exact_scope_ck', + MESSAGE = 'Reservation shortage decision must preserve the exact Confirmation scope, rank, and health transition'; + END IF; + + IF NEW.decision IN ('HONORABLE', 'SHORTAGE') THEN + SELECT pg_catalog.sum((allocation.entry #>> '{quantity,amount}')::numeric) + INTO expected_affected_amount + FROM "inventory"."reservation_confirmations" AS confirmation + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + confirmation.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS allocation(entry) + JOIN "inventory"."reservation_shortage_impacts" AS impact + ON impact.tenant_id = NEW.tenant_id + AND impact.change_kind = NEW.change_kind + AND impact.change_id = NEW.change_id + WHERE confirmation.tenant_id = NEW.tenant_id + AND confirmation.confirmation_id = NEW.confirmation_id + AND allocation.entry #>> '{positionRef,tenantId}' = NEW.tenant_id::text + AND allocation.entry #>> '{positionRef,resourceId}' = impact.position_id::text; + + IF expected_affected_amount IS NULL + OR NEW.affected_amount IS DISTINCT FROM expected_affected_amount + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impact_decisions_exact_scope_ck', + MESSAGE = 'Reservation shortage decision affected amount must equal the exact Position allocation total'; + END IF; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."verify_reservation_shortage_impact_decisions"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + impact "inventory"."reservation_shortage_impacts"%ROWTYPE; + stored_count integer; +BEGIN + SELECT stored.* + INTO impact + FROM "inventory"."reservation_shortage_impacts" AS stored + WHERE stored.tenant_id = NEW.tenant_id + AND stored.change_kind = NEW.change_kind + AND stored.change_id = NEW.change_id; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_exact_decisions_ck', + MESSAGE = 'Reservation shortage decisions require one exact parent impact'; + END IF; + + SELECT pg_catalog.count(*)::integer + INTO stored_count + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id; + + IF stored_count IS DISTINCT FROM impact.decision_count + OR ( + impact.status = 'DETERMINATE' + AND ( + EXISTS ( + SELECT 1 + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + AND ( + decision.decision NOT IN ('HONORABLE', 'SHORTAGE') + OR decision.priority_ordinal IS NULL + OR decision.affected_amount IS NULL + ) + ) + OR ( + SELECT pg_catalog.count(DISTINCT decision.priority_ordinal) + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + ) IS DISTINCT FROM impact.decision_count + OR ( + SELECT coalesce(pg_catalog.min(decision.priority_ordinal), 1) + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + ) IS DISTINCT FROM 1 + OR ( + SELECT coalesce(pg_catalog.max(decision.priority_ordinal), 0) + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + ) IS DISTINCT FROM impact.decision_count + OR ( + SELECT pg_catalog.count(DISTINCT decision.rank_issued_at) + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + ) IS DISTINCT FROM impact.decision_count + OR EXISTS ( + SELECT 1 + FROM ( + SELECT + decision.decision, + decision.priority_ordinal, + pg_catalog.row_number() OVER ( + ORDER BY decision.rank_issued_at, decision.confirmation_id + ) AS expected_ordinal, + pg_catalog.sum(decision.affected_amount) OVER ( + ORDER BY decision.priority_ordinal + ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + ) AS cumulative_amount + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + ) AS ordered + WHERE ordered.priority_ordinal IS DISTINCT FROM ordered.expected_ordinal + OR ordered.decision IS DISTINCT FROM CASE + WHEN ordered.cumulative_amount + <= pg_catalog.greatest(impact.available_amount - impact.fenced_amount, 0) + THEN 'HONORABLE' + ELSE 'SHORTAGE' + END + ) + ) + ) + OR ( + impact.status = 'INDETERMINATE' + AND ( + impact.decision_count < 2 + OR EXISTS ( + SELECT 1 + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + AND ( + decision.decision IS DISTINCT FROM 'ORDER_UNRESOLVABLE' + OR decision.priority_ordinal IS NOT NULL + OR decision.affected_amount IS NOT NULL + ) + ) + OR ( + SELECT pg_catalog.count(DISTINCT decision.rank_issued_at) + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = impact.tenant_id + AND decision.change_kind = impact.change_kind + AND decision.change_id = impact.change_id + ) >= impact.decision_count + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_exact_decisions_ck', + MESSAGE = 'Reservation shortage decisions must exactly cover the authoritative rank without gaps or skips'; + END IF; + + RETURN NULL; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_reservation_shortage_impact_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_append_only_ck', + MESSAGE = 'Reservation shortage impact evidence is append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_shortage_impacts_source_trg" +BEFORE INSERT ON "inventory"."reservation_shortage_impacts" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_shortage_impact_source"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_shortage_impact_decisions_exact_scope_trg" +BEFORE INSERT ON "inventory"."reservation_shortage_impact_decisions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_shortage_impact_source"(); +--> statement-breakpoint +CREATE CONSTRAINT TRIGGER "inventory_reservation_shortage_impacts_decision_set_trg" +AFTER INSERT ON "inventory"."reservation_shortage_impacts" +DEFERRABLE INITIALLY DEFERRED +FOR EACH ROW EXECUTE FUNCTION "inventory"."verify_reservation_shortage_impact_decisions"(); +--> statement-breakpoint +CREATE CONSTRAINT TRIGGER "inventory_reservation_shortage_impact_decisions_decision_set_trg" +AFTER INSERT ON "inventory"."reservation_shortage_impact_decisions" +DEFERRABLE INITIALLY DEFERRED +FOR EACH ROW EXECUTE FUNCTION "inventory"."verify_reservation_shortage_impact_decisions"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_shortage_impacts_no_mutation_trg" +BEFORE UPDATE OR DELETE ON "inventory"."reservation_shortage_impacts" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_reservation_shortage_impact_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_shortage_impact_decisions_no_mutation_trg" +BEFORE UPDATE OR DELETE ON "inventory"."reservation_shortage_impact_decisions" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_reservation_shortage_impact_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_shortage_impact_source"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."verify_reservation_shortage_impact_decisions"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_reservation_shortage_impact_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE FUNCTION "inventory"."find_reservation_shortage_impact_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_change_kind text, + p_change_id uuid +) RETURNS TABLE(found boolean) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation shortage impact worker scope mismatch'; + END IF; + + IF p_change_kind NOT IN ('RECEIPT', 'ISSUE') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_worker_source_ck', + MESSAGE = 'Only physical stock effects may be evaluated by the shortage impact worker'; + END IF; + + RETURN QUERY + SELECT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_shortage_impacts" AS impact + JOIN "inventory"."physical_stock_effects" AS effect + ON effect.tenant_id = impact.tenant_id + AND effect.effect_id = impact.physical_effect_id + AND effect.legal_entity_id = p_legal_entity_id + WHERE impact.tenant_id = p_tenant_id + AND impact.change_kind = p_change_kind + AND impact.change_id = p_change_id + AND effect.kind = p_change_kind + AND effect.position_id = impact.position_id + ); +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."read_reservation_shortage_impact_context_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_change_kind text, + p_change_id uuid, + p_position_id uuid, + p_occurred_at timestamptz +) RETURNS TABLE(context jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + candidate_set jsonb; + evidence_ref text; + fenced_amount numeric(38, 9); + position "inventory"."stock_positions"%ROWTYPE; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation shortage impact worker scope mismatch'; + END IF; + + IF p_change_kind NOT IN ('RECEIPT', 'ISSUE') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_exact_source_ck', + MESSAGE = 'Reservation shortage impact worker source kind is invalid'; + END IF; + + SELECT stored.* + INTO position + FROM "inventory"."stock_positions" AS stored + WHERE stored.tenant_id = p_tenant_id + AND stored.stock_position_id = p_position_id + AND stored.lifecycle_state = 'CURRENT' + AND stored.on_hand_state = 'CURRENT' + AND stored.on_hand_amount IS NOT NULL + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + SELECT effect.evidence_json ->> 'backendEvidenceRef' + INTO evidence_ref + FROM "inventory"."physical_stock_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_change_id + AND effect.position_id = p_position_id + AND effect.kind = p_change_kind + AND effect.state = 'APPLIED' + AND (effect.evidence_json ->> 'appliedAt')::timestamptz = p_occurred_at + AND position.on_hand_observed_at = (effect.evidence_json ->> 'appliedAt')::timestamptz + AND position.on_hand_evidence_ref = effect.evidence_json ->> 'backendEvidenceRef' + FOR UPDATE; + + IF evidence_ref IS NULL THEN + RETURN; + END IF; + + WITH candidate_rows AS ( + SELECT DISTINCT + confirmation.confirmation_id, + confirmation.snapshot, + reservation.lifecycle_meaning + FROM "inventory"."reservation_confirmations" AS confirmation + JOIN "inventory"."obligations" AS reservation + ON reservation.tenant_id = confirmation.tenant_id + AND reservation.obligation_id = confirmation.reservation_id + JOIN "inventory"."obligation_allocations" AS allocation + ON allocation.tenant_id = confirmation.tenant_id + AND allocation.obligation_id = confirmation.reservation_id + AND allocation.stock_position_id = p_position_id + WHERE confirmation.tenant_id = p_tenant_id + ) + SELECT coalesce( + pg_catalog.jsonb_agg( + pg_catalog.jsonb_build_object( + 'allocations', ( + SELECT coalesce(pg_catalog.jsonb_agg(stored_allocation.entry), '[]'::jsonb) + FROM pg_catalog.jsonb_array_elements( + candidate.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS stored_allocation(entry) + ), + 'confirmation', candidate.snapshot, + 'poolBoundary', CASE candidate.lifecycle_meaning + WHEN 'COMMITTED_OBLIGATION' THEN 'COMMITTED_OBLIGATION' + ELSE 'NONE' + END + ) ORDER BY + (candidate.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz, + candidate.confirmation_id + ), + '[]'::jsonb + ) + INTO candidate_set + FROM candidate_rows AS candidate; + + SELECT coalesce(pg_catalog.sum((allocation.entry #>> '{quantity,amount}')::numeric), 0) + INTO fenced_amount + FROM pg_catalog.jsonb_array_elements(candidate_set) AS fenced(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements(fenced.entry -> 'allocations') AS allocation(entry) + WHERE ( + fenced.entry ->> 'poolBoundary' = 'COMMITTED_OBLIGATION' + OR ( + fenced.entry ->> 'poolBoundary' = 'NONE' + AND fenced.entry #>> '{confirmation,health,state}' IN ('EXPIRED', 'REVOKED') + ) + ) + AND allocation.entry #>> '{positionRef,tenantId}' = p_tenant_id::text + AND allocation.entry #>> '{positionRef,resourceId}' = p_position_id::text; + + RETURN QUERY SELECT pg_catalog.jsonb_build_object( + 'causeEvidenceRef', evidence_ref, + 'evaluationInput', pg_catalog.jsonb_build_object( + 'affectedPositionRef', pg_catalog.jsonb_build_object( + 'moduleId', 'commerce.inventory', + 'resourceId', position.stock_position_id, + 'resourceType', 'commerce.inventory.stock-position', + 'tenantId', position.tenant_id + ), + 'availableQuantity', pg_catalog.jsonb_build_object( + 'amount', pg_catalog.trim_scale(position.on_hand_amount)::text, + 'unitRef', pg_catalog.jsonb_build_object( + 'moduleId', position.stock_unit_module_id, + 'resourceId', position.stock_unit_resource_id, + 'resourceType', position.stock_unit_resource_type, + 'tenantId', position.stock_unit_tenant_id + ) + ), + 'candidates', candidate_set + ), + 'fencedAmount', pg_catalog.trim_scale(fenced_amount)::text, + 'positionRevision', position.revision + ); +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."apply_reservation_shortage_impact_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_change_kind text, + p_change_id uuid, + p_position_id uuid, + p_occurred_at timestamptz, + p_evaluation jsonb +) RETURNS TABLE(applied boolean) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + after_snapshot jsonb; + candidate jsonb; + candidate_count integer; + cause_evidence_ref text; + context_record jsonb; + current_confirmation "inventory"."reservation_confirmations"%ROWTYPE; + decision jsonb; + decision_count integer; + decision_index integer := 0; + evaluation_tag text; + expected_amount numeric(38, 9); + expected_fenced_amount numeric(38, 9); + existing_impact "inventory"."reservation_shortage_impacts"%ROWTYPE; + owner_evidence_ref text; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation shortage impact worker scope mismatch'; + END IF; + + IF p_change_kind NOT IN ('RECEIPT', 'ISSUE') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_worker_source_ck', + MESSAGE = 'Only physical stock effects may be applied by the shortage impact worker'; + END IF; + + SELECT impact.* + INTO existing_impact + FROM "inventory"."reservation_shortage_impacts" AS impact + JOIN "inventory"."physical_stock_effects" AS effect + ON effect.tenant_id = impact.tenant_id + AND effect.effect_id = impact.physical_effect_id + AND effect.legal_entity_id = p_legal_entity_id + WHERE impact.tenant_id = p_tenant_id + AND impact.change_kind = p_change_kind + AND impact.change_id = p_change_id + AND effect.kind = p_change_kind + AND effect.position_id = impact.position_id + FOR KEY SHARE; + + evaluation_tag := p_evaluation ->> '_tag'; + IF FOUND THEN + IF existing_impact.position_id IS DISTINCT FROM p_position_id + OR existing_impact.occurred_at IS DISTINCT FROM p_occurred_at + OR evaluation_tag IS DISTINCT FROM existing_impact.status + OR (p_evaluation ->> 'fencedAmount')::numeric IS DISTINCT FROM existing_impact.fenced_amount + OR p_evaluation #>> '{affectedPositionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR p_evaluation #>> '{affectedPositionRef,resourceType}' + IS DISTINCT FROM 'commerce.inventory.stock-position' + OR p_evaluation #>> '{affectedPositionRef,tenantId}' IS DISTINCT FROM p_tenant_id::text + OR p_evaluation #>> '{affectedPositionRef,resourceId}' IS DISTINCT FROM p_position_id::text + OR ( + evaluation_tag = 'DETERMINATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_evaluation)) <> 4 + OR + pg_catalog.jsonb_typeof(p_evaluation -> 'decisions') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_evaluation -> 'decisions') IS DISTINCT FROM existing_impact.decision_count + OR ( + SELECT pg_catalog.count(DISTINCT replay.entry #>> '{confirmationRef,resourceId}') + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'decisions') AS replay(entry) + ) IS DISTINCT FROM existing_impact.decision_count + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'decisions') + WITH ORDINALITY AS replay(entry, ordinal) + WHERE NOT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_shortage_impact_decisions" AS stored + JOIN "inventory"."stock_positions" AS position + ON position.tenant_id = stored.tenant_id + AND position.stock_position_id = existing_impact.position_id + WHERE stored.tenant_id = p_tenant_id + AND stored.change_kind = p_change_kind + AND stored.change_id = p_change_id + AND stored.priority_ordinal = replay.ordinal::integer + AND stored.confirmation_id = (replay.entry #>> '{confirmationRef,resourceId}')::uuid + AND stored.decision = replay.entry ->> 'capacity' + AND stored.affected_amount = (replay.entry #>> '{affectedQuantity,amount}')::numeric + AND stored.health_before = replay.entry ->> 'currentHealth' + AND stored.rank_issued_at = (replay.entry #>> '{issuanceRank,issuedAt}')::timestamptz + AND stored.rank_owner_evidence_ref = replay.entry #>> '{issuanceRank,ownerEvidenceRef}' + AND replay.entry #>> '{confirmationRef,moduleId}' = 'commerce.inventory' + AND replay.entry #>> '{confirmationRef,resourceType}' + = 'commerce.inventory.reservation-confirmation' + AND replay.entry #>> '{confirmationRef,tenantId}' = p_tenant_id::text + AND replay.entry #>> '{affectedQuantity,unitRef,moduleId}' = position.stock_unit_module_id + AND (replay.entry #>> '{affectedQuantity,unitRef,resourceId}')::uuid + = position.stock_unit_resource_id + AND replay.entry #>> '{affectedQuantity,unitRef,resourceType}' + = position.stock_unit_resource_type + AND (replay.entry #>> '{affectedQuantity,unitRef,tenantId}')::uuid + = position.stock_unit_tenant_id + ) + ) + ) + ) + OR ( + evaluation_tag = 'INDETERMINATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_evaluation)) <> 6 + OR p_evaluation ->> 'reason' IS DISTINCT FROM existing_impact.reason + OR p_evaluation -> 'reconciliationRequired' IS DISTINCT FROM 'true'::jsonb + OR pg_catalog.jsonb_typeof(p_evaluation -> 'candidateRefs') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_evaluation -> 'candidateRefs') IS DISTINCT FROM existing_impact.decision_count + OR ( + SELECT pg_catalog.count(DISTINCT replay.entry ->> 'resourceId') + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'candidateRefs') AS replay(entry) + ) IS DISTINCT FROM existing_impact.decision_count + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'candidateRefs') + WITH ORDINALITY AS replay(entry, ordinal) + WHERE NOT EXISTS ( + SELECT 1 + FROM ( + SELECT + decision.*, + pg_catalog.row_number() OVER ( + ORDER BY decision.rank_issued_at, decision.confirmation_id + ) AS expected_ordinal + FROM "inventory"."reservation_shortage_impact_decisions" AS decision + WHERE decision.tenant_id = p_tenant_id + AND decision.change_kind = p_change_kind + AND decision.change_id = p_change_id + ) AS stored + WHERE stored.tenant_id = p_tenant_id + AND stored.change_kind = p_change_kind + AND stored.change_id = p_change_id + AND stored.expected_ordinal = replay.ordinal + AND stored.confirmation_id = (replay.entry ->> 'resourceId')::uuid + AND stored.decision = 'ORDER_UNRESOLVABLE' + AND replay.entry ->> 'moduleId' = 'commerce.inventory' + AND replay.entry ->> 'resourceType' = 'commerce.inventory.reservation-confirmation' + AND replay.entry ->> 'tenantId' = p_tenant_id::text + ) + ) + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_replay_ck', + MESSAGE = 'Reservation shortage impact replay must exactly match persisted evidence'; + END IF; + + RETURN QUERY SELECT true; + RETURN; + END IF; + + SELECT result.context + INTO context_record + FROM "inventory"."read_reservation_shortage_impact_context_for_worker"( + p_tenant_id, + p_legal_entity_id, + p_change_kind, + p_change_id, + p_position_id, + p_occurred_at + ) AS result; + + IF context_record IS NULL + OR evaluation_tag NOT IN ('DETERMINATE', 'INDETERMINATE') + OR p_evaluation #>> '{affectedPositionRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR p_evaluation #>> '{affectedPositionRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.stock-position' + OR p_evaluation #>> '{affectedPositionRef,tenantId}' IS DISTINCT FROM p_tenant_id::text + OR p_evaluation #>> '{affectedPositionRef,resourceId}' IS DISTINCT FROM p_position_id::text + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_evaluation_ck', + MESSAGE = 'Reservation shortage impact evaluation must match the locked source context'; + END IF; + + cause_evidence_ref := context_record ->> 'causeEvidenceRef'; + SELECT pg_catalog.count(*)::integer + INTO candidate_count + FROM pg_catalog.jsonb_array_elements(context_record #> '{evaluationInput,candidates}') AS eligible(entry) + WHERE eligible.entry ->> 'poolBoundary' = 'NONE' + AND eligible.entry #>> '{confirmation,health,state}' IN ('VALID', 'AT_RISK', 'UNVERIFIABLE'); + + SELECT coalesce(pg_catalog.sum((allocation.entry #>> '{quantity,amount}')::numeric), 0) + INTO expected_fenced_amount + FROM pg_catalog.jsonb_array_elements(context_record #> '{evaluationInput,candidates}') AS fenced(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements(fenced.entry -> 'allocations') AS allocation(entry) + WHERE ( + fenced.entry ->> 'poolBoundary' = 'COMMITTED_OBLIGATION' + OR ( + fenced.entry ->> 'poolBoundary' = 'NONE' + AND fenced.entry #>> '{confirmation,health,state}' IN ('EXPIRED', 'REVOKED') + ) + ) + AND allocation.entry #>> '{positionRef,tenantId}' = p_tenant_id::text + AND allocation.entry #>> '{positionRef,resourceId}' = p_position_id::text; + + IF (p_evaluation ->> 'fencedAmount')::numeric IS DISTINCT FROM expected_fenced_amount THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_fenced_amount_ck', + MESSAGE = 'Reservation shortage fenced amount must equal exact non-reusable allocation evidence'; + END IF; + + IF evaluation_tag = 'DETERMINATE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_evaluation)) <> 4 + OR pg_catalog.jsonb_typeof(p_evaluation -> 'decisions') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_evaluation -> 'decisions') IS DISTINCT FROM candidate_count + OR ( + SELECT pg_catalog.count(DISTINCT evaluated.entry #>> '{confirmationRef,resourceId}') + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'decisions') AS evaluated(entry) + ) IS DISTINCT FROM candidate_count + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_evaluation_ck', + MESSAGE = 'Determinate shortage decisions must exactly cover eligible Confirmations'; + END IF; + decision_count := pg_catalog.jsonb_array_length(p_evaluation -> 'decisions'); + ELSE + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_evaluation)) <> 6 + OR p_evaluation ->> 'reason' IS DISTINCT FROM 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE' + OR p_evaluation -> 'reconciliationRequired' IS DISTINCT FROM 'true'::jsonb + OR pg_catalog.jsonb_typeof(p_evaluation -> 'candidateRefs') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_evaluation -> 'candidateRefs') IS DISTINCT FROM candidate_count + OR ( + SELECT pg_catalog.count(DISTINCT evaluated.entry ->> 'resourceId') + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'candidateRefs') AS evaluated(entry) + ) IS DISTINCT FROM candidate_count + OR candidate_count < 2 + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_evaluation_ck', + MESSAGE = 'Indeterminate shortage evidence must exactly cover the unresolved authoritative rank'; + END IF; + decision_count := candidate_count; + END IF; + + INSERT INTO "inventory"."reservation_shortage_impacts" ( + tenant_id, + change_kind, + change_id, + physical_effect_id, + stock_correction_id, + position_id, + position_revision, + available_amount, + fenced_amount, + occurred_at, + status, + reconciliation_required, + reason, + decision_count + ) VALUES ( + p_tenant_id, + p_change_kind, + p_change_id, + CASE WHEN p_change_kind IN ('RECEIPT', 'ISSUE') THEN p_change_id END, + CASE WHEN p_change_kind = 'CORRECTION' THEN p_change_id END, + p_position_id, + (context_record ->> 'positionRevision')::integer, + (context_record #>> '{evaluationInput,availableQuantity,amount}')::numeric, + expected_fenced_amount, + p_occurred_at, + evaluation_tag, + evaluation_tag = 'INDETERMINATE', + CASE WHEN evaluation_tag = 'INDETERMINATE' THEN p_evaluation ->> 'reason' END, + decision_count + ); + + IF evaluation_tag = 'DETERMINATE' THEN + FOR decision IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'decisions') AS evaluated(entry) + LOOP + decision_index := decision_index + 1; + SELECT eligible.entry + INTO candidate + FROM pg_catalog.jsonb_array_elements(context_record #> '{evaluationInput,candidates}') AS eligible(entry) + WHERE eligible.entry ->> 'poolBoundary' = 'NONE' + AND eligible.entry #>> '{confirmation,health,state}' IN ('VALID', 'AT_RISK', 'UNVERIFIABLE') + AND eligible.entry #>> '{confirmation,ref,resourceId}' = decision #>> '{confirmationRef,resourceId}'; + + SELECT pg_catalog.sum((allocation.entry #>> '{quantity,amount}')::numeric) + INTO expected_amount + FROM pg_catalog.jsonb_array_elements(candidate -> 'allocations') AS allocation(entry) + WHERE allocation.entry #>> '{positionRef,tenantId}' = p_tenant_id::text + AND allocation.entry #>> '{positionRef,resourceId}' = p_position_id::text; + + IF candidate IS NULL + OR decision ->> 'capacity' NOT IN ('HONORABLE', 'SHORTAGE') + OR decision #>> '{confirmationRef,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR decision #>> '{confirmationRef,resourceType}' IS DISTINCT FROM 'commerce.inventory.reservation-confirmation' + OR decision #>> '{confirmationRef,tenantId}' IS DISTINCT FROM p_tenant_id::text + OR decision ->> 'currentHealth' IS DISTINCT FROM candidate #>> '{confirmation,health,state}' + OR decision -> 'issuanceRank' IS DISTINCT FROM candidate #> '{confirmation,issuanceRank}' + OR (decision #>> '{affectedQuantity,amount}')::numeric IS DISTINCT FROM expected_amount + OR decision #> '{affectedQuantity,unitRef}' + IS DISTINCT FROM context_record #> '{evaluationInput,availableQuantity,unitRef}' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_evaluation_ck', + MESSAGE = 'Shortage decision must exactly match one eligible Confirmation allocation'; + END IF; + + SELECT confirmation.* + INTO current_confirmation + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = p_tenant_id + AND confirmation.confirmation_id = (decision #>> '{confirmationRef,resourceId}')::uuid + FOR UPDATE; + + IF current_confirmation.snapshot IS DISTINCT FROM candidate -> 'confirmation' THEN + RAISE EXCEPTION USING + ERRCODE = '40001', + MESSAGE = 'Reservation Confirmation changed while applying shortage impact'; + END IF; + + IF decision ->> 'capacity' = 'SHORTAGE' AND current_confirmation.current_health_state = 'VALID' THEN + owner_evidence_ref := pg_catalog.left( + 'stock-change:' || pg_catalog.lower(p_change_kind) || ':' || cause_evidence_ref, + 300 + ); + after_snapshot := pg_catalog.jsonb_set( + pg_catalog.jsonb_set( + current_confirmation.snapshot, + '{health}', + pg_catalog.jsonb_build_object( + 'state', 'AT_RISK', + 'observation', pg_catalog.jsonb_build_object( + '_tag', 'MATERIAL_IMPAIRMENT', + 'effectiveAt', p_occurred_at, + 'ownerEvidenceRef', owner_evidence_ref + ) + ) + ), + '{revision}', + pg_catalog.to_jsonb(current_confirmation.current_revision + 1) + ); + + UPDATE "inventory"."reservation_confirmations" + SET current_health_state = 'AT_RISK', + current_revision = current_confirmation.current_revision + 1, + snapshot = after_snapshot, + updated_at = pg_catalog.clock_timestamp() + WHERE tenant_id = p_tenant_id + AND confirmation_id = current_confirmation.confirmation_id + AND current_revision = current_confirmation.current_revision; + + INSERT INTO "inventory"."reservation_confirmation_history" ( + tenant_id, + confirmation_id, + revision, + health_state, + snapshot, + transitioned_at + ) VALUES ( + p_tenant_id, + current_confirmation.confirmation_id, + current_confirmation.current_revision + 1, + 'AT_RISK', + after_snapshot, + p_occurred_at + ); + ELSE + after_snapshot := current_confirmation.snapshot; + END IF; + + INSERT INTO "inventory"."reservation_shortage_impact_decisions" ( + tenant_id, + change_kind, + change_id, + confirmation_id, + priority_ordinal, + decision, + affected_amount, + health_before, + health_after, + confirmation_revision_before, + confirmation_revision_after, + rank_issued_at, + rank_owner_evidence_ref + ) VALUES ( + p_tenant_id, + p_change_kind, + p_change_id, + current_confirmation.confirmation_id, + decision_index, + decision ->> 'capacity', + expected_amount, + current_confirmation.current_health_state, + after_snapshot #>> '{health,state}', + current_confirmation.current_revision, + (after_snapshot ->> 'revision')::integer, + (decision #>> '{issuanceRank,issuedAt}')::timestamptz, + decision #>> '{issuanceRank,ownerEvidenceRef}' + ); + END LOOP; + ELSE + FOR decision IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(p_evaluation -> 'candidateRefs') AS evaluated(entry) + LOOP + SELECT eligible.entry + INTO candidate + FROM pg_catalog.jsonb_array_elements(context_record #> '{evaluationInput,candidates}') AS eligible(entry) + WHERE eligible.entry ->> 'poolBoundary' = 'NONE' + AND eligible.entry #>> '{confirmation,health,state}' IN ('VALID', 'AT_RISK', 'UNVERIFIABLE') + AND eligible.entry #>> '{confirmation,ref,resourceId}' = decision ->> 'resourceId'; + + IF candidate IS NULL + OR decision ->> 'moduleId' IS DISTINCT FROM 'commerce.inventory' + OR decision ->> 'resourceType' IS DISTINCT FROM 'commerce.inventory.reservation-confirmation' + OR decision ->> 'tenantId' IS DISTINCT FROM p_tenant_id::text + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_evaluation_ck', + MESSAGE = 'Indeterminate shortage candidate must exactly match one eligible Confirmation'; + END IF; + + SELECT confirmation.* + INTO current_confirmation + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = p_tenant_id + AND confirmation.confirmation_id = (decision ->> 'resourceId')::uuid + FOR KEY SHARE; + + IF current_confirmation.snapshot IS DISTINCT FROM candidate -> 'confirmation' THEN + RAISE EXCEPTION USING + ERRCODE = '40001', + MESSAGE = 'Reservation Confirmation changed while applying shortage impact'; + END IF; + + INSERT INTO "inventory"."reservation_shortage_impact_decisions" ( + tenant_id, + change_kind, + change_id, + confirmation_id, + priority_ordinal, + decision, + affected_amount, + health_before, + health_after, + confirmation_revision_before, + confirmation_revision_after, + rank_issued_at, + rank_owner_evidence_ref + ) VALUES ( + p_tenant_id, + p_change_kind, + p_change_id, + current_confirmation.confirmation_id, + NULL, + 'ORDER_UNRESOLVABLE', + NULL, + current_confirmation.current_health_state, + current_confirmation.current_health_state, + current_confirmation.current_revision, + current_confirmation.current_revision, + (current_confirmation.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz, + current_confirmation.snapshot #>> '{issuanceRank,ownerEvidenceRef}' + ); + END LOOP; + END IF; + + RETURN QUERY SELECT true; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."find_reservation_shortage_impact_for_worker"(uuid, uuid, text, uuid) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."read_reservation_shortage_impact_context_for_worker"(uuid, uuid, text, uuid, uuid, timestamptz) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."apply_reservation_shortage_impact_for_worker"(uuid, uuid, text, uuid, uuid, timestamptz, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."find_reservation_shortage_impact_for_worker"(uuid, uuid, text, uuid) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."read_reservation_shortage_impact_context_for_worker"(uuid, uuid, text, uuid, uuid, timestamptz) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."apply_reservation_shortage_impact_for_worker"(uuid, uuid, text, uuid, uuid, timestamptz, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924211533_inventory-reservation-shortage-impacts/snapshot.json b/app/verticals/inventory/drizzle/20260924211533_inventory-reservation-shortage-impacts/snapshot.json new file mode 100644 index 000000000..b68dc35b1 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924211533_inventory-reservation-shortage-impacts/snapshot.json @@ -0,0 +1,10811 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "0d9900a5-4fbb-47d6-ae8f-18a76914f28b", + "prevIds": [ + "54b2df4c-16c1-416e-b87f-2c4ca6ae900a" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924213441_inventory-reservation-release-effects/migration.sql b/app/verticals/inventory/drizzle/20260924213441_inventory-reservation-release-effects/migration.sql new file mode 100644 index 000000000..7dbb640a8 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924213441_inventory-reservation-release-effects/migration.sql @@ -0,0 +1,788 @@ +CREATE TABLE "inventory"."reservation_release_effect_history" ( + "history_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "release_effect_id" text NOT NULL, + "revision" integer NOT NULL, + "state" text NOT NULL, + "snapshot" jsonb NOT NULL, + "transitioned_at" timestamp with time zone NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_release_effect_history_meaning_ck" CHECK ("state" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and "revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effect_history" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."reservation_release_effects" ( + "release_effect_record_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "release_effect_id" text NOT NULL, + "mutation_id" uuid NOT NULL, + "source_action_invocation_id" uuid NOT NULL, + "legal_entity_id" uuid NOT NULL, + "reservation_id" uuid NOT NULL, + "attempt_id" text NOT NULL, + "owner_configuration_id" uuid NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "current_state" text DEFAULT 'REQUESTED' NOT NULL, + "current_revision" integer DEFAULT 1 NOT NULL, + "snapshot" jsonb NOT NULL, + "requested_at" timestamp with time zone NOT NULL, + "released_at" timestamp with time zone, + "owner_evidence_ref" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_reservation_release_effects_meaning_ck" CHECK (char_length(btrim("release_effect_id")) between 1 and 300 and char_length(btrim("attempt_id")) between 1 and 300 and char_length(btrim("issuer_backend_id")) between 1 and 300 and "issuer_backend_kind" in ('external_business_system', 'ontos_wms') and "current_state" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and "current_revision" >= 1 and (("current_state" = 'RELEASED' and "released_at" is not null and "owner_evidence_ref" is not null) or ("current_state" <> 'RELEASED' and "released_at" is null and "owner_evidence_ref" is null))) +); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effects" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_release_effect_history_scope_id_uk" ON "inventory"."reservation_release_effect_history" ("tenant_id","history_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_release_effect_history_revision_uk" ON "inventory"."reservation_release_effect_history" ("tenant_id","release_effect_id","revision");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_release_effects_scope_effect_uk" ON "inventory"."reservation_release_effects" ("tenant_id","release_effect_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_release_effects_reservation_uk" ON "inventory"."reservation_release_effects" ("tenant_id","reservation_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_reservation_release_effects_mutation_uk" ON "inventory"."reservation_release_effects" ("tenant_id","mutation_id");--> statement-breakpoint +CREATE INDEX "inventory_reservation_release_effects_state_idx" ON "inventory"."reservation_release_effects" ("tenant_id","current_state","updated_at");--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effect_history" ADD CONSTRAINT "inventory_reservation_release_effect_history_effect_fk" FOREIGN KEY ("tenant_id","release_effect_id") REFERENCES "inventory"."reservation_release_effects"("tenant_id","release_effect_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effects" ADD CONSTRAINT "inventory_reservation_release_effects_reservation_fk" FOREIGN KEY ("tenant_id","reservation_id") REFERENCES "inventory"."obligations"("tenant_id","obligation_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effects" ADD CONSTRAINT "inventory_reservation_release_effects_backend_configuration_fk" FOREIGN KEY ("tenant_id","owner_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effect_history_tenant_select" ON "inventory"."reservation_release_effect_history" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_release_effect_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effect_history_tenant_insert" ON "inventory"."reservation_release_effect_history" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_release_effect_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effect_history_tenant_update" ON "inventory"."reservation_release_effect_history" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_release_effect_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_release_effect_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effect_history_tenant_delete" ON "inventory"."reservation_release_effect_history" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_release_effect_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effects_tenant_select" ON "inventory"."reservation_release_effects" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."reservation_release_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effects_tenant_insert" ON "inventory"."reservation_release_effects" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."reservation_release_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effects_tenant_update" ON "inventory"."reservation_release_effects" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."reservation_release_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."reservation_release_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_reservation_release_effects_tenant_delete" ON "inventory"."reservation_release_effects" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."reservation_release_effects"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effect_history" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."reservation_release_effects" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_release_effect_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + request jsonb; + reservation jsonb; + state_tag text; +BEGIN + request := NEW.snapshot -> 'request'; + reservation := request -> 'reservation'; + state_tag := NEW.snapshot ->> '_tag'; + + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR pg_catalog.jsonb_typeof(request) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(request)) <> 6 + OR NOT request ?& ARRAY[ + 'effectId', 'legalEntityId', 'mutationId', 'requestedAt', 'reservation', 'sourceActionInvocationId' + ] + OR state_tag IS DISTINCT FROM NEW.current_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR request ->> 'effectId' IS DISTINCT FROM NEW.release_effect_id + OR (request ->> 'mutationId')::uuid IS DISTINCT FROM NEW.mutation_id + OR (request ->> 'sourceActionInvocationId')::uuid IS DISTINCT FROM NEW.source_action_invocation_id + OR (request ->> 'legalEntityId')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR (request ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + OR reservation #>> '{ref,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR reservation #>> '{ref,resourceType}' IS DISTINCT FROM 'commerce.inventory.inventory-reservation' + OR reservation #>> '{ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (reservation #>> '{ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR reservation #>> '{origin,kind}' IS DISTINCT FROM 'ORDER_COMMITMENT_ATTEMPT' + OR reservation #>> '{origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR reservation #>> '{lifecycleMeaning}' IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + OR reservation #>> '{authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (reservation #>> '{authority,configurationId}')::uuid IS DISTINCT FROM NEW.owner_configuration_id + OR reservation #>> '{authority,selection,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR reservation #>> '{authority,selection,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_snapshot_ck', + MESSAGE = 'Reservation Release effect identity and request snapshot must exactly match relational columns'; + END IF; + + PERFORM 1 + FROM "inventory"."obligations" AS obligation + JOIN "inventory"."reservation_create_effects" AS create_effect + ON create_effect.tenant_id = obligation.tenant_id + AND create_effect.reservation_id = obligation.obligation_id + AND create_effect.attempt_id = obligation.attempt_id + AND create_effect.legal_entity_id = NEW.legal_entity_id + AND create_effect.state = 'ESTABLISHED' + WHERE obligation.tenant_id = NEW.tenant_id + AND obligation.obligation_id = NEW.reservation_id + AND obligation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND obligation.attempt_id = NEW.attempt_id + AND (TG_OP <> 'INSERT' OR obligation.lifecycle_meaning = 'PROVISIONAL_RESERVATION') + AND obligation.customer_configuration_id = reservation #>> '{authority,customerConfigurationId}' + AND obligation.owner_configuration_id = NEW.owner_configuration_id + AND obligation.authority_backend_kind = NEW.issuer_backend_kind + AND obligation.authority_backend_id = NEW.issuer_backend_id + AND obligation.authority_selected_at = (reservation #>> '{authority,selectedAt}')::timestamptz + AND obligation.authority_revision = (reservation #>> '{authority,revision}')::integer + AND create_effect.request_json #>> '{reservation,ref,resourceId}' = NEW.reservation_id::text + AND create_effect.request_json #>> '{reservation,origin,attemptId}' = NEW.attempt_id + AND create_effect.record_json -> 'reservation' IS NOT DISTINCT FROM reservation + FOR UPDATE OF obligation; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_exact_reservation_ck', + MESSAGE = 'Reservation Release must preserve the exact runtime Attempt and established Reservation snapshot'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.owner_configuration_id + AND authority.customer_configuration_id = reservation #>> '{authority,customerConfigurationId}' + AND authority.backend_kind = NEW.issuer_backend_kind + AND authority.backend_id = NEW.issuer_backend_id + AND authority.selected_at = (reservation #>> '{authority,selectedAt}')::timestamptz + AND authority.revision = (reservation #>> '{authority,revision}')::integer + AND reservation #>> '{authority,selection,backend}' = authority.backend_kind + AND reservation #>> '{authority,selection,backendId}' = authority.backend_id + AND reservation #>> '{authority,selection,exactReservationCapability}' + = authority.exact_reservation_capability + AND reservation #>> '{authority,selection,stockCorrectionCapability}' + = authority.stock_correction_capability + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_exact_authority_ck', + MESSAGE = 'Reservation Release must retain the exact selected Reservation Authority snapshot'; + END IF; + + IF ( + state_tag = 'REQUESTED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 3 + OR NEW.current_revision IS DISTINCT FROM 1 + OR NEW.released_at IS NOT NULL + OR NEW.owner_evidence_ref IS NOT NULL + ) + ) OR ( + state_tag = 'RELEASED' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 10 + OR NEW.snapshot -> 'safelyReusable' IS DISTINCT FROM 'true'::jsonb + OR NEW.snapshot -> 'activeAllocations' IS DISTINCT FROM '[]'::jsonb + OR NEW.snapshot ->> 'releaseOutcome' NOT IN ('RELEASED', 'ALREADY_RELEASED') + OR (NEW.snapshot ->> 'releasedAt')::timestamptz IS DISTINCT FROM NEW.released_at + OR NEW.snapshot ->> 'ownerEvidenceRef' IS DISTINCT FROM NEW.owner_evidence_ref + OR NEW.snapshot #>> '{authorityIssuer,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.snapshot #>> '{authorityIssuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.snapshot #>> '{authorityIssuer,origin}' IS DISTINCT FROM (CASE NEW.issuer_backend_kind + WHEN 'external_business_system' THEN 'EXTERNAL_BUSINESS_SYSTEM' + ELSE 'ONTOS_WMS' + END) + OR pg_catalog.jsonb_typeof(NEW.snapshot -> 'safeReleaseProof') IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'safeReleaseProof')) <> 2 + OR NEW.snapshot #>> '{safeReleaseProof,order,_tag}' IS DISTINCT FROM 'NOT_COMMITTED_CLOSED' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys( + NEW.snapshot #> '{safeReleaseProof,order}' + )) <> 4 + OR coalesce(pg_catalog.length(pg_catalog.btrim( + NEW.snapshot #>> '{safeReleaseProof,order,closureEvidenceRef}' + )), 0) NOT BETWEEN 1 AND 300 + OR coalesce(pg_catalog.length(pg_catalog.btrim( + NEW.snapshot #>> '{safeReleaseProof,order,nonCommitEvidenceRef}' + )), 0) NOT BETWEEN 1 AND 300 + OR (NEW.snapshot #>> '{safeReleaseProof,order,observedAt}')::timestamptz IS NULL + OR NEW.snapshot #>> '{safeReleaseProof,protection,_tag}' IS DISTINCT FROM 'ABSENT_PROVEN' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys( + NEW.snapshot #> '{safeReleaseProof,protection}' + )) <> 3 + OR coalesce(pg_catalog.length(pg_catalog.btrim( + NEW.snapshot #>> '{safeReleaseProof,protection,evidenceRef}' + )), 0) NOT BETWEEN 1 AND 300 + OR (NEW.snapshot #>> '{safeReleaseProof,protection,observedAt}')::timestamptz IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.owner_evidence_ref)), 0) NOT BETWEEN 1 AND 300 + ) + ) OR ( + state_tag = 'NOT_RELEASABLE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 7 + OR NEW.snapshot -> 'safelyReusable' IS DISTINCT FROM 'false'::jsonb + OR NEW.snapshot ->> 'reason' NOT IN ('COMMITTED', 'PROTECTION_ESTABLISHED') + OR (NEW.snapshot ->> 'observedAt')::timestamptz IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(NEW.snapshot ->> 'evidenceRef')), 0) NOT BETWEEN 1 AND 300 + OR NEW.released_at IS NOT NULL + OR NEW.owner_evidence_ref IS NOT NULL + ) + ) OR ( + state_tag = 'INDETERMINATE' + AND ( + (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 6 + OR NEW.snapshot -> 'safelyReusable' IS DISTINCT FROM 'false'::jsonb + OR NEW.snapshot ->> 'reason' NOT IN ( + 'ORDER_OUTCOME_UNKNOWN', + 'PROTECTION_OUTCOME_UNKNOWN', + 'AUTHORITY_OUTCOME_UNKNOWN' + ) + OR (NEW.snapshot ->> 'observedAt')::timestamptz IS NULL + OR NEW.released_at IS NOT NULL + OR NEW.owner_evidence_ref IS NOT NULL + ) + ) OR state_tag NOT IN ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_terminal_proof_ck', + MESSAGE = 'Reservation Release state must retain exact reusable-stock proof and terminal evidence'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_release_effect_transition"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_lifecycle_ck', + MESSAGE = 'Reservation Release effect cannot be deleted'; + END IF; + + IF NEW.release_effect_record_id IS DISTINCT FROM OLD.release_effect_record_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.release_effect_id IS DISTINCT FROM OLD.release_effect_id + OR NEW.mutation_id IS DISTINCT FROM OLD.mutation_id + OR NEW.source_action_invocation_id IS DISTINCT FROM OLD.source_action_invocation_id + OR NEW.legal_entity_id IS DISTINCT FROM OLD.legal_entity_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.issuer_backend_kind IS DISTINCT FROM OLD.issuer_backend_kind + OR NEW.issuer_backend_id IS DISTINCT FROM OLD.issuer_backend_id + OR NEW.requested_at IS DISTINCT FROM OLD.requested_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR NEW.snapshot -> 'request' IS DISTINCT FROM OLD.snapshot -> 'request' + OR NEW.current_revision IS DISTINCT FROM OLD.current_revision + 1 + OR OLD.current_state IN ('RELEASED', 'NOT_RELEASABLE') + OR OLD.current_state NOT IN ('REQUESTED', 'INDETERMINATE') + OR NEW.current_state NOT IN ('INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') + OR NEW.updated_at < OLD.updated_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_lifecycle_ck', + MESSAGE = 'Reservation Release transition mutates immutable intent or violates monotonic lifecycle'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_reservation_release_effect_history_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 + FROM "inventory"."reservation_release_effects" AS effect + WHERE effect.tenant_id = NEW.tenant_id + AND effect.release_effect_id = NEW.release_effect_id + AND effect.current_revision = NEW.revision + AND effect.current_state = NEW.state + AND effect.snapshot IS NOT DISTINCT FROM NEW.snapshot + AND NEW.snapshot ->> '_tag' = NEW.state + AND (NEW.snapshot ->> 'revision')::integer = NEW.revision + AND NEW.transitioned_at = CASE NEW.state + WHEN 'REQUESTED' THEN (NEW.snapshot #>> '{request,requestedAt}')::timestamptz + WHEN 'RELEASED' THEN (NEW.snapshot ->> 'releasedAt')::timestamptz + ELSE (NEW.snapshot ->> 'observedAt')::timestamptz + END + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effect_history_snapshot_ck', + MESSAGE = 'Reservation Release history must exactly snapshot the current validated revision'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_reservation_release_effect_history_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effect_history_append_only_ck', + MESSAGE = 'Reservation Release effect history is append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_release_effects_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."reservation_release_effects" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_release_effect_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_release_effects_transition_trg" +BEFORE UPDATE OR DELETE ON "inventory"."reservation_release_effects" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_release_effect_transition"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_release_effect_history_scope_trg" +BEFORE INSERT ON "inventory"."reservation_release_effect_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_release_effect_history_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_release_effect_history_no_update_trg" +BEFORE UPDATE ON "inventory"."reservation_release_effect_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_reservation_release_effect_history_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_release_effect_history_no_delete_trg" +BEFORE DELETE ON "inventory"."reservation_release_effect_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_reservation_release_effect_history_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_release_effect_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_release_effect_transition"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_release_effect_history_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_reservation_release_effect_history_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE FUNCTION "inventory"."read_reservation_release_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + current_record jsonb; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Release worker scope mismatch'; + END IF; + + SELECT effect.snapshot + INTO current_record + FROM "inventory"."reservation_release_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.release_effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + RETURN QUERY SELECT current_record; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."finalize_reservation_release_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text, + p_expected_revision integer, + p_next_snapshot jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + current_effect "inventory"."reservation_release_effects"%ROWTYPE; + next_state text; + next_transitioned_at timestamptz; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Release worker scope mismatch'; + END IF; + + SELECT effect.* + INTO current_effect + FROM "inventory"."reservation_release_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.release_effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + next_state := p_next_snapshot ->> '_tag'; + IF current_effect.snapshot IS NOT DISTINCT FROM p_next_snapshot THEN + IF current_effect.current_revision IS DISTINCT FROM p_expected_revision + 1 + OR current_effect.current_state NOT IN ('INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') + OR next_state IS DISTINCT FROM current_effect.current_state + OR (p_next_snapshot ->> 'revision')::integer IS DISTINCT FROM current_effect.current_revision + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_worker_cas_ck', + MESSAGE = 'Reservation Release replay must match the exact completed compare-and-set'; + END IF; + + RETURN QUERY SELECT current_effect.snapshot; + RETURN; + END IF; + + IF current_effect.current_state IN ('RELEASED', 'NOT_RELEASABLE') + OR current_effect.current_revision IS DISTINCT FROM p_expected_revision + OR (p_next_snapshot ->> 'revision')::integer IS DISTINCT FROM p_expected_revision + 1 + OR p_next_snapshot -> 'request' IS DISTINCT FROM current_effect.snapshot -> 'request' + OR p_next_snapshot #>> '{request,effectId}' IS DISTINCT FROM current_effect.release_effect_id + OR p_next_snapshot #>> '{request,legalEntityId}' IS DISTINCT FROM current_effect.legal_entity_id::text + OR next_state NOT IN ('INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_release_effects_worker_cas_ck', + MESSAGE = 'Reservation Release worker finalization must be an exact monotonic compare-and-set'; + END IF; + + next_transitioned_at := CASE next_state + WHEN 'RELEASED' THEN (p_next_snapshot ->> 'releasedAt')::timestamptz + ELSE (p_next_snapshot ->> 'observedAt')::timestamptz + END; + + UPDATE "inventory"."reservation_release_effects" + SET current_state = next_state, + current_revision = p_expected_revision + 1, + snapshot = p_next_snapshot, + released_at = CASE WHEN next_state = 'RELEASED' THEN next_transitioned_at END, + owner_evidence_ref = CASE WHEN next_state = 'RELEASED' THEN p_next_snapshot ->> 'ownerEvidenceRef' END, + updated_at = next_transitioned_at + WHERE tenant_id = p_tenant_id + AND legal_entity_id = p_legal_entity_id + AND release_effect_id = p_effect_id + AND current_revision = p_expected_revision; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '40001', + MESSAGE = 'Reservation Release effect changed during worker finalization'; + END IF; + + INSERT INTO "inventory"."reservation_release_effect_history" ( + tenant_id, + release_effect_id, + revision, + state, + snapshot, + transitioned_at + ) VALUES ( + p_tenant_id, + p_effect_id, + p_expected_revision + 1, + next_state, + p_next_snapshot, + next_transitioned_at + ); + + RETURN QUERY SELECT p_next_snapshot; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."read_reservation_release_effect_for_worker"(uuid, uuid, text) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."finalize_reservation_release_effect_for_worker"(uuid, uuid, text, integer, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."read_reservation_release_effect_for_worker"(uuid, uuid, text) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."finalize_reservation_release_effect_for_worker"(uuid, uuid, text, integer, jsonb) TO "ontos_runtime"; +--> statement-breakpoint +ALTER FUNCTION "inventory"."enforce_reservation_shortage_impact_source"() +RENAME TO "enforce_reservation_shortage_impact_decision_scope"; +--> statement-breakpoint +DROP TRIGGER "inventory_reservation_shortage_impacts_source_trg" +ON "inventory"."reservation_shortage_impacts"; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."enforce_reservation_shortage_impact_source"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + expected_fenced_amount numeric(38, 9); + position_matches boolean; +BEGIN + PERFORM 1 + FROM "inventory"."stock_positions" AS position + WHERE position.tenant_id = NEW.tenant_id + AND position.stock_position_id = NEW.position_id + AND position.lifecycle_state = 'CURRENT' + AND position.on_hand_state = 'CURRENT' + AND position.revision = NEW.position_revision + AND position.on_hand_amount = NEW.available_amount + FOR UPDATE; + + position_matches := FOUND; + + SELECT coalesce(pg_catalog.sum(allocation.allocated_amount), 0) + INTO expected_fenced_amount + FROM "inventory"."obligation_allocations" AS allocation + JOIN "inventory"."obligations" AS obligation + ON obligation.tenant_id = allocation.tenant_id + AND obligation.obligation_id = allocation.obligation_id + WHERE allocation.tenant_id = NEW.tenant_id + AND allocation.stock_position_id = NEW.position_id + AND ( + obligation.lifecycle_meaning = 'COMMITTED_OBLIGATION' + OR EXISTS ( + SELECT 1 + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = allocation.tenant_id + AND confirmation.reservation_id = allocation.obligation_id + AND confirmation.current_health_state IN ('EXPIRED', 'REVOKED') + ) + ) + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_release_effects" AS release_effect + WHERE release_effect.tenant_id = allocation.tenant_id + AND release_effect.reservation_id = allocation.obligation_id + AND release_effect.current_state = 'RELEASED' + ); + + IF NOT position_matches + OR NEW.fenced_amount IS DISTINCT FROM expected_fenced_amount + OR ( + NEW.change_kind IN ('RECEIPT', 'ISSUE') + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."physical_stock_effects" AS effect + WHERE effect.tenant_id = NEW.tenant_id + AND effect.effect_id = NEW.physical_effect_id + AND effect.effect_id = NEW.change_id + AND effect.kind = NEW.change_kind + AND effect.position_id = NEW.position_id + AND effect.state = 'APPLIED' + AND effect.evidence_json ->> 'effectId' = NEW.change_id::text + AND effect.evidence_json ->> 'kind' = NEW.change_kind + AND effect.evidence_json #>> '{positionRef,tenantId}' = NEW.tenant_id::text + AND effect.evidence_json #>> '{positionRef,resourceId}' = NEW.position_id::text + AND (effect.evidence_json ->> 'appliedAt')::timestamptz = NEW.occurred_at + AND EXISTS ( + SELECT 1 + FROM "inventory"."stock_positions" AS current_position + WHERE current_position.tenant_id = NEW.tenant_id + AND current_position.stock_position_id = NEW.position_id + AND current_position.on_hand_observed_at + = (effect.evidence_json ->> 'appliedAt')::timestamptz + AND current_position.on_hand_evidence_ref + = effect.evidence_json ->> 'backendEvidenceRef' + ) + ) + ) + OR ( + NEW.change_kind = 'CORRECTION' + AND NOT EXISTS ( + SELECT 1 + FROM "inventory"."stock_corrections" AS correction + WHERE correction.tenant_id = NEW.tenant_id + AND correction.correction_id = NEW.stock_correction_id + AND correction.correction_id = NEW.change_id + AND correction.position_id = NEW.position_id + AND correction.state = 'APPLIED' + AND correction.position_revision_after = NEW.position_revision + AND correction.corrected_quantity_amount = NEW.available_amount + AND correction.applied_at = NEW.occurred_at + AND correction.record_json ->> 'correctionId' = NEW.change_id::text + AND correction.record_json #>> '{positionRef,tenantId}' = NEW.tenant_id::text + AND correction.record_json #>> '{positionRef,resourceId}' = NEW.position_id::text + AND (correction.record_json ->> 'positionRevisionAfter')::integer = NEW.position_revision + AND (correction.record_json #>> '{correctedQuantity,amount}')::numeric = NEW.available_amount + AND (correction.record_json ->> 'appliedAt')::timestamptz = NEW.occurred_at + AND EXISTS ( + SELECT 1 + FROM "inventory"."stock_positions" AS current_position + WHERE current_position.tenant_id = NEW.tenant_id + AND current_position.stock_position_id = NEW.position_id + AND current_position.on_hand_observed_at = correction.business_observed_at + AND current_position.on_hand_evidence_ref = correction.owner_evidence_ref + ) + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_exact_source_ck', + MESSAGE = 'Reservation shortage impact must reference the exact applied source, Current Position revision, and non-reusable capacity'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_reservation_shortage_impacts_source_trg" +BEFORE INSERT ON "inventory"."reservation_shortage_impacts" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_reservation_shortage_impact_source"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_shortage_impact_source"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_reservation_shortage_impact_decision_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."read_reservation_shortage_impact_context_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_change_kind text, + p_change_id uuid, + p_position_id uuid, + p_occurred_at timestamptz +) RETURNS TABLE(context jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + candidate_set jsonb; + evidence_ref text; + fenced_amount numeric(38, 9); + position "inventory"."stock_positions"%ROWTYPE; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation shortage impact worker scope mismatch'; + END IF; + + IF p_change_kind NOT IN ('RECEIPT', 'ISSUE') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_shortage_impacts_exact_source_ck', + MESSAGE = 'Reservation shortage impact worker source kind is invalid'; + END IF; + + SELECT stored.* + INTO position + FROM "inventory"."stock_positions" AS stored + WHERE stored.tenant_id = p_tenant_id + AND stored.stock_position_id = p_position_id + AND stored.lifecycle_state = 'CURRENT' + AND stored.on_hand_state = 'CURRENT' + AND stored.on_hand_amount IS NOT NULL + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + SELECT effect.evidence_json ->> 'backendEvidenceRef' + INTO evidence_ref + FROM "inventory"."physical_stock_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_change_id + AND effect.position_id = p_position_id + AND effect.kind = p_change_kind + AND effect.state = 'APPLIED' + AND (effect.evidence_json ->> 'appliedAt')::timestamptz = p_occurred_at + AND position.on_hand_observed_at = (effect.evidence_json ->> 'appliedAt')::timestamptz + AND position.on_hand_evidence_ref = effect.evidence_json ->> 'backendEvidenceRef' + FOR UPDATE; + + IF evidence_ref IS NULL THEN + RETURN; + END IF; + + WITH candidate_rows AS ( + SELECT DISTINCT + confirmation.confirmation_id, + confirmation.snapshot, + reservation.lifecycle_meaning + FROM "inventory"."reservation_confirmations" AS confirmation + JOIN "inventory"."obligations" AS reservation + ON reservation.tenant_id = confirmation.tenant_id + AND reservation.obligation_id = confirmation.reservation_id + JOIN "inventory"."obligation_allocations" AS allocation + ON allocation.tenant_id = confirmation.tenant_id + AND allocation.obligation_id = confirmation.reservation_id + AND allocation.stock_position_id = p_position_id + LEFT JOIN "inventory"."reservation_release_effects" AS release_effect + ON release_effect.tenant_id = confirmation.tenant_id + AND release_effect.reservation_id = confirmation.reservation_id + WHERE confirmation.tenant_id = p_tenant_id + AND ( + release_effect.release_effect_record_id IS NULL + OR release_effect.current_state <> 'RELEASED' + ) + ) + SELECT coalesce( + pg_catalog.jsonb_agg( + pg_catalog.jsonb_build_object( + 'allocations', ( + SELECT coalesce(pg_catalog.jsonb_agg(stored_allocation.entry), '[]'::jsonb) + FROM pg_catalog.jsonb_array_elements( + candidate.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS stored_allocation(entry) + ), + 'confirmation', candidate.snapshot, + 'poolBoundary', CASE candidate.lifecycle_meaning + WHEN 'COMMITTED_OBLIGATION' THEN 'COMMITTED_OBLIGATION' + ELSE 'NONE' + END + ) ORDER BY + (candidate.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz, + candidate.confirmation_id + ), + '[]'::jsonb + ) + INTO candidate_set + FROM candidate_rows AS candidate; + + SELECT coalesce(pg_catalog.sum((allocation.entry #>> '{quantity,amount}')::numeric), 0) + INTO fenced_amount + FROM pg_catalog.jsonb_array_elements(candidate_set) AS fenced(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements(fenced.entry -> 'allocations') AS allocation(entry) + WHERE ( + fenced.entry ->> 'poolBoundary' = 'COMMITTED_OBLIGATION' + OR ( + fenced.entry ->> 'poolBoundary' = 'NONE' + AND fenced.entry #>> '{confirmation,health,state}' IN ('EXPIRED', 'REVOKED') + ) + ) + AND allocation.entry #>> '{positionRef,tenantId}' = p_tenant_id::text + AND allocation.entry #>> '{positionRef,resourceId}' = p_position_id::text; + + RETURN QUERY SELECT pg_catalog.jsonb_build_object( + 'causeEvidenceRef', evidence_ref, + 'evaluationInput', pg_catalog.jsonb_build_object( + 'affectedPositionRef', pg_catalog.jsonb_build_object( + 'moduleId', 'commerce.inventory', + 'resourceId', position.stock_position_id, + 'resourceType', 'commerce.inventory.stock-position', + 'tenantId', position.tenant_id + ), + 'availableQuantity', pg_catalog.jsonb_build_object( + 'amount', pg_catalog.trim_scale(position.on_hand_amount)::text, + 'unitRef', pg_catalog.jsonb_build_object( + 'moduleId', position.stock_unit_module_id, + 'resourceId', position.stock_unit_resource_id, + 'resourceType', position.stock_unit_resource_type, + 'tenantId', position.stock_unit_tenant_id + ) + ), + 'candidates', candidate_set + ), + 'fencedAmount', pg_catalog.trim_scale(fenced_amount)::text, + 'positionRevision', position.revision + ); +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."read_reservation_shortage_impact_context_for_worker"(uuid, uuid, text, uuid, uuid, timestamptz) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."read_reservation_shortage_impact_context_for_worker"(uuid, uuid, text, uuid, uuid, timestamptz) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924213441_inventory-reservation-release-effects/snapshot.json b/app/verticals/inventory/drizzle/20260924213441_inventory-reservation-release-effects/snapshot.json new file mode 100644 index 000000000..ba58d75e5 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924213441_inventory-reservation-release-effects/snapshot.json @@ -0,0 +1,11551 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "8a8d62fa-a012-48e5-9206-11503d43dcf9", + "prevIds": [ + "0d9900a5-4fbb-47d6-ae8f-18a76914f28b" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924220523_inventory-effect-ledger/migration.sql b/app/verticals/inventory/drizzle/20260924220523_inventory-effect-ledger/migration.sql new file mode 100644 index 000000000..b7a033a55 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924220523_inventory-effect-ledger/migration.sql @@ -0,0 +1,643 @@ +CREATE TABLE "inventory"."effect_ledger" ( + "tenant_id" uuid, + "effect_id" text, + "effect_kind" text NOT NULL, + "current_state" text DEFAULT 'REQUESTED' NOT NULL, + "current_revision" integer DEFAULT 1 NOT NULL, + "legal_entity_id" uuid NOT NULL, + "customer_configuration_id" text NOT NULL, + "reservation_id" uuid, + "attempt_id" text, + "authority_configuration_id" uuid NOT NULL, + "authority_backend_kind" text NOT NULL, + "authority_backend_id" text NOT NULL, + "intent_json" jsonb NOT NULL, + "intent_canonical" text NOT NULL, + "resolution_json" jsonb, + "snapshot" jsonb NOT NULL, + "requested_at" timestamp with time zone NOT NULL, + "updated_at" timestamp with time zone NOT NULL, + CONSTRAINT "inventory_effect_ledger_pkey" PRIMARY KEY("tenant_id","effect_id"), + CONSTRAINT "inventory_effect_ledger_kind_ck" CHECK ("effect_kind" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', 'STOCK_CORRECTION')), + CONSTRAINT "inventory_effect_ledger_state_ck" CHECK ("current_state" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')), + CONSTRAINT "inventory_effect_ledger_identity_ck" CHECK (char_length(btrim("effect_id")) between 1 and 300 and char_length(btrim("customer_configuration_id")) between 1 and 300 and char_length(btrim("authority_backend_id")) between 1 and 300 and char_length("intent_canonical") > 0), + CONSTRAINT "inventory_effect_ledger_reservation_scope_ck" CHECK (("effect_kind" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and "reservation_id" is not null and "attempt_id" is not null and char_length(btrim("attempt_id")) between 1 and 300) or ("effect_kind" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and "reservation_id" is null and "attempt_id" is null)), + CONSTRAINT "inventory_effect_ledger_resolution_ck" CHECK (("current_state" = 'REQUESTED' and "resolution_json" is null) or ("current_state" = 'INDETERMINATE') or ("current_state" in ('SUCCEEDED', 'REJECTED') and "resolution_json" is not null)), + CONSTRAINT "inventory_effect_ledger_revision_ck" CHECK ("current_revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE TABLE "inventory"."effect_ledger_history" ( + "history_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "effect_id" text NOT NULL, + "revision" integer NOT NULL, + "state" text NOT NULL, + "snapshot" jsonb NOT NULL, + "transitioned_at" timestamp with time zone NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_effect_ledger_history_state_ck" CHECK ("state" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and "revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger_history" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE INDEX "inventory_effect_ledger_state_idx" ON "inventory"."effect_ledger" ("tenant_id","current_state","effect_kind","updated_at");--> statement-breakpoint +CREATE INDEX "inventory_effect_ledger_reservation_idx" ON "inventory"."effect_ledger" ("tenant_id","reservation_id","effect_kind");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_effect_ledger_history_scope_id_uk" ON "inventory"."effect_ledger_history" ("tenant_id","history_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_effect_ledger_history_revision_uk" ON "inventory"."effect_ledger_history" ("tenant_id","effect_id","revision");--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger" ADD CONSTRAINT "inventory_effect_ledger_authority_fk" FOREIGN KEY ("tenant_id","authority_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger_history" ADD CONSTRAINT "inventory_effect_ledger_history_effect_fk" FOREIGN KEY ("tenant_id","effect_id") REFERENCES "inventory"."effect_ledger"("tenant_id","effect_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_tenant_select" ON "inventory"."effect_ledger" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."effect_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_tenant_insert" ON "inventory"."effect_ledger" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."effect_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_tenant_update" ON "inventory"."effect_ledger" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."effect_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."effect_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_tenant_delete" ON "inventory"."effect_ledger" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."effect_ledger"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_history_tenant_select" ON "inventory"."effect_ledger_history" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."effect_ledger_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_history_tenant_insert" ON "inventory"."effect_ledger_history" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."effect_ledger_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_history_tenant_update" ON "inventory"."effect_ledger_history" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."effect_ledger_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."effect_ledger_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_effect_ledger_history_tenant_delete" ON "inventory"."effect_ledger_history" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."effect_ledger_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger_history" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + intent jsonb := NEW.intent_json; + intent_kind text := NEW.intent_json ->> '_tag'; + parsed_canonical jsonb; + resolution_identity text; +BEGIN + BEGIN + parsed_canonical := NEW.intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect intent canonical fingerprint must be valid JSON'; + END; + + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 8 + OR NEW.snapshot ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot ->> 'effectId' IS DISTINCT FROM NEW.effect_id + OR NEW.snapshot ->> 'currentState' IS DISTINCT FROM NEW.current_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + OR (NEW.snapshot ->> 'updatedAt')::timestamptz IS DISTINCT FROM NEW.updated_at + OR NEW.updated_at < NEW.requested_at + OR NEW.snapshot -> 'intent' IS DISTINCT FROM intent + OR NEW.snapshot -> 'resolution' IS DISTINCT FROM coalesce(NEW.resolution_json, 'null'::jsonb) + OR intent IS DISTINCT FROM parsed_canonical + OR intent_kind IS DISTINCT FROM NEW.effect_kind + OR (NEW.current_state = 'REQUESTED' AND (NEW.current_revision <> 1 OR NEW.resolution_json IS NOT NULL)) + OR (NEW.current_state IN ('SUCCEEDED', 'REJECTED') AND NEW.resolution_json IS NULL) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger relational state must exactly match its canonical snapshot'; + END IF; + + IF NEW.effect_kind = 'RESERVATION_CREATE' THEN + IF intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,commerceContext,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,commerceContext,commerceMarketRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,commerceContext,sellingLegalEntityRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR (intent #>> '{request,commerceContext,sellingLegalEntityRef,resourceId}')::uuid + IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR intent #>> '{request,commerceContext,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Reservation Create ledger scope does not match its exact intent'; + END IF; + ELSIF NEW.effect_kind = 'RESERVATION_RELEASE' THEN + IF intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,reservation,authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,reservation,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,reservation,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,reservation,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Reservation Release ledger scope does not match its exact intent'; + END IF; + ELSIF NEW.effect_kind IN ('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE') THEN + IF intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,stockItemRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,stockLocationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,backendConfigurationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.reservation_id IS NOT NULL + OR NEW.attempt_id IS NOT NULL + OR (intent #>> '{request,backendConfigurationRef,resourceId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,backendId}' IS DISTINCT FROM NEW.authority_backend_id + OR intent #>> '{request,kind}' IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'PHYSICAL_RECEIPT' THEN 'RECEIPT' + ELSE 'ISSUE' + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Physical Stock effect ledger scope does not match its exact intent'; + END IF; + ELSIF NEW.effect_kind = 'STOCK_CORRECTION' THEN + IF intent #>> '{record,correctionId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{record,positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{record,authorityConfigurationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent ->> 'legalEntityId')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{record,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.reservation_id IS NOT NULL + OR NEW.attempt_id IS NOT NULL + OR (intent #>> '{record,authorityConfigurationRef,resourceId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{record,issuer,backendKind}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{record,issuer,backendId}' IS DISTINCT FROM NEW.authority_backend_id + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Stock Correction ledger scope does not match its exact intent'; + END IF; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger kind is not supported'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.authority_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = NEW.authority_backend_kind + AND authority.backend_id = NEW.authority_backend_id + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger authority does not match the selected backend configuration'; + END IF; + + IF NEW.resolution_json IS NOT NULL THEN + resolution_identity := CASE NEW.effect_kind + WHEN 'STOCK_CORRECTION' THEN NEW.resolution_json #>> '{record,correctionId}' + ELSE NEW.resolution_json #>> '{effect,request,effectId}' + END; + IF NEW.resolution_json ->> '_tag' IS DISTINCT FROM NEW.effect_kind + OR resolution_identity IS DISTINCT FROM NEW.effect_id + OR ( + NEW.effect_kind <> 'STOCK_CORRECTION' + AND NEW.resolution_json #> '{effect,request}' IS DISTINCT FROM intent -> 'request' + ) + OR ( + NEW.effect_kind = 'STOCK_CORRECTION' + AND NEW.resolution_json -> 'record' IS DISTINCT FROM intent -> 'record' + ) + OR ( + NEW.effect_kind IN ('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE') + AND NEW.resolution_json #>> '{effect,request,kind}' IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'PHYSICAL_RECEIPT' THEN 'RECEIPT' + ELSE 'ISSUE' + END) + ) + OR NEW.current_state IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'RECONCILIATION_REQUIRED' THEN 'INDETERMINATE' + WHEN 'ESTABLISHED' THEN 'SUCCEEDED' + WHEN 'RESOLVED_NO_RESERVATION' THEN 'REJECTED' + END + WHEN 'RESERVATION_RELEASE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'RELEASED' THEN 'SUCCEEDED' + WHEN 'NOT_RELEASABLE' THEN 'REJECTED' + END + WHEN 'PHYSICAL_RECEIPT' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'APPLIED' THEN 'SUCCEEDED' + WHEN 'REJECTED' THEN 'REJECTED' + END + WHEN 'PHYSICAL_ISSUE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'APPLIED' THEN 'SUCCEEDED' + WHEN 'REJECTED' THEN 'REJECTED' + END + WHEN 'STOCK_CORRECTION' THEN CASE NEW.resolution_json #>> '{record,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'APPLIED' THEN 'SUCCEEDED' + END + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect resolution must preserve the exact kind and owner effect identity'; + END IF; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_effect_ledger_transition"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.effect_id IS DISTINCT FROM OLD.effect_id + OR NEW.effect_kind IS DISTINCT FROM OLD.effect_kind + OR NEW.legal_entity_id IS DISTINCT FROM OLD.legal_entity_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.authority_configuration_id IS DISTINCT FROM OLD.authority_configuration_id + OR NEW.authority_backend_kind IS DISTINCT FROM OLD.authority_backend_kind + OR NEW.authority_backend_id IS DISTINCT FROM OLD.authority_backend_id + OR NEW.intent_json IS DISTINCT FROM OLD.intent_json + OR NEW.intent_canonical IS DISTINCT FROM OLD.intent_canonical + OR NEW.requested_at IS DISTINCT FROM OLD.requested_at + OR NEW.current_revision IS DISTINCT FROM OLD.current_revision + 1 + OR OLD.current_state IN ('SUCCEEDED', 'REJECTED') + OR OLD.current_state NOT IN ('REQUESTED', 'INDETERMINATE') + OR NEW.current_state NOT IN ('INDETERMINATE', 'SUCCEEDED', 'REJECTED') + OR NEW.updated_at < OLD.updated_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_effect_ledger_transition_ck', + MESSAGE = 'Inventory effect ledger transition mutates immutable intent or violates monotonic lifecycle'; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_effect_ledger_history_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 + FROM "inventory"."effect_ledger" AS effect + WHERE effect.tenant_id = NEW.tenant_id + AND effect.effect_id = NEW.effect_id + AND effect.current_revision = NEW.revision + AND effect.current_state = NEW.state + AND effect.snapshot IS NOT DISTINCT FROM NEW.snapshot + AND (NEW.snapshot ->> 'updatedAt')::timestamptz = NEW.transitioned_at + FOR KEY SHARE; + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_history_snapshot_ck', + MESSAGE = 'Inventory effect ledger history must exactly snapshot the current validated revision'; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_effect_ledger_history_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_history_append_only_ck', + MESSAGE = 'Inventory effect ledger history is append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_effect_ledger_exact_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."effect_ledger" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_effect_ledger_exact_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_effect_ledger_transition_trg" +BEFORE UPDATE OR DELETE ON "inventory"."effect_ledger" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_effect_ledger_transition"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_effect_ledger_history_scope_trg" +BEFORE INSERT ON "inventory"."effect_ledger_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_effect_ledger_history_scope"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_effect_ledger_history_no_update_trg" +BEFORE UPDATE ON "inventory"."effect_ledger_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_effect_ledger_history_mutation"(); +--> statement-breakpoint +CREATE TRIGGER "inventory_effect_ledger_history_no_delete_trg" +BEFORE DELETE ON "inventory"."effect_ledger_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_effect_ledger_history_mutation"(); +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_effect_ledger_transition"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_effect_ledger_history_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_effect_ledger_history_mutation"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE FUNCTION "inventory"."claim_inventory_effect_ledger"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_intent_canonical text, + p_initial_snapshot jsonb +) RETURNS TABLE(record jsonb, inserted boolean) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + attempt_id text; + authority_backend_id text; + authority_backend_kind text; + authority_configuration_id uuid; + customer_configuration_id text; + effect_id text := p_initial_snapshot ->> 'effectId'; + effect_kind text := p_initial_snapshot #>> '{intent,_tag}'; + existing "inventory"."effect_ledger"%ROWTYPE; + intent jsonb; + reservation_id uuid; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory effect ledger claim scope mismatch'; + END IF; + + BEGIN + intent := p_intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger claim canonical intent must be valid JSON'; + END; + + IF p_initial_snapshot -> 'intent' IS DISTINCT FROM intent + OR p_initial_snapshot ->> 'tenantId' IS DISTINCT FROM p_tenant_id::text + OR p_initial_snapshot ->> 'currentState' IS DISTINCT FROM 'REQUESTED' + OR (p_initial_snapshot ->> 'revision')::integer IS DISTINCT FROM 1 + OR p_initial_snapshot -> 'resolution' IS DISTINCT FROM 'null'::jsonb + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger claim must carry one exact canonical REQUESTED snapshot'; + END IF; + + CASE effect_kind + WHEN 'RESERVATION_CREATE' THEN + customer_configuration_id := intent #>> '{request,authority,customerConfigurationId}'; + reservation_id := (intent #>> '{request,reservation,ref,resourceId}')::uuid; + attempt_id := intent #>> '{request,reservation,origin,attemptId}'; + authority_configuration_id := (intent #>> '{request,authority,configurationId}')::uuid; + authority_backend_kind := intent #>> '{request,authority,selection,backend}'; + authority_backend_id := intent #>> '{request,authority,selection,backendId}'; + WHEN 'RESERVATION_RELEASE' THEN + customer_configuration_id := intent #>> '{request,reservation,authority,customerConfigurationId}'; + reservation_id := (intent #>> '{request,reservation,ref,resourceId}')::uuid; + attempt_id := intent #>> '{request,reservation,origin,attemptId}'; + authority_configuration_id := (intent #>> '{request,reservation,authority,configurationId}')::uuid; + authority_backend_kind := intent #>> '{request,reservation,authority,selection,backend}'; + authority_backend_id := intent #>> '{request,reservation,authority,selection,backendId}'; + WHEN 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE' THEN + customer_configuration_id := intent #>> '{request,customerConfigurationId}'; + reservation_id := NULL; + attempt_id := NULL; + authority_configuration_id := (intent #>> '{request,backendConfigurationRef,resourceId}')::uuid; + authority_backend_kind := intent #>> '{request,backend}'; + authority_backend_id := intent #>> '{request,backendId}'; + WHEN 'STOCK_CORRECTION' THEN + customer_configuration_id := intent #>> '{record,customerConfigurationId}'; + reservation_id := NULL; + attempt_id := NULL; + authority_configuration_id := (intent #>> '{record,authorityConfigurationRef,resourceId}')::uuid; + authority_backend_kind := intent #>> '{record,issuer,backendKind}'; + authority_backend_id := intent #>> '{record,issuer,backendId}'; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger claim kind is unsupported'; + END CASE; + + INSERT INTO "inventory"."effect_ledger" ( + tenant_id, + effect_id, + effect_kind, + current_state, + current_revision, + legal_entity_id, + customer_configuration_id, + reservation_id, + attempt_id, + authority_configuration_id, + authority_backend_kind, + authority_backend_id, + intent_json, + intent_canonical, + resolution_json, + snapshot, + requested_at, + updated_at + ) VALUES ( + p_tenant_id, + effect_id, + effect_kind, + 'REQUESTED', + 1, + p_legal_entity_id, + customer_configuration_id, + reservation_id, + attempt_id, + authority_configuration_id, + authority_backend_kind, + authority_backend_id, + intent, + p_intent_canonical, + NULL, + p_initial_snapshot, + (p_initial_snapshot ->> 'requestedAt')::timestamptz, + (p_initial_snapshot ->> 'updatedAt')::timestamptz + ) + ON CONFLICT ON CONSTRAINT inventory_effect_ledger_pkey DO NOTHING + RETURNING * INTO existing; + + IF FOUND THEN + INSERT INTO "inventory"."effect_ledger_history" ( + tenant_id, effect_id, revision, state, snapshot, transitioned_at + ) VALUES ( + existing.tenant_id, + existing.effect_id, + existing.current_revision, + existing.current_state, + existing.snapshot, + existing.updated_at + ); + RETURN QUERY SELECT existing.snapshot, true; + RETURN; + END IF; + + SELECT stored.* + INTO existing + FROM "inventory"."effect_ledger" AS stored + WHERE stored.tenant_id = p_tenant_id + AND stored.effect_id = effect_id + AND stored.legal_entity_id = p_legal_entity_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + RETURN QUERY SELECT existing.snapshot, false; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."read_inventory_effect_ledger_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory effect ledger worker scope mismatch'; + END IF; + + RETURN QUERY + SELECT effect.snapshot + FROM "inventory"."effect_ledger" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; +END; +$$; +--> statement-breakpoint +CREATE FUNCTION "inventory"."transition_inventory_effect_ledger_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text, + p_expected_revision integer, + p_expected_state text, + p_next_snapshot jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + current_effect "inventory"."effect_ledger"%ROWTYPE; + next_state text := p_next_snapshot ->> 'currentState'; + next_revision integer := (p_next_snapshot ->> 'revision')::integer; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory effect ledger worker scope mismatch'; + END IF; + + SELECT effect.* + INTO current_effect + FROM "inventory"."effect_ledger" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + IF current_effect.snapshot IS NOT DISTINCT FROM p_next_snapshot THEN + IF current_effect.current_revision IS DISTINCT FROM p_expected_revision + 1 + OR current_effect.current_state IS DISTINCT FROM next_state + OR next_revision IS DISTINCT FROM current_effect.current_revision + OR NOT ( + (p_expected_state = 'REQUESTED' AND next_state IN ('INDETERMINATE', 'SUCCEEDED', 'REJECTED')) + OR (p_expected_state = 'INDETERMINATE' AND next_state IN ('INDETERMINATE', 'SUCCEEDED', 'REJECTED')) + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."effect_ledger_history" AS predecessor + WHERE predecessor.tenant_id = p_tenant_id + AND predecessor.effect_id = p_effect_id + AND predecessor.revision = p_expected_revision + AND predecessor.state = p_expected_state + ) + THEN + RETURN; + END IF; + RETURN QUERY SELECT current_effect.snapshot; + RETURN; + END IF; + + IF current_effect.current_revision IS DISTINCT FROM p_expected_revision + OR current_effect.current_state IS DISTINCT FROM p_expected_state + OR next_revision IS DISTINCT FROM p_expected_revision + 1 + OR p_next_snapshot ->> 'tenantId' IS DISTINCT FROM p_tenant_id::text + OR p_next_snapshot ->> 'effectId' IS DISTINCT FROM p_effect_id + OR p_next_snapshot -> 'intent' IS DISTINCT FROM current_effect.intent_json + OR NOT ( + (p_expected_state = 'REQUESTED' AND next_state IN ('INDETERMINATE', 'SUCCEEDED', 'REJECTED')) + OR (p_expected_state = 'INDETERMINATE' AND next_state IN ('INDETERMINATE', 'SUCCEEDED', 'REJECTED')) + ) + THEN + RETURN; + END IF; + + UPDATE "inventory"."effect_ledger" + SET current_state = next_state, + current_revision = next_revision, + resolution_json = CASE WHEN p_next_snapshot -> 'resolution' = 'null'::jsonb + THEN NULL + ELSE p_next_snapshot -> 'resolution' + END, + snapshot = p_next_snapshot, + updated_at = (p_next_snapshot ->> 'updatedAt')::timestamptz + WHERE tenant_id = p_tenant_id + AND legal_entity_id = p_legal_entity_id + AND effect_id = p_effect_id + AND current_revision = p_expected_revision + AND current_state = p_expected_state + RETURNING * INTO current_effect; + + IF NOT FOUND THEN + RETURN; + END IF; + + INSERT INTO "inventory"."effect_ledger_history" ( + tenant_id, effect_id, revision, state, snapshot, transitioned_at + ) VALUES ( + current_effect.tenant_id, + current_effect.effect_id, + current_effect.current_revision, + current_effect.current_state, + current_effect.snapshot, + current_effect.updated_at + ); + + RETURN QUERY SELECT current_effect.snapshot; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."claim_inventory_effect_ledger"(uuid, uuid, text, jsonb) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."read_inventory_effect_ledger_for_worker"(uuid, uuid, text) FROM PUBLIC; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."transition_inventory_effect_ledger_for_worker"(uuid, uuid, text, integer, text, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."claim_inventory_effect_ledger"(uuid, uuid, text, jsonb) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."read_inventory_effect_ledger_for_worker"(uuid, uuid, text) TO "ontos_runtime"; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."transition_inventory_effect_ledger_for_worker"(uuid, uuid, text, integer, text, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924220523_inventory-effect-ledger/snapshot.json b/app/verticals/inventory/drizzle/20260924220523_inventory-effect-ledger/snapshot.json new file mode 100644 index 000000000..0594f5942 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924220523_inventory-effect-ledger/snapshot.json @@ -0,0 +1,12253 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "5eb62862-a7a8-4164-902a-e110cfb7a6be", + "prevIds": [ + "8a8d62fa-a012-48e5-9206-11503d43dcf9" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', 'STOCK_CORRECTION')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924222500_inventory-obligation-commit/migration.sql b/app/verticals/inventory/drizzle/20260924222500_inventory-obligation-commit/migration.sql new file mode 100644 index 000000000..1e1de82bf --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924222500_inventory-obligation-commit/migration.sql @@ -0,0 +1,79 @@ +CREATE UNIQUE INDEX "inventory_obligations_runtime_accepted_order_uk" ON "inventory"."obligations" ("tenant_id","accepted_order_id") WHERE "origin_kind" = 'ORDER_COMMITMENT_ATTEMPT' and "lifecycle_meaning" = 'COMMITTED_OBLIGATION'; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."reject_obligation_origin_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' + OR NEW.obligation_id IS DISTINCT FROM OLD.obligation_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.origin_kind IS DISTINCT FROM OLD.origin_kind + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.source_system IS DISTINCT FROM OLD.source_system + OR NEW.source_order_id IS DISTINCT FROM OLD.source_order_id + OR NEW.source_obligation_id IS DISTINCT FROM OLD.source_obligation_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.authority_backend_kind IS DISTINCT FROM OLD.authority_backend_kind + OR NEW.authority_backend_id IS DISTINCT FROM OLD.authority_backend_id + OR NEW.authority_selected_at IS DISTINCT FROM OLD.authority_selected_at + OR NEW.authority_revision IS DISTINCT FROM OLD.authority_revision + OR NEW.established_at IS DISTINCT FROM OLD.established_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Inventory Obligation identity, origin, authority, and establishment evidence are immutable'; + END IF; + + IF OLD.origin_kind = 'IMPORTED_PROVEN_ORDER' THEN + IF NEW.lifecycle_meaning IS DISTINCT FROM OLD.lifecycle_meaning + OR NEW.accepted_order_id IS DISTINCT FROM OLD.accepted_order_id + OR NEW.order_evidence_ref IS DISTINCT FROM OLD.order_evidence_ref + OR NEW.order_evidence_observed_at IS DISTINCT FROM OLD.order_evidence_observed_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Imported committed Obligation and Order evidence are immutable'; + END IF; + RETURN NEW; + END IF; + + IF OLD.origin_kind <> 'ORDER_COMMITMENT_ATTEMPT' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Inventory Obligation origin is invalid'; + END IF; + + IF NEW.lifecycle_meaning IS NOT DISTINCT FROM OLD.lifecycle_meaning + AND NEW.accepted_order_id IS NOT DISTINCT FROM OLD.accepted_order_id + AND NEW.order_evidence_ref IS NOT DISTINCT FROM OLD.order_evidence_ref + AND NEW.order_evidence_observed_at IS NOT DISTINCT FROM OLD.order_evidence_observed_at + THEN + RETURN NEW; + END IF; + + IF OLD.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND OLD.accepted_order_id IS NULL + AND OLD.order_evidence_ref IS NULL + AND OLD.order_evidence_observed_at IS NULL + AND NEW.lifecycle_meaning = 'COMMITTED_OBLIGATION' + AND NEW.accepted_order_id IS NOT NULL + AND NEW.order_evidence_ref IS NOT NULL + AND NEW.order_evidence_observed_at IS NOT NULL + THEN + RETURN NEW; + END IF; + + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Runtime Inventory Obligation permits only one provisional-to-committed Order binding'; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_obligation_origin_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924222500_inventory-obligation-commit/snapshot.json b/app/verticals/inventory/drizzle/20260924222500_inventory-obligation-commit/snapshot.json new file mode 100644 index 000000000..cef1a52e5 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924222500_inventory-obligation-commit/snapshot.json @@ -0,0 +1,12281 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "899d4bf7-3265-4911-b463-d412547560cf", + "prevIds": [ + "5eb62862-a7a8-4164-902a-e110cfb7a6be" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', 'STOCK_CORRECTION')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260924223324_inventory-effect-ledger-contract-fix/migration.sql b/app/verticals/inventory/drizzle/20260924223324_inventory-effect-ledger-contract-fix/migration.sql new file mode 100644 index 000000000..4d735c458 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924223324_inventory-effect-ledger-contract-fix/migration.sql @@ -0,0 +1,338 @@ +ALTER TABLE "inventory"."effect_ledger" DROP CONSTRAINT "inventory_effect_ledger_kind_ck", ADD CONSTRAINT "inventory_effect_ledger_kind_ck" CHECK ("effect_kind" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')); +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + intent jsonb := NEW.intent_json; + intent_kind text := NEW.intent_json ->> '_tag'; + parsed_canonical jsonb; + resolution_business_request jsonb; + resolution_identity text; +BEGIN + BEGIN + parsed_canonical := NEW.intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect intent canonical fingerprint must be valid JSON'; + END; + + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 8 + OR pg_catalog.jsonb_typeof(intent) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent)) <> 2 + OR pg_catalog.jsonb_typeof(intent -> 'request') IS DISTINCT FROM 'object' + OR NEW.snapshot ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot ->> 'effectId' IS DISTINCT FROM NEW.effect_id + OR NEW.snapshot ->> 'currentState' IS DISTINCT FROM NEW.current_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + OR (NEW.snapshot ->> 'updatedAt')::timestamptz IS DISTINCT FROM NEW.updated_at + OR NEW.updated_at < NEW.requested_at + OR NEW.snapshot -> 'intent' IS DISTINCT FROM intent + OR NEW.snapshot -> 'resolution' IS DISTINCT FROM coalesce(NEW.resolution_json, 'null'::jsonb) + OR intent IS DISTINCT FROM parsed_canonical + OR intent_kind IS DISTINCT FROM NEW.effect_kind + OR (NEW.current_state = 'REQUESTED' AND (NEW.current_revision <> 1 OR NEW.resolution_json IS NOT NULL)) + OR (NEW.current_state IN ('SUCCEEDED', 'REJECTED') AND NEW.resolution_json IS NULL) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger relational state must exactly match its canonical snapshot'; + END IF; + + IF NEW.effect_kind = 'RESERVATION_CREATE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 5 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,commerceContext,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,commerceContext,commerceMarketRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,commerceContext,sellingLegalEntityRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR (intent #>> '{request,commerceContext,sellingLegalEntityRef,resourceId}')::uuid + IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR intent #>> '{request,commerceContext,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Reservation Create ledger scope does not match its canonical business intent'; + END IF; + ELSIF NEW.effect_kind = 'RESERVATION_RELEASE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 3 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,reservation,authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,reservation,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,reservation,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,reservation,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Reservation Release ledger scope does not match its canonical business intent'; + END IF; + ELSIF NEW.effect_kind IN ('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE') THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 12 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,stockItemRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,stockLocationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,backendConfigurationRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,quantity,unitRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR NEW.reservation_id IS NOT NULL + OR NEW.attempt_id IS NOT NULL + OR (intent #>> '{request,backendConfigurationRef,resourceId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,backendId}' IS DISTINCT FROM NEW.authority_backend_id + OR intent #>> '{request,kind}' IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'PHYSICAL_RECEIPT' THEN 'RECEIPT' + ELSE 'ISSUE' + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Physical Stock effect ledger scope does not match its canonical business intent'; + END IF; + ELSIF NEW.effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Commitment Protection effect intent is reserved until its typed owner contract is installed'; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger kind is not supported'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.authority_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = NEW.authority_backend_kind + AND authority.backend_id = NEW.authority_backend_id + FOR KEY SHARE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger authority does not match the selected backend configuration'; + END IF; + + IF NEW.resolution_json IS NOT NULL THEN + resolution_identity := NEW.resolution_json #>> '{effect,request,effectId}'; + resolution_business_request := CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN + NEW.resolution_json #> '{effect,request}' - 'mutationId' - 'requestedAt' - 'sourceActionInvocationId' + WHEN 'RESERVATION_RELEASE' THEN + NEW.resolution_json #> '{effect,request}' - 'mutationId' - 'requestedAt' - 'sourceActionInvocationId' + WHEN 'PHYSICAL_RECEIPT' THEN + NEW.resolution_json #> '{effect,request}' - 'actionInvocationId' - 'requestedAt' + WHEN 'PHYSICAL_ISSUE' THEN + NEW.resolution_json #> '{effect,request}' - 'actionInvocationId' - 'requestedAt' + END; + IF NEW.resolution_json ->> '_tag' IS DISTINCT FROM NEW.effect_kind + OR resolution_identity IS DISTINCT FROM NEW.effect_id + OR resolution_business_request IS DISTINCT FROM intent -> 'request' + OR ( + NEW.effect_kind IN ('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE') + AND NEW.resolution_json #>> '{effect,request,kind}' IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'PHYSICAL_RECEIPT' THEN 'RECEIPT' + ELSE 'ISSUE' + END) + ) + OR NEW.current_state IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'RECONCILIATION_REQUIRED' THEN 'INDETERMINATE' + WHEN 'ESTABLISHED' THEN 'SUCCEEDED' + WHEN 'RESOLVED_NO_RESERVATION' THEN 'REJECTED' + END + WHEN 'RESERVATION_RELEASE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'RELEASED' THEN 'SUCCEEDED' + WHEN 'NOT_RELEASABLE' THEN 'REJECTED' + END + WHEN 'PHYSICAL_RECEIPT' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'APPLIED' THEN 'SUCCEEDED' + WHEN 'REJECTED' THEN 'REJECTED' + END + WHEN 'PHYSICAL_ISSUE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' + WHEN 'INDETERMINATE' THEN 'INDETERMINATE' + WHEN 'APPLIED' THEN 'SUCCEEDED' + WHEN 'REJECTED' THEN 'REJECTED' + END + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect resolution must preserve the exact business intent, kind, and owner effect identity'; + END IF; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."claim_inventory_effect_ledger"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_intent_canonical text, + p_initial_snapshot jsonb +) RETURNS TABLE(record jsonb, inserted boolean) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + attempt_id text; + authority_backend_id text; + authority_backend_kind text; + authority_configuration_id uuid; + customer_configuration_id text; + effect_id text := p_initial_snapshot ->> 'effectId'; + effect_kind text := p_initial_snapshot #>> '{intent,_tag}'; + existing "inventory"."effect_ledger"%ROWTYPE; + intent jsonb; + reservation_id uuid; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory effect ledger claim scope mismatch'; + END IF; + + BEGIN + intent := p_intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger claim canonical intent must be valid JSON'; + END; + + IF p_initial_snapshot -> 'intent' IS DISTINCT FROM intent + OR p_initial_snapshot ->> 'tenantId' IS DISTINCT FROM p_tenant_id::text + OR p_initial_snapshot ->> 'currentState' IS DISTINCT FROM 'REQUESTED' + OR (p_initial_snapshot ->> 'revision')::integer IS DISTINCT FROM 1 + OR p_initial_snapshot -> 'resolution' IS DISTINCT FROM 'null'::jsonb + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger claim must carry one exact canonical REQUESTED snapshot'; + END IF; + + CASE effect_kind + WHEN 'RESERVATION_CREATE' THEN + customer_configuration_id := intent #>> '{request,authority,customerConfigurationId}'; + reservation_id := (intent #>> '{request,reservation,ref,resourceId}')::uuid; + attempt_id := intent #>> '{request,reservation,origin,attemptId}'; + authority_configuration_id := (intent #>> '{request,authority,configurationId}')::uuid; + authority_backend_kind := intent #>> '{request,authority,selection,backend}'; + authority_backend_id := intent #>> '{request,authority,selection,backendId}'; + WHEN 'RESERVATION_RELEASE' THEN + customer_configuration_id := intent #>> '{request,reservation,authority,customerConfigurationId}'; + reservation_id := (intent #>> '{request,reservation,ref,resourceId}')::uuid; + attempt_id := intent #>> '{request,reservation,origin,attemptId}'; + authority_configuration_id := (intent #>> '{request,reservation,authority,configurationId}')::uuid; + authority_backend_kind := intent #>> '{request,reservation,authority,selection,backend}'; + authority_backend_id := intent #>> '{request,reservation,authority,selection,backendId}'; + WHEN 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE' THEN + customer_configuration_id := intent #>> '{request,customerConfigurationId}'; + reservation_id := NULL; + attempt_id := NULL; + authority_configuration_id := (intent #>> '{request,backendConfigurationRef,resourceId}')::uuid; + authority_backend_kind := intent #>> '{request,backend}'; + authority_backend_id := intent #>> '{request,backendId}'; + WHEN 'ESTABLISH_COMMITMENT_PROTECTION' THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Commitment Protection effect claim is reserved until its typed owner contract is installed'; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger claim kind is unsupported'; + END CASE; + + INSERT INTO "inventory"."effect_ledger" ( + tenant_id, + effect_id, + effect_kind, + current_state, + current_revision, + legal_entity_id, + customer_configuration_id, + reservation_id, + attempt_id, + authority_configuration_id, + authority_backend_kind, + authority_backend_id, + intent_json, + intent_canonical, + resolution_json, + snapshot, + requested_at, + updated_at + ) VALUES ( + p_tenant_id, + effect_id, + effect_kind, + 'REQUESTED', + 1, + p_legal_entity_id, + customer_configuration_id, + reservation_id, + attempt_id, + authority_configuration_id, + authority_backend_kind, + authority_backend_id, + intent, + p_intent_canonical, + NULL, + p_initial_snapshot, + (p_initial_snapshot ->> 'requestedAt')::timestamptz, + (p_initial_snapshot ->> 'updatedAt')::timestamptz + ) + ON CONFLICT ON CONSTRAINT inventory_effect_ledger_pkey DO NOTHING + RETURNING * INTO existing; + + IF FOUND THEN + INSERT INTO "inventory"."effect_ledger_history" ( + tenant_id, effect_id, revision, state, snapshot, transitioned_at + ) VALUES ( + existing.tenant_id, + existing.effect_id, + existing.current_revision, + existing.current_state, + existing.snapshot, + existing.updated_at + ); + RETURN QUERY SELECT existing.snapshot, true; + RETURN; + END IF; + + SELECT stored.* + INTO existing + FROM "inventory"."effect_ledger" AS stored + WHERE stored.tenant_id = p_tenant_id + AND stored.effect_id = effect_id + AND stored.legal_entity_id = p_legal_entity_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + RETURN QUERY SELECT existing.snapshot, false; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."claim_inventory_effect_ledger"(uuid, uuid, text, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."claim_inventory_effect_ledger"(uuid, uuid, text, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260924223324_inventory-effect-ledger-contract-fix/snapshot.json b/app/verticals/inventory/drizzle/20260924223324_inventory-effect-ledger-contract-fix/snapshot.json new file mode 100644 index 000000000..0e75c8399 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260924223324_inventory-effect-ledger-contract-fix/snapshot.json @@ -0,0 +1,12281 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "5ccf313f-5a4d-4547-8d40-bff21369fdd6", + "prevIds": [ + "899d4bf7-3265-4911-b463-d412547560cf" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260925014556_inventory-commitment-protections/migration.sql b/app/verticals/inventory/drizzle/20260925014556_inventory-commitment-protections/migration.sql new file mode 100644 index 000000000..82a24e50d --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925014556_inventory-commitment-protections/migration.sql @@ -0,0 +1,558 @@ +CREATE TABLE "inventory"."commitment_protection_history" ( + "history_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "protection_id" uuid NOT NULL, + "revision" integer NOT NULL, + "health_state" text NOT NULL, + "snapshot" jsonb NOT NULL, + "transitioned_at" timestamp with time zone NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_commitment_protection_history_health_ck" CHECK ("health_state" in ('PROTECTED', 'AT_RISK') and "revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protection_history" ENABLE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE TABLE "inventory"."commitment_protections" ( + "protection_id" uuid PRIMARY KEY, + "tenant_id" uuid NOT NULL, + "confirmation_id" uuid NOT NULL, + "reservation_id" uuid NOT NULL, + "attempt_id" text NOT NULL, + "owner_configuration_id" uuid NOT NULL, + "issuer_backend_kind" text NOT NULL, + "issuer_backend_id" text NOT NULL, + "authority_effect_id" text NOT NULL, + "owner_evidence_ref" text NOT NULL, + "established_at" timestamp with time zone NOT NULL, + "current_health_state" text DEFAULT 'PROTECTED' NOT NULL, + "current_revision" integer DEFAULT 1 NOT NULL, + "snapshot" jsonb NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_commitment_protections_meaning_ck" CHECK (char_length(btrim("attempt_id")) between 1 and 300 and char_length(btrim("issuer_backend_id")) between 1 and 300 and char_length(btrim("authority_effect_id")) between 1 and 300 and char_length(btrim("owner_evidence_ref")) between 1 and 300 and "issuer_backend_kind" in ('external_business_system', 'ontos_wms')), + CONSTRAINT "inventory_commitment_protections_health_ck" CHECK ("current_health_state" in ('PROTECTED', 'AT_RISK') and "current_revision" >= 1) +); +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protections" ENABLE ROW LEVEL SECURITY; +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_commitment_protection_history_scope_id_uk" ON "inventory"."commitment_protection_history" ("tenant_id","history_id"); +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_commitment_protection_history_revision_uk" ON "inventory"."commitment_protection_history" ("tenant_id","protection_id","revision"); +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_commitment_protections_scope_id_uk" ON "inventory"."commitment_protections" ("tenant_id","protection_id"); +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_commitment_protections_reservation_attempt_uk" ON "inventory"."commitment_protections" ("tenant_id","reservation_id","attempt_id"); +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_commitment_protections_confirmation_uk" ON "inventory"."commitment_protections" ("tenant_id","confirmation_id"); +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_commitment_protections_authority_effect_uk" ON "inventory"."commitment_protections" ("tenant_id","authority_effect_id"); +--> statement-breakpoint +CREATE INDEX "inventory_commitment_protections_health_idx" ON "inventory"."commitment_protections" ("tenant_id","current_health_state","established_at"); +--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_effect_ledger_commitment_protection_attempt_uk" ON "inventory"."effect_ledger" ("tenant_id","reservation_id","attempt_id","effect_kind") WHERE "effect_kind" = 'ESTABLISH_COMMITMENT_PROTECTION'; +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protection_history" ADD CONSTRAINT "inventory_commitment_protection_history_protection_fk" FOREIGN KEY ("tenant_id","protection_id") REFERENCES "inventory"."commitment_protections"("tenant_id","protection_id") ON DELETE RESTRICT; +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protections" ADD CONSTRAINT "inventory_commitment_protections_confirmation_fk" FOREIGN KEY ("tenant_id","confirmation_id") REFERENCES "inventory"."reservation_confirmations"("tenant_id","confirmation_id") ON DELETE RESTRICT; +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protections" ADD CONSTRAINT "inventory_commitment_protections_reservation_fk" FOREIGN KEY ("tenant_id","reservation_id") REFERENCES "inventory"."obligations"("tenant_id","obligation_id") ON DELETE RESTRICT; +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protections" ADD CONSTRAINT "inventory_commitment_protections_backend_configuration_fk" FOREIGN KEY ("tenant_id","owner_configuration_id") REFERENCES "inventory"."backend_configurations"("tenant_id","configuration_id") ON DELETE RESTRICT; +--> statement-breakpoint +ALTER TABLE "inventory"."effect_ledger" DROP CONSTRAINT "inventory_effect_ledger_reservation_scope_ck", ADD CONSTRAINT "inventory_effect_ledger_reservation_scope_ck" CHECK (("effect_kind" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and "reservation_id" is not null and "attempt_id" is not null and char_length(btrim("attempt_id")) between 1 and 300) or ("effect_kind" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and "reservation_id" is null and "attempt_id" is null)); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protection_history_tenant_select" ON "inventory"."commitment_protection_history" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."commitment_protection_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protection_history_tenant_insert" ON "inventory"."commitment_protection_history" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."commitment_protection_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protection_history_tenant_update" ON "inventory"."commitment_protection_history" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."commitment_protection_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."commitment_protection_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protection_history_tenant_delete" ON "inventory"."commitment_protection_history" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."commitment_protection_history"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protections_tenant_select" ON "inventory"."commitment_protections" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."commitment_protections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protections_tenant_insert" ON "inventory"."commitment_protections" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."commitment_protections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protections_tenant_update" ON "inventory"."commitment_protections" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."commitment_protections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."commitment_protections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +CREATE POLICY "inventory_commitment_protections_tenant_delete" ON "inventory"."commitment_protections" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."commitment_protections"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."commitment_protection_history" FORCE ROW LEVEL SECURITY; +ALTER TABLE "inventory"."commitment_protections" FORCE ROW LEVEL SECURITY; +GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE "inventory"."commitment_protection_history" TO "ontos_runtime"; +GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE "inventory"."commitment_protections" TO "ontos_runtime"; +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_commitment_protection_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + authority "inventory"."backend_configurations"%ROWTYPE; + confirmation "inventory"."reservation_confirmations"%ROWTYPE; + candidate_confirmation jsonb := NEW.snapshot -> 'confirmation'; + expected_allocations jsonb; + actual_allocations jsonb; +BEGIN + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (NEW.snapshot #>> '{ref,resourceId}')::uuid IS DISTINCT FROM NEW.protection_id + OR NEW.snapshot #>> '{ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (NEW.snapshot #>> '{confirmation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.confirmation_id + OR NEW.snapshot #>> '{confirmation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (NEW.snapshot #>> '{confirmation,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR NEW.snapshot #>> '{confirmation,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (NEW.snapshot #>> '{confirmation,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.owner_configuration_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.snapshot #>> '{authorityEvidence,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.snapshot #>> '{authorityEvidence,effectId}' IS DISTINCT FROM NEW.authority_effect_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validFrom}')::timestamptz IS DISTINCT FROM NEW.established_at + OR (NEW.snapshot ->> 'establishedAt')::timestamptz IS DISTINCT FROM NEW.established_at + OR NEW.snapshot #>> '{health,state}' IS DISTINCT FROM NEW.current_health_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz IS DISTINCT FROM NEW.updated_at + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection snapshot must exactly match its relational identity and current health'; + END IF; + + IF TG_OP = 'UPDATE' THEN + RETURN NEW; + END IF; + + SELECT selected.* INTO authority + FROM "inventory"."backend_configurations" AS selected + WHERE selected.tenant_id = NEW.tenant_id + AND selected.configuration_id = NEW.owner_configuration_id + AND selected.customer_configuration_id = NEW.snapshot #>> '{confirmation,reservation,authority,customerConfigurationId}' + AND selected.backend_kind = NEW.issuer_backend_kind + AND selected.backend_id = NEW.issuer_backend_id + FOR KEY SHARE; + IF NOT FOUND + OR NEW.snapshot #>> '{authorityEvidence,issuer,origin}' IS DISTINCT FROM (CASE NEW.issuer_backend_kind + WHEN 'external_business_system' THEN 'EXTERNAL_BUSINESS_SYSTEM' + WHEN 'ontos_wms' THEN 'ONTOS_WMS' + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_authority_ck', + MESSAGE = 'Commitment Protection must preserve the exact selected backend authority'; + END IF; + + SELECT current_confirmation.* INTO confirmation + FROM "inventory"."reservation_confirmations" AS current_confirmation + WHERE current_confirmation.tenant_id = NEW.tenant_id + AND current_confirmation.confirmation_id = NEW.confirmation_id + AND current_confirmation.reservation_id = NEW.reservation_id + AND current_confirmation.attempt_id = NEW.attempt_id + AND current_confirmation.owner_configuration_id = NEW.owner_configuration_id + AND current_confirmation.issuer_backend_kind = NEW.issuer_backend_kind + AND current_confirmation.issuer_backend_id = NEW.issuer_backend_id + FOR KEY SHARE; + IF NOT FOUND + OR NEW.established_at >= confirmation.expires_at + OR NOT EXISTS ( + SELECT 1 FROM "inventory"."reservation_confirmation_history" AS confirmation_history + WHERE confirmation_history.tenant_id = NEW.tenant_id + AND confirmation_history.confirmation_id = NEW.confirmation_id + AND confirmation_history.snapshot = candidate_confirmation + ) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_confirmation_ck', + MESSAGE = 'Commitment Protection must reference exact retained Confirmation proof established before exclusive expiry'; + END IF; + + PERFORM 1 FROM "inventory"."obligations" AS reservation + WHERE reservation.tenant_id = NEW.tenant_id + AND reservation.obligation_id = NEW.reservation_id + AND reservation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND reservation.origin_attempt_id = NEW.attempt_id + AND reservation.owner_configuration_id = NEW.owner_configuration_id + AND reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + FOR KEY SHARE; + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_reservation_ck', + MESSAGE = 'Commitment Protection must reference the exact provisional Reservation and Attempt'; + END IF; + + SELECT pg_catalog.jsonb_agg(allocation.entry ORDER BY allocation.entry ->> 'allocationId') + INTO expected_allocations + FROM pg_catalog.jsonb_array_elements(candidate_confirmation #> '{reservation,requirements}') AS requirement(entry), + LATERAL pg_catalog.jsonb_array_elements(requirement.entry -> 'allocations') AS allocation(entry); + SELECT pg_catalog.jsonb_agg(allocation.entry ORDER BY allocation.entry ->> 'allocationId') + INTO actual_allocations + FROM pg_catalog.jsonb_array_elements(NEW.snapshot #> '{authorityEvidence,evidence,allocations}') AS allocation(entry); + IF NEW.current_health_state IS DISTINCT FROM 'PROTECTED' + OR NEW.current_revision IS DISTINCT FROM 1 + OR NEW.snapshot #>> '{authorityEvidence,kind}' IS DISTINCT FROM 'AUTHORITATIVE_RESERVATION_EVIDENCE' + OR NEW.snapshot #>> '{authorityEvidence,operation}' IS DISTINCT FROM 'COMMITMENT_PROTECTION' + OR NEW.snapshot #>> '{authorityEvidence,evidence,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,reservationId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,customerConfigurationId}' IS DISTINCT FROM authority.customer_configuration_id + OR NEW.snapshot #>> '{health,observation,_tag}' IS DISTINCT FROM 'ESTABLISHED' + OR NEW.snapshot #>> '{health,observation,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{health,reconciliationRequired}')::boolean IS DISTINCT FROM false + OR expected_allocations IS DISTINCT FROM actual_allocations + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection establishment must preserve exact authority allocation, quantity, Unit, Item, Position, and evidence scope'; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."claim_inventory_effect_ledger"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_intent_canonical text, + p_initial_snapshot jsonb +) RETURNS TABLE(record jsonb, inserted boolean) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + v_attempt_id text; + v_authority_backend_id text; + v_authority_backend_kind text; + v_authority_configuration_id uuid; + v_customer_configuration_id text; + v_effect_id text := p_initial_snapshot ->> 'effectId'; + v_effect_kind text := p_initial_snapshot #>> '{intent,_tag}'; + v_existing "inventory"."effect_ledger"%ROWTYPE; + v_intent jsonb; + v_reservation_id uuid; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory effect ledger claim scope mismatch'; + END IF; + BEGIN v_intent := p_intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END; + IF p_initial_snapshot -> 'intent' IS DISTINCT FROM v_intent + OR p_initial_snapshot ->> 'tenantId' IS DISTINCT FROM p_tenant_id::text + OR p_initial_snapshot ->> 'currentState' IS DISTINCT FROM 'REQUESTED' + OR (p_initial_snapshot ->> 'revision')::integer IS DISTINCT FROM 1 + OR p_initial_snapshot -> 'resolution' IS DISTINCT FROM 'null'::jsonb THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + + CASE v_effect_kind + WHEN 'RESERVATION_CREATE' THEN + v_customer_configuration_id := v_intent #>> '{request,authority,customerConfigurationId}'; + v_reservation_id := (v_intent #>> '{request,reservation,ref,resourceId}')::uuid; + v_attempt_id := v_intent #>> '{request,reservation,origin,attemptId}'; + v_authority_configuration_id := (v_intent #>> '{request,authority,configurationId}')::uuid; + v_authority_backend_kind := v_intent #>> '{request,authority,selection,backend}'; + v_authority_backend_id := v_intent #>> '{request,authority,selection,backendId}'; + WHEN 'RESERVATION_RELEASE' THEN + v_customer_configuration_id := v_intent #>> '{request,reservation,authority,customerConfigurationId}'; + v_reservation_id := (v_intent #>> '{request,reservation,ref,resourceId}')::uuid; + v_attempt_id := v_intent #>> '{request,reservation,origin,attemptId}'; + v_authority_configuration_id := (v_intent #>> '{request,reservation,authority,configurationId}')::uuid; + v_authority_backend_kind := v_intent #>> '{request,reservation,authority,selection,backend}'; + v_authority_backend_id := v_intent #>> '{request,reservation,authority,selection,backendId}'; + WHEN 'ESTABLISH_COMMITMENT_PROTECTION' THEN + v_customer_configuration_id := v_intent #>> '{request,confirmation,reservation,authority,customerConfigurationId}'; + v_reservation_id := (v_intent #>> '{request,confirmation,reservation,ref,resourceId}')::uuid; + v_attempt_id := v_intent #>> '{request,confirmation,reservation,origin,attemptId}'; + v_authority_configuration_id := (v_intent #>> '{request,confirmation,reservation,authority,configurationId}')::uuid; + v_authority_backend_kind := v_intent #>> '{request,confirmation,reservation,authority,selection,backend}'; + v_authority_backend_id := v_intent #>> '{request,confirmation,reservation,authority,selection,backendId}'; + WHEN 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE' THEN + v_customer_configuration_id := v_intent #>> '{request,customerConfigurationId}'; + v_reservation_id := NULL; + v_attempt_id := NULL; + v_authority_configuration_id := (v_intent #>> '{request,backendConfigurationRef,resourceId}')::uuid; + v_authority_backend_kind := v_intent #>> '{request,backend}'; + v_authority_backend_id := v_intent #>> '{request,backendId}'; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END CASE; + + INSERT INTO "inventory"."effect_ledger" ( + tenant_id, effect_id, effect_kind, current_state, current_revision, legal_entity_id, + customer_configuration_id, reservation_id, attempt_id, authority_configuration_id, + authority_backend_kind, authority_backend_id, intent_json, intent_canonical, resolution_json, + snapshot, requested_at, updated_at + ) VALUES ( + p_tenant_id, v_effect_id, v_effect_kind, 'REQUESTED', 1, p_legal_entity_id, + v_customer_configuration_id, v_reservation_id, v_attempt_id, v_authority_configuration_id, + v_authority_backend_kind, v_authority_backend_id, v_intent, p_intent_canonical, NULL, + p_initial_snapshot, (p_initial_snapshot ->> 'requestedAt')::timestamptz, + (p_initial_snapshot ->> 'updatedAt')::timestamptz + ) + ON CONFLICT DO NOTHING + RETURNING * INTO v_existing; + + IF FOUND THEN + INSERT INTO "inventory"."effect_ledger_history" ( + tenant_id, effect_id, revision, state, snapshot, transitioned_at + ) VALUES ( + v_existing.tenant_id, v_existing.effect_id, v_existing.current_revision, + v_existing.current_state, v_existing.snapshot, v_existing.updated_at + ); + RETURN QUERY SELECT v_existing.snapshot, true; + RETURN; + END IF; + + SELECT stored.* INTO v_existing + FROM "inventory"."effect_ledger" AS stored + WHERE stored.tenant_id = p_tenant_id + AND stored.legal_entity_id = p_legal_entity_id + AND ( + stored.effect_id = v_effect_id + OR ( + v_effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' + AND stored.effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' + AND stored.reservation_id = v_reservation_id + AND stored.attempt_id = v_attempt_id + ) + ) + ORDER BY (stored.effect_id = v_effect_id) DESC + LIMIT 1 + FOR UPDATE; + IF NOT FOUND THEN RETURN; END IF; + RETURN QUERY SELECT v_existing.snapshot, false; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_commitment_protections_scope_trg" +BEFORE INSERT OR UPDATE ON "inventory"."commitment_protections" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_commitment_protection_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_commitment_protection_lifecycle"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection cannot be deleted or released'; + END IF; + IF NEW.protection_id IS DISTINCT FROM OLD.protection_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.confirmation_id IS DISTINCT FROM OLD.confirmation_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.issuer_backend_kind IS DISTINCT FROM OLD.issuer_backend_kind + OR NEW.issuer_backend_id IS DISTINCT FROM OLD.issuer_backend_id + OR NEW.authority_effect_id IS DISTINCT FROM OLD.authority_effect_id + OR NEW.owner_evidence_ref IS DISTINCT FROM OLD.owner_evidence_ref + OR NEW.established_at IS DISTINCT FROM OLD.established_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR NEW.current_revision IS DISTINCT FROM OLD.current_revision + 1 + OR OLD.current_health_state NOT IN ('PROTECTED', 'AT_RISK') + OR NEW.current_health_state IS DISTINCT FROM 'AT_RISK' + OR NEW.updated_at < OLD.updated_at + OR NEW.snapshot -> 'authorityEvidence' IS DISTINCT FROM OLD.snapshot -> 'authorityEvidence' + OR NEW.snapshot -> 'confirmation' IS DISTINCT FROM OLD.snapshot -> 'confirmation' + OR NEW.snapshot -> 'establishedAt' IS DISTINCT FROM OLD.snapshot -> 'establishedAt' + OR NEW.snapshot -> 'ref' IS DISTINCT FROM OLD.snapshot -> 'ref' + OR NEW.snapshot #>> '{health,observation,_tag}' NOT IN ('BINDING_CORRECTION', 'MATERIAL_IMPAIRMENT') + OR (NEW.snapshot #>> '{health,reconciliationRequired}')::boolean IS DISTINCT FROM true + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection permits only monotonic PROTECTED or AT_RISK to AT_RISK health revisions'; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_commitment_protections_lifecycle_trg" +BEFORE UPDATE OR DELETE ON "inventory"."commitment_protections" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_commitment_protection_lifecycle"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."enforce_commitment_protection_history_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + PERFORM 1 FROM "inventory"."commitment_protections" AS protection + WHERE protection.tenant_id = NEW.tenant_id + AND protection.protection_id = NEW.protection_id + AND protection.current_revision = NEW.revision + AND protection.current_health_state = NEW.health_state + AND protection.snapshot = NEW.snapshot + AND protection.updated_at = NEW.transitioned_at + FOR KEY SHARE; + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection history must exactly snapshot the current authoritative revision'; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_commitment_protection_history_scope_trg" +BEFORE INSERT ON "inventory"."commitment_protection_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."enforce_commitment_protection_history_scope"(); +--> statement-breakpoint +CREATE FUNCTION "inventory"."reject_commitment_protection_history_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection history is append-only'; +END; +$$; +--> statement-breakpoint +CREATE TRIGGER "inventory_commitment_protection_history_no_update_trg" +BEFORE UPDATE ON "inventory"."commitment_protection_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_commitment_protection_history_mutation"(); +CREATE TRIGGER "inventory_commitment_protection_history_no_delete_trg" +BEFORE DELETE ON "inventory"."commitment_protection_history" +FOR EACH ROW EXECUTE FUNCTION "inventory"."reject_commitment_protection_history_mutation"(); +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + intent jsonb := NEW.intent_json; + intent_kind text := NEW.intent_json ->> '_tag'; + parsed_canonical jsonb; + resolution_business_request jsonb; + resolution_identity text; +BEGIN + BEGIN + parsed_canonical := NEW.intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect intent canonical fingerprint must be valid JSON'; + END; + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 8 + OR pg_catalog.jsonb_typeof(intent) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent)) <> 2 + OR pg_catalog.jsonb_typeof(intent -> 'request') IS DISTINCT FROM 'object' + OR NEW.snapshot ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot ->> 'effectId' IS DISTINCT FROM NEW.effect_id + OR NEW.snapshot ->> 'currentState' IS DISTINCT FROM NEW.current_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + OR (NEW.snapshot ->> 'updatedAt')::timestamptz IS DISTINCT FROM NEW.updated_at + OR NEW.updated_at < NEW.requested_at + OR NEW.snapshot -> 'intent' IS DISTINCT FROM intent + OR NEW.snapshot -> 'resolution' IS DISTINCT FROM coalesce(NEW.resolution_json, 'null'::jsonb) + OR intent IS DISTINCT FROM parsed_canonical + OR intent_kind IS DISTINCT FROM NEW.effect_kind + OR (NEW.current_state = 'REQUESTED' AND (NEW.current_revision <> 1 OR NEW.resolution_json IS NOT NULL)) + OR (NEW.current_state IN ('SUCCEEDED', 'REJECTED') AND NEW.resolution_json IS NULL) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger relational state must exactly match its canonical snapshot'; + END IF; + + IF NEW.effect_kind = 'RESERVATION_CREATE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 5 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + ELSIF NEW.effect_kind = 'RESERVATION_RELEASE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 3 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,reservation,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,reservation,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,reservation,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + ELSIF NEW.effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 4 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,confirmation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,protectionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,confirmation,reservation,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,confirmation,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,confirmation,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,confirmation,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,confirmation,reservation,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,confirmation,reservation,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Commitment Protection ledger scope does not match its canonical business intent'; + END IF; + ELSIF NEW.effect_kind IN ('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE') THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 12 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,backendConfigurationRef,resourceId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,backendId}' IS DISTINCT FROM NEW.authority_backend_id + OR NEW.reservation_id IS NOT NULL OR NEW.attempt_id IS NOT NULL THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + + PERFORM 1 FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.authority_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = NEW.authority_backend_kind + AND authority.backend_id = NEW.authority_backend_id + FOR KEY SHARE; + IF NOT FOUND THEN RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; END IF; + + IF NEW.resolution_json IS NOT NULL THEN + resolution_identity := NEW.resolution_json #>> '{effect,request,effectId}'; + resolution_business_request := CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN NEW.resolution_json #> '{effect,request}' - 'mutationId' - 'requestedAt' - 'sourceActionInvocationId' + WHEN 'RESERVATION_RELEASE' THEN NEW.resolution_json #> '{effect,request}' - 'mutationId' - 'requestedAt' - 'sourceActionInvocationId' + WHEN 'ESTABLISH_COMMITMENT_PROTECTION' THEN NEW.resolution_json #> '{effect,request}' + WHEN 'PHYSICAL_RECEIPT' THEN NEW.resolution_json #> '{effect,request}' - 'actionInvocationId' - 'requestedAt' + WHEN 'PHYSICAL_ISSUE' THEN NEW.resolution_json #> '{effect,request}' - 'actionInvocationId' - 'requestedAt' + END; + IF NEW.resolution_json ->> '_tag' IS DISTINCT FROM NEW.effect_kind + OR resolution_identity IS DISTINCT FROM NEW.effect_id + OR resolution_business_request IS DISTINCT FROM intent -> 'request' + OR ( + NEW.effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' + AND NEW.resolution_json #>> '{effect,_tag}' = 'PROTECTED' + AND ( + NEW.resolution_json #> '{effect,protection,ref}' IS DISTINCT FROM intent #> '{request,protectionRef}' + OR NEW.resolution_json #> '{effect,protection,confirmation}' IS DISTINCT FROM intent #> '{request,confirmation}' + OR NEW.resolution_json #>> '{effect,protection,authorityEvidence,effectId}' IS DISTINCT FROM NEW.effect_id + OR NEW.resolution_json #>> '{effect,protection,authorityEvidence,operation}' IS DISTINCT FROM 'COMMITMENT_PROTECTION' + ) + ) + OR NEW.current_state IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'RECONCILIATION_REQUIRED' THEN 'INDETERMINATE' WHEN 'ESTABLISHED' THEN 'SUCCEEDED' WHEN 'RESOLVED_NO_RESERVATION' THEN 'REJECTED' END + WHEN 'RESERVATION_RELEASE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'RELEASED' THEN 'SUCCEEDED' WHEN 'NOT_RELEASABLE' THEN 'REJECTED' END + WHEN 'ESTABLISH_COMMITMENT_PROTECTION' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'PROTECTED' THEN 'SUCCEEDED' WHEN 'NOT_PROTECTABLE' THEN 'REJECTED' END + WHEN 'PHYSICAL_RECEIPT' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'APPLIED' THEN 'SUCCEEDED' WHEN 'REJECTED' THEN 'REJECTED' END + WHEN 'PHYSICAL_ISSUE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'APPLIED' THEN 'SUCCEEDED' WHEN 'REJECTED' THEN 'REJECTED' END + END) THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect resolution must preserve exact business intent, kind, identity, and terminal meaning'; + END IF; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_commitment_protection_scope"() FROM PUBLIC, "ontos_runtime"; +REVOKE ALL ON FUNCTION "inventory"."enforce_commitment_protection_lifecycle"() FROM PUBLIC, "ontos_runtime"; +REVOKE ALL ON FUNCTION "inventory"."enforce_commitment_protection_history_scope"() FROM PUBLIC, "ontos_runtime"; +REVOKE ALL ON FUNCTION "inventory"."reject_commitment_protection_history_mutation"() FROM PUBLIC, "ontos_runtime"; +REVOKE ALL ON FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() FROM PUBLIC, "ontos_runtime"; +REVOKE ALL ON FUNCTION "inventory"."claim_inventory_effect_ledger"(uuid, uuid, text, jsonb) FROM PUBLIC; +GRANT EXECUTE ON FUNCTION "inventory"."claim_inventory_effect_ledger"(uuid, uuid, text, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260925014556_inventory-commitment-protections/snapshot.json b/app/verticals/inventory/drizzle/20260925014556_inventory-commitment-protections/snapshot.json new file mode 100644 index 000000000..7bbcaa364 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925014556_inventory-commitment-protections/snapshot.json @@ -0,0 +1,13085 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "0eeac4e2-e60a-4c40-8141-e88b4749d969", + "prevIds": [ + "5ccf313f-5a4d-4547-8d40-bff21369fdd6" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": true, + "name": "commitment_protection_history_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": true, + "name": "commitment_protections_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + } + ], + "renames": [] +} diff --git a/app/verticals/inventory/drizzle/20260925044500_inventory-obligation-authority-capabilities/migration.sql b/app/verticals/inventory/drizzle/20260925044500_inventory-obligation-authority-capabilities/migration.sql new file mode 100644 index 000000000..fe25d82eb --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925044500_inventory-obligation-authority-capabilities/migration.sql @@ -0,0 +1,164 @@ +ALTER TABLE "inventory"."obligations" ADD COLUMN "authority_exact_reservation_capability" text; +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" ADD COLUMN "authority_stock_correction_capability" text; +--> statement-breakpoint +UPDATE "inventory"."obligations" AS obligation +SET + "authority_exact_reservation_capability" = configuration."exact_reservation_capability", + "authority_stock_correction_capability" = configuration."stock_correction_capability" +FROM "inventory"."backend_configurations" AS configuration +WHERE configuration."tenant_id" = obligation."tenant_id" + AND configuration."configuration_id" = obligation."owner_configuration_id"; +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" ALTER COLUMN "authority_exact_reservation_capability" SET NOT NULL; +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" ALTER COLUMN "authority_stock_correction_capability" SET NOT NULL; +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" DROP CONSTRAINT "inventory_obligations_authority_ck"; +--> statement-breakpoint +ALTER TABLE "inventory"."obligations" ADD CONSTRAINT "inventory_obligations_authority_ck" CHECK ( + "authority_backend_kind" in ('external_business_system', 'ontos_wms') + and "authority_exact_reservation_capability" in ('SUPPORTED', 'UNSUPPORTED') + and "authority_stock_correction_capability" in ('SUPPORTED', 'UNSUPPORTED') + and ( + "authority_backend_kind" <> 'ontos_wms' + or ( + "authority_exact_reservation_capability" = 'SUPPORTED' + and "authority_stock_correction_capability" = 'SUPPORTED' + ) + ) + and "authority_revision" = 1 +); +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."enforce_obligation_authority"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'UPDATE' + AND NEW.obligation_id IS NOT DISTINCT FROM OLD.obligation_id + AND NEW.tenant_id IS NOT DISTINCT FROM OLD.tenant_id + AND NEW.origin_kind IS NOT DISTINCT FROM OLD.origin_kind + AND NEW.attempt_id IS NOT DISTINCT FROM OLD.attempt_id + AND NEW.source_system IS NOT DISTINCT FROM OLD.source_system + AND NEW.source_order_id IS NOT DISTINCT FROM OLD.source_order_id + AND NEW.source_obligation_id IS NOT DISTINCT FROM OLD.source_obligation_id + AND NEW.customer_configuration_id IS NOT DISTINCT FROM OLD.customer_configuration_id + AND NEW.owner_configuration_id IS NOT DISTINCT FROM OLD.owner_configuration_id + AND NEW.authority_backend_kind IS NOT DISTINCT FROM OLD.authority_backend_kind + AND NEW.authority_backend_id IS NOT DISTINCT FROM OLD.authority_backend_id + AND NEW.authority_exact_reservation_capability IS NOT DISTINCT FROM OLD.authority_exact_reservation_capability + AND NEW.authority_stock_correction_capability IS NOT DISTINCT FROM OLD.authority_stock_correction_capability + AND NEW.authority_selected_at IS NOT DISTINCT FROM OLD.authority_selected_at + AND NEW.authority_revision IS NOT DISTINCT FROM OLD.authority_revision + AND NEW.established_at IS NOT DISTINCT FROM OLD.established_at + THEN + RETURN NEW; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS configuration + WHERE configuration.tenant_id = NEW.tenant_id + AND configuration.configuration_id = NEW.owner_configuration_id + AND configuration.customer_configuration_id = NEW.customer_configuration_id + AND configuration.backend_kind = NEW.authority_backend_kind + AND configuration.backend_id = NEW.authority_backend_id + AND configuration.exact_reservation_capability = NEW.authority_exact_reservation_capability + AND configuration.stock_correction_capability = NEW.authority_stock_correction_capability + AND configuration.selected_at = NEW.authority_selected_at + AND configuration.revision = NEW.authority_revision + AND configuration.exact_reservation_capability = 'SUPPORTED' + FOR UPDATE; + + IF NOT FOUND THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_exact_authority_ck', + MESSAGE = 'Inventory Obligation must retain the exact selected backend configuration snapshot'; + END IF; + + RETURN NEW; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."reject_obligation_origin_mutation"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +BEGIN + IF TG_OP = 'DELETE' + OR NEW.obligation_id IS DISTINCT FROM OLD.obligation_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.origin_kind IS DISTINCT FROM OLD.origin_kind + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.source_system IS DISTINCT FROM OLD.source_system + OR NEW.source_order_id IS DISTINCT FROM OLD.source_order_id + OR NEW.source_obligation_id IS DISTINCT FROM OLD.source_obligation_id + OR NEW.customer_configuration_id IS DISTINCT FROM OLD.customer_configuration_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.authority_backend_kind IS DISTINCT FROM OLD.authority_backend_kind + OR NEW.authority_backend_id IS DISTINCT FROM OLD.authority_backend_id + OR NEW.authority_exact_reservation_capability IS DISTINCT FROM OLD.authority_exact_reservation_capability + OR NEW.authority_stock_correction_capability IS DISTINCT FROM OLD.authority_stock_correction_capability + OR NEW.authority_selected_at IS DISTINCT FROM OLD.authority_selected_at + OR NEW.authority_revision IS DISTINCT FROM OLD.authority_revision + OR NEW.established_at IS DISTINCT FROM OLD.established_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Inventory Obligation identity, origin, authority, and establishment evidence are immutable'; + END IF; + + IF OLD.origin_kind = 'IMPORTED_PROVEN_ORDER' THEN + IF NEW.lifecycle_meaning IS DISTINCT FROM OLD.lifecycle_meaning + OR NEW.accepted_order_id IS DISTINCT FROM OLD.accepted_order_id + OR NEW.order_evidence_ref IS DISTINCT FROM OLD.order_evidence_ref + OR NEW.order_evidence_observed_at IS DISTINCT FROM OLD.order_evidence_observed_at + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Imported committed Obligation and Order evidence are immutable'; + END IF; + RETURN NEW; + END IF; + + IF OLD.origin_kind <> 'ORDER_COMMITMENT_ATTEMPT' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Inventory Obligation origin is invalid'; + END IF; + + IF NEW.lifecycle_meaning IS NOT DISTINCT FROM OLD.lifecycle_meaning + AND NEW.accepted_order_id IS NOT DISTINCT FROM OLD.accepted_order_id + AND NEW.order_evidence_ref IS NOT DISTINCT FROM OLD.order_evidence_ref + AND NEW.order_evidence_observed_at IS NOT DISTINCT FROM OLD.order_evidence_observed_at + THEN + RETURN NEW; + END IF; + + IF OLD.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND OLD.accepted_order_id IS NULL + AND OLD.order_evidence_ref IS NULL + AND OLD.order_evidence_observed_at IS NULL + AND NEW.lifecycle_meaning = 'COMMITTED_OBLIGATION' + AND NEW.accepted_order_id IS NOT NULL + AND NEW.order_evidence_ref IS NOT NULL + AND NEW.order_evidence_observed_at IS NOT NULL + THEN + RETURN NEW; + END IF; + + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_obligations_immutable_origin_ck', + MESSAGE = 'Runtime Inventory Obligation permits only one provisional-to-committed Order binding'; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_obligation_authority"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."reject_obligation_origin_mutation"() FROM PUBLIC, "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260925044500_inventory-obligation-authority-capabilities/snapshot.json b/app/verticals/inventory/drizzle/20260925044500_inventory-obligation-authority-capabilities/snapshot.json new file mode 100644 index 000000000..589666d29 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925044500_inventory-obligation-authority-capabilities/snapshot.json @@ -0,0 +1,13111 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "80bd5289-90a5-431c-99a8-84c89bd76231", + "prevIds": [ + "0eeac4e2-e60a-4c40-8141-e88b4749d969" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": true, + "name": "commitment_protection_history_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": true, + "name": "commitment_protections_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + } + ], + "renames": [] +} diff --git a/app/verticals/inventory/drizzle/20260925092712_binding-correction-reconciliation-impact/migration.sql b/app/verticals/inventory/drizzle/20260925092712_binding-correction-reconciliation-impact/migration.sql new file mode 100644 index 000000000..b7d8dc216 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925092712_binding-correction-reconciliation-impact/migration.sql @@ -0,0 +1,33 @@ +CREATE TABLE "inventory"."binding_correction_reconciliations" ( + "reconciliation_id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), + "tenant_id" uuid NOT NULL, + "binding_id" uuid NOT NULL, + "binding_revision" integer NOT NULL, + "correction_evidence_ref" text NOT NULL, + "corrected_at" timestamp with time zone NOT NULL, + "obligation_id" uuid NOT NULL, + "purchase_demand_occurrence_id" text NOT NULL, + "historical_stock_item_id" uuid NOT NULL, + "current_stock_item_id" uuid NOT NULL, + "reason" text DEFAULT 'POST_COMMIT_BINDING_MISMATCH' NOT NULL, + "status" text DEFAULT 'OPEN' NOT NULL, + "recorded_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "inventory_binding_correction_reconciliations_meaning_ck" CHECK ("binding_revision" >= 2 and char_length(btrim("correction_evidence_ref")) between 1 and 300 and char_length(btrim("purchase_demand_occurrence_id")) between 1 and 300 and "reason" = 'POST_COMMIT_BINDING_MISMATCH' and "status" = 'OPEN' and "historical_stock_item_id" <> "current_stock_item_id") +); +--> statement-breakpoint +ALTER TABLE "inventory"."binding_correction_reconciliations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_binding_correction_reconciliations_scope_id_uk" ON "inventory"."binding_correction_reconciliations" ("tenant_id","reconciliation_id");--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_binding_correction_reconciliations_observation_uk" ON "inventory"."binding_correction_reconciliations" ("tenant_id","binding_id","binding_revision","obligation_id","purchase_demand_occurrence_id");--> statement-breakpoint +CREATE INDEX "inventory_binding_correction_reconciliations_open_idx" ON "inventory"."binding_correction_reconciliations" ("tenant_id","status","corrected_at");--> statement-breakpoint +CREATE INDEX "inventory_obligation_requirements_binding_impact_idx" ON "inventory"."obligation_requirements" ("tenant_id","binding_id","stock_item_id","exact_selection_meaning_kind","exact_selection_meaning_id");--> statement-breakpoint +ALTER TABLE "inventory"."binding_correction_reconciliations" ADD CONSTRAINT "inventory_binding_correction_reconciliations_requirement_fk" FOREIGN KEY ("tenant_id","obligation_id","purchase_demand_occurrence_id") REFERENCES "inventory"."obligation_requirements"("tenant_id","obligation_id","purchase_demand_occurrence_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."binding_correction_reconciliations" ADD CONSTRAINT "inventory_binding_correction_reconciliations_historical_item_fk" FOREIGN KEY ("tenant_id","historical_stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +ALTER TABLE "inventory"."binding_correction_reconciliations" ADD CONSTRAINT "inventory_binding_correction_reconciliations_current_item_fk" FOREIGN KEY ("tenant_id","current_stock_item_id") REFERENCES "inventory"."stock_items"("tenant_id","stock_item_id") ON DELETE RESTRICT;--> statement-breakpoint +CREATE POLICY "inventory_binding_correction_reconciliations_tenant_select" ON "inventory"."binding_correction_reconciliations" AS PERMISSIVE FOR SELECT TO "ontos_runtime" USING ("inventory"."binding_correction_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_binding_correction_reconciliations_tenant_insert" ON "inventory"."binding_correction_reconciliations" AS PERMISSIVE FOR INSERT TO "ontos_runtime" WITH CHECK ("inventory"."binding_correction_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_binding_correction_reconciliations_tenant_update" ON "inventory"."binding_correction_reconciliations" AS PERMISSIVE FOR UPDATE TO "ontos_runtime" USING ("inventory"."binding_correction_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid) WITH CHECK ("inventory"."binding_correction_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid);--> statement-breakpoint +CREATE POLICY "inventory_binding_correction_reconciliations_tenant_delete" ON "inventory"."binding_correction_reconciliations" AS PERMISSIVE FOR DELETE TO "ontos_runtime" USING ("inventory"."binding_correction_reconciliations"."tenant_id" = nullif(current_setting('ontos.tenant_id', true), '')::uuid); +--> statement-breakpoint +ALTER TABLE "inventory"."binding_correction_reconciliations" FORCE ROW LEVEL SECURITY; +--> statement-breakpoint +GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE "inventory"."binding_correction_reconciliations" TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260925092712_binding-correction-reconciliation-impact/snapshot.json b/app/verticals/inventory/drizzle/20260925092712_binding-correction-reconciliation-impact/snapshot.json new file mode 100644 index 000000000..9fbbd5b72 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925092712_binding-correction-reconciliation-impact/snapshot.json @@ -0,0 +1,13575 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "b459c033-f282-49ed-8fb6-d1986398efaa", + "prevIds": [ + "80bd5289-90a5-431c-99a8-84c89bd76231" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260925094231_replace-reservation-create-effect-finalizer/migration.sql b/app/verticals/inventory/drizzle/20260925094231_replace-reservation-create-effect-finalizer/migration.sql new file mode 100644 index 000000000..b164359fb --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925094231_replace-reservation-create-effect-finalizer/migration.sql @@ -0,0 +1,470 @@ +CREATE OR REPLACE FUNCTION "inventory"."finalize_reservation_create_effect_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text, + p_terminal jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + allocation jsonb; + current_binding "inventory"."catalog_to_stock_bindings"%ROWTYPE; + current_effect "inventory"."reservation_create_effects"%ROWTYPE; + expected_allocation_count integer := 0; + requirement jsonb; + stored_count integer; + stored_obligation "inventory"."obligations"%ROWTYPE; + terminal_tag text; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Inventory Reservation create-effect worker scope mismatch'; + END IF; + + SELECT effect.* + INTO current_effect + FROM "inventory"."reservation_create_effects" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + terminal_tag := p_terminal ->> '_tag'; + IF pg_catalog.jsonb_typeof(p_terminal) IS DISTINCT FROM 'object' + OR terminal_tag IS NULL + OR terminal_tag NOT IN ( + 'ESTABLISHED', + 'RECONCILIATION_REQUIRED', + 'INDETERMINATE', + 'RESOLVED_NO_RESERVATION' + ) + OR p_terminal -> 'request' IS DISTINCT FROM current_effect.request_json + OR p_terminal #>> '{request,effectId}' IS DISTINCT FROM current_effect.effect_id + OR p_terminal #>> '{request,legalEntityId}' IS DISTINCT FROM current_effect.legal_entity_id::text + OR p_terminal #>> '{request,mutationId}' IS DISTINCT FROM current_effect.mutation_id::text + OR p_terminal #>> '{request,sourceActionInvocationId}' + IS DISTINCT FROM current_effect.source_action_invocation_id::text + OR p_terminal #>> '{request,authority,tenantId}' IS DISTINCT FROM current_effect.tenant_id::text + OR p_terminal #>> '{request,authority,configurationId}' + IS DISTINCT FROM current_effect.backend_configuration_id::text + OR p_terminal #>> '{request,reservation,ref,resourceId}' IS DISTINCT FROM current_effect.reservation_id::text + OR p_terminal #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM current_effect.attempt_id + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Inventory Reservation create-effect terminal payload must exactly match its durable request'; + END IF; + + IF terminal_tag = 'ESTABLISHED' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 4 + OR coalesce(pg_catalog.length(pg_catalog.btrim(p_terminal ->> 'ownerEvidenceRef')), 0) NOT BETWEEN 1 AND 300 + OR pg_catalog.jsonb_typeof(p_terminal -> 'reservation') IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal -> 'reservation')) <> 6 + OR p_terminal #> '{reservation,authority}' IS DISTINCT FROM current_effect.request_json -> 'authority' + OR p_terminal #> '{reservation,origin}' IS DISTINCT FROM current_effect.request_json #> '{reservation,origin}' + OR p_terminal #> '{reservation,ref}' IS DISTINCT FROM current_effect.request_json #> '{reservation,ref}' + OR p_terminal #> '{reservation,requirements}' + IS DISTINCT FROM current_effect.request_json #> '{reservation,requirements}' + OR p_terminal #>> '{reservation,lifecycleMeaning}' IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + OR (p_terminal #>> '{reservation,establishedAt}')::timestamptz IS NULL + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Established Inventory Reservation must exactly preserve the durable request and allocation plan'; + END IF; + ELSIF terminal_tag = 'RECONCILIATION_REQUIRED' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 5 + OR pg_catalog.jsonb_typeof(p_terminal -> 'constrainedAllocations') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_terminal -> 'constrainedAllocations') < 1 + OR (p_terminal ->> 'observedAt')::timestamptz IS NULL + OR coalesce(pg_catalog.length(pg_catalog.btrim(p_terminal ->> 'ownerEvidenceRef')), 0) NOT BETWEEN 1 AND 300 + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'constrainedAllocations') AS observed(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT observed.entry ->> 'allocationId') + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'constrainedAllocations') AS observed(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'constrainedAllocations') AS observed(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + WHERE planned_allocation.entry ->> 'allocationId' = observed.entry ->> 'allocationId' + AND planned_allocation.entry -> 'stockItemRef' = observed.entry -> 'stockItemRef' + AND planned_allocation.entry -> 'positionRef' = observed.entry -> 'stockPositionRef' + AND planned_allocation.entry #> '{quantity,unitRef}' = observed.entry #> '{quantity,unitRef}' + AND (observed.entry #>> '{quantity,amount}')::numeric > 0 + AND (observed.entry #>> '{quantity,amount}')::numeric + <= (planned_allocation.entry #>> '{quantity,amount}')::numeric + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Reconciliation-required Inventory Reservation evidence must remain within the durable plan'; + END IF; + ELSIF terminal_tag = 'INDETERMINATE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 5 + OR pg_catalog.jsonb_typeof(p_terminal -> 'possibleConstrainedAllocations') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(p_terminal -> 'possibleConstrainedAllocations') < 1 + OR (p_terminal ->> 'observedAt')::timestamptz IS NULL + OR p_terminal ->> 'reason' IS NULL + OR p_terminal ->> 'reason' NOT IN ( + 'DISPATCH_PENDING', + 'BACKEND_OUTCOME_UNKNOWN', + 'EVIDENCE_UNVERIFIABLE', + 'AUTHORITY_UNAVAILABLE' + ) + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + ) + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(DISTINCT possible.entry ->> 'allocationId') + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(p_terminal -> 'possibleConstrainedAllocations') AS possible(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + planned_requirement.entry -> 'allocations' + ) AS planned_allocation(entry) + WHERE planned_allocation.entry ->> 'allocationId' = possible.entry ->> 'allocationId' + AND planned_allocation.entry -> 'stockItemRef' = possible.entry -> 'stockItemRef' + AND planned_allocation.entry -> 'positionRef' = possible.entry -> 'stockPositionRef' + AND planned_allocation.entry -> 'quantity' = possible.entry -> 'quantity' + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Indeterminate Inventory Reservation evidence must retain bounded typed uncertainty'; + END IF; + ELSE + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(p_terminal)) <> 5 + OR p_terminal -> 'effectAbsenceProven' IS DISTINCT FROM 'true'::jsonb + OR (p_terminal ->> 'observedAt')::timestamptz IS NULL + OR p_terminal ->> 'reason' IS NULL + OR p_terminal ->> 'reason' NOT IN ('INSUFFICIENT_STOCK', 'BACKEND_REJECTED') + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_terminal_payload_ck', + MESSAGE = 'Resolved Inventory Reservation absence must retain authoritative no-effect proof'; + END IF; + END IF; + + IF current_effect.state IN ('ESTABLISHED', 'RESOLVED_NO_RESERVATION') THEN + IF current_effect.record_json IS DISTINCT FROM p_terminal THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_transition_ck', + MESSAGE = 'Terminal Inventory Reservation create-effect evidence cannot be replaced'; + END IF; + RETURN QUERY SELECT current_effect.record_json; + RETURN; + END IF; + + IF terminal_tag = 'ESTABLISHED' THEN + FOR requirement IN + SELECT planned.entry + FROM pg_catalog.jsonb_array_elements( + current_effect.request_json #> '{reservation,requirements}' + ) AS planned(entry) + ORDER BY + planned.entry #>> '{exactSelectionMeaning,kind}', + planned.entry #>> '{exactSelectionMeaning,id}' + LOOP + SELECT binding.* + INTO current_binding + FROM "inventory"."catalog_to_stock_bindings" AS binding + WHERE binding.tenant_id = p_tenant_id + AND binding.exact_selection_kind = requirement #>> '{exactSelectionMeaning,kind}' + AND binding.exact_selection_meaning_id = requirement #>> '{exactSelectionMeaning,id}' + FOR UPDATE; + + IF NOT FOUND + OR current_binding.binding_id::text IS DISTINCT FROM requirement #>> '{bindingRef,resourceId}' + OR current_binding.stock_item_id::text + IS DISTINCT FROM requirement #>> '{stockItem,stockItemRef,resourceId}' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_stale_binding_ck', + MESSAGE = 'Inventory Reservation cannot establish against a corrected Catalog-to-Stock Binding'; + END IF; + END LOOP; + + INSERT INTO "inventory"."obligations" ( + obligation_id, + tenant_id, + origin_kind, + lifecycle_meaning, + attempt_id, + accepted_order_id, + order_evidence_ref, + order_evidence_observed_at, + source_system, + source_order_id, + source_obligation_id, + customer_configuration_id, + owner_configuration_id, + authority_backend_kind, + authority_backend_id, + authority_exact_reservation_capability, + authority_stock_correction_capability, + authority_selected_at, + authority_revision, + established_at + ) VALUES ( + (p_terminal #>> '{reservation,ref,resourceId}')::uuid, + p_tenant_id, + 'ORDER_COMMITMENT_ATTEMPT', + 'PROVISIONAL_RESERVATION', + current_effect.attempt_id, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + current_effect.customer_configuration_id, + current_effect.backend_configuration_id, + current_effect.request_json #>> '{authority,selection,backend}', + current_effect.backend_id, + current_effect.request_json #>> '{authority,selection,exactReservationCapability}', + current_effect.request_json #>> '{authority,selection,stockCorrectionCapability}', + (current_effect.request_json #>> '{authority,selectedAt}')::timestamptz, + (current_effect.request_json #>> '{authority,revision}')::integer, + (p_terminal #>> '{reservation,establishedAt}')::timestamptz + ) + ON CONFLICT DO NOTHING; + + SELECT obligation.* + INTO stored_obligation + FROM "inventory"."obligations" AS obligation + WHERE obligation.obligation_id = current_effect.reservation_id + FOR UPDATE; + + IF NOT FOUND + OR stored_obligation.tenant_id IS DISTINCT FROM p_tenant_id + OR stored_obligation.origin_kind IS DISTINCT FROM 'ORDER_COMMITMENT_ATTEMPT' + OR stored_obligation.lifecycle_meaning IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + OR stored_obligation.attempt_id IS DISTINCT FROM current_effect.attempt_id + OR stored_obligation.accepted_order_id IS NOT NULL + OR stored_obligation.order_evidence_ref IS NOT NULL + OR stored_obligation.order_evidence_observed_at IS NOT NULL + OR stored_obligation.source_system IS NOT NULL + OR stored_obligation.source_order_id IS NOT NULL + OR stored_obligation.source_obligation_id IS NOT NULL + OR stored_obligation.customer_configuration_id IS DISTINCT FROM current_effect.customer_configuration_id + OR stored_obligation.owner_configuration_id IS DISTINCT FROM current_effect.backend_configuration_id + OR stored_obligation.authority_backend_kind + IS DISTINCT FROM current_effect.request_json #>> '{authority,selection,backend}' + OR stored_obligation.authority_backend_id IS DISTINCT FROM current_effect.backend_id + OR stored_obligation.authority_exact_reservation_capability + IS DISTINCT FROM current_effect.request_json #>> '{authority,selection,exactReservationCapability}' + OR stored_obligation.authority_stock_correction_capability + IS DISTINCT FROM current_effect.request_json #>> '{authority,selection,stockCorrectionCapability}' + OR stored_obligation.authority_selected_at + IS DISTINCT FROM (current_effect.request_json #>> '{authority,selectedAt}')::timestamptz + OR stored_obligation.authority_revision + IS DISTINCT FROM (current_effect.request_json #>> '{authority,revision}')::integer + OR stored_obligation.established_at + IS DISTINCT FROM (p_terminal #>> '{reservation,establishedAt}')::timestamptz + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation identity is already bound to different obligation evidence'; + END IF; + + FOR requirement IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(p_terminal #> '{reservation,requirements}') AS required(entry) + LOOP + INSERT INTO "inventory"."obligation_requirements" ( + tenant_id, + obligation_id, + purchase_demand_occurrence_id, + binding_id, + catalog_selection, + exact_selection_meaning_id, + exact_selection_meaning_kind, + stock_item_id, + stock_item_revision, + stock_item_snapshot, + requested_amount, + unit_module_id, + unit_resource_id, + unit_resource_type, + unit_tenant_id + ) VALUES ( + p_tenant_id, + current_effect.reservation_id, + requirement ->> 'purchaseDemandOccurrenceId', + (requirement #>> '{bindingRef,resourceId}')::uuid, + requirement -> 'catalogSelection', + requirement #>> '{exactSelectionMeaning,id}', + requirement #>> '{exactSelectionMeaning,kind}', + (requirement #>> '{stockItem,stockItemRef,resourceId}')::uuid, + (requirement #>> '{stockItem,revision}')::integer, + requirement -> 'stockItem', + (requirement ->> 'quantity')::numeric, + requirement #>> '{unitRef,moduleId}', + (requirement #>> '{unitRef,resourceId}')::uuid, + requirement #>> '{unitRef,resourceType}', + (requirement #>> '{unitRef,tenantId}')::uuid + ) + ON CONFLICT DO NOTHING; + + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = p_tenant_id + AND stored_requirement.obligation_id = current_effect.reservation_id + AND stored_requirement.purchase_demand_occurrence_id = requirement ->> 'purchaseDemandOccurrenceId' + AND stored_requirement.binding_id = (requirement #>> '{bindingRef,resourceId}')::uuid + AND stored_requirement.catalog_selection = requirement -> 'catalogSelection' + AND stored_requirement.exact_selection_meaning_id = requirement #>> '{exactSelectionMeaning,id}' + AND stored_requirement.exact_selection_meaning_kind = requirement #>> '{exactSelectionMeaning,kind}' + AND stored_requirement.stock_item_id = (requirement #>> '{stockItem,stockItemRef,resourceId}')::uuid + AND stored_requirement.stock_item_revision = (requirement #>> '{stockItem,revision}')::integer + AND stored_requirement.stock_item_snapshot = requirement -> 'stockItem' + AND stored_requirement.requested_amount = (requirement ->> 'quantity')::numeric + AND stored_requirement.unit_module_id = requirement #>> '{unitRef,moduleId}' + AND stored_requirement.unit_resource_id = (requirement #>> '{unitRef,resourceId}')::uuid + AND stored_requirement.unit_resource_type = requirement #>> '{unitRef,resourceType}' + AND stored_requirement.unit_tenant_id = (requirement #>> '{unitRef,tenantId}')::uuid + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation requirement identity is already bound to different evidence'; + END IF; + + FOR allocation IN + SELECT entry + FROM pg_catalog.jsonb_array_elements(requirement -> 'allocations') AS allocated(entry) + LOOP + expected_allocation_count := expected_allocation_count + 1; + INSERT INTO "inventory"."obligation_allocations" ( + tenant_id, + obligation_id, + allocation_id, + purchase_demand_occurrence_id, + stock_item_id, + stock_position_id, + allocated_amount, + unit_module_id, + unit_resource_id, + unit_resource_type, + unit_tenant_id + ) VALUES ( + p_tenant_id, + current_effect.reservation_id, + allocation ->> 'allocationId', + requirement ->> 'purchaseDemandOccurrenceId', + (allocation #>> '{stockItemRef,resourceId}')::uuid, + (allocation #>> '{positionRef,resourceId}')::uuid, + (allocation #>> '{quantity,amount}')::numeric, + allocation #>> '{quantity,unitRef,moduleId}', + (allocation #>> '{quantity,unitRef,resourceId}')::uuid, + allocation #>> '{quantity,unitRef,resourceType}', + (allocation #>> '{quantity,unitRef,tenantId}')::uuid + ) + ON CONFLICT DO NOTHING; + + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = p_tenant_id + AND stored_allocation.obligation_id = current_effect.reservation_id + AND stored_allocation.allocation_id = allocation ->> 'allocationId' + AND stored_allocation.purchase_demand_occurrence_id = requirement ->> 'purchaseDemandOccurrenceId' + AND stored_allocation.stock_item_id = (allocation #>> '{stockItemRef,resourceId}')::uuid + AND stored_allocation.stock_position_id = (allocation #>> '{positionRef,resourceId}')::uuid + AND stored_allocation.allocated_amount = (allocation #>> '{quantity,amount}')::numeric + AND stored_allocation.unit_module_id = allocation #>> '{quantity,unitRef,moduleId}' + AND stored_allocation.unit_resource_id = (allocation #>> '{quantity,unitRef,resourceId}')::uuid + AND stored_allocation.unit_resource_type = allocation #>> '{quantity,unitRef,resourceType}' + AND stored_allocation.unit_tenant_id = (allocation #>> '{quantity,unitRef,tenantId}')::uuid + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation allocation identity is already bound to different evidence'; + END IF; + END LOOP; + END LOOP; + + SELECT pg_catalog.count(*)::integer + INTO stored_count + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = p_tenant_id + AND stored_requirement.obligation_id = current_effect.reservation_id; + IF stored_count IS DISTINCT FROM pg_catalog.jsonb_array_length(p_terminal #> '{reservation,requirements}') THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation requirement set must exactly match terminal evidence'; + END IF; + + SELECT pg_catalog.count(*)::integer + INTO stored_count + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = p_tenant_id + AND stored_allocation.obligation_id = current_effect.reservation_id; + IF stored_count IS DISTINCT FROM expected_allocation_count THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_create_effects_obligation_conflict_ck', + MESSAGE = 'Inventory Reservation allocation set must exactly match terminal evidence'; + END IF; + END IF; + + UPDATE "inventory"."reservation_create_effects" AS effect + SET state = terminal_tag, + record_json = p_terminal, + updated_at = pg_catalog.clock_timestamp() + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id; + + RETURN QUERY SELECT p_terminal; +END; +$$; diff --git a/app/verticals/inventory/drizzle/20260925094231_replace-reservation-create-effect-finalizer/snapshot.json b/app/verticals/inventory/drizzle/20260925094231_replace-reservation-create-effect-finalizer/snapshot.json new file mode 100644 index 000000000..73cfa9107 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925094231_replace-reservation-create-effect-finalizer/snapshot.json @@ -0,0 +1,13575 @@ +{ + "id": "7a61649e-9898-4a49-a4ac-a00358b2cd5f", + "prevIds": [ + "b459c033-f282-49ed-8fb6-d1986398efaa" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260925094950_current-stock-item-exact-meaning-uniqueness/migration.sql b/app/verticals/inventory/drizzle/20260925094950_current-stock-item-exact-meaning-uniqueness/migration.sql new file mode 100644 index 000000000..d89fade36 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925094950_current-stock-item-exact-meaning-uniqueness/migration.sql @@ -0,0 +1,2 @@ +DROP INDEX "inventory"."inventory_stock_items_exact_meaning_uk";--> statement-breakpoint +CREATE UNIQUE INDEX "inventory_stock_items_exact_meaning_uk" ON "inventory"."stock_items" ("tenant_id","exact_selection_meaning_id") WHERE "lifecycle_state" = 'CURRENT'; \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260925094950_current-stock-item-exact-meaning-uniqueness/snapshot.json b/app/verticals/inventory/drizzle/20260925094950_current-stock-item-exact-meaning-uniqueness/snapshot.json new file mode 100644 index 000000000..7e36c5fa6 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925094950_current-stock-item-exact-meaning-uniqueness/snapshot.json @@ -0,0 +1,13575 @@ +{ + "version": "8", + "dialect": "postgres", + "id": "6f5d93cb-9d97-4cdf-87d9-d4832ef9d766", + "prevIds": [ + "7a61649e-9898-4a49-a4ac-a00358b2cd5f" + ], + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260925094955_allow-committed-confirmation-health-revisions/migration.sql b/app/verticals/inventory/drizzle/20260925094955_allow-committed-confirmation-health-revisions/migration.sql new file mode 100644 index 000000000..0065f8a9f --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925094955_allow-committed-confirmation-health-revisions/migration.sql @@ -0,0 +1,409 @@ +-- Binding-correction health revisions preserve the immutable provisional Reservation snapshot while +-- validating against the same Reservation after its legal commit transition. +CREATE OR REPLACE FUNCTION "inventory"."enforce_reservation_confirmation_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + observation_tag text; +BEGIN + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 8 + OR NOT ( + NEW.snapshot ?& ARRAY[ + 'authorityEvidence', 'expiresAt', 'health', 'issuanceRank', 'issuedAt', 'ref', 'reservation', 'revision' + ] + ) + OR pg_catalog.jsonb_typeof(NEW.snapshot -> 'reservation') IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'reservation')) <> 6 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'ref')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,ref}')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,origin}')) <> 2 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,authority}')) <> 6 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{reservation,authority,selection}')) <> 4 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'authorityEvidence')) <> 5 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{authorityEvidence,issuer}')) <> 3 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{authorityEvidence,evidence}')) <> 8 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'health')) <> 2 + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot -> 'issuanceRank')) <> 3 + OR pg_catalog.jsonb_typeof(NEW.snapshot #> '{reservation,requirements}') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(NEW.snapshot #> '{reservation,requirements}') < 1 + OR NEW.snapshot #>> '{ref,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.snapshot #>> '{ref,resourceType}' IS DISTINCT FROM 'commerce.inventory.reservation-confirmation' + OR NEW.snapshot #>> '{ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{ref,resourceId}' IS DISTINCT FROM NEW.confirmation_id::text + OR NEW.snapshot #>> '{reservation,ref,moduleId}' IS DISTINCT FROM 'commerce.inventory' + OR NEW.snapshot #>> '{reservation,ref,resourceType}' + IS DISTINCT FROM 'commerce.inventory.inventory-reservation' + OR NEW.snapshot #>> '{reservation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{reservation,ref,resourceId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{reservation,origin,kind}' IS DISTINCT FROM 'ORDER_COMMITMENT_ATTEMPT' + OR NEW.snapshot #>> '{reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{reservation,lifecycleMeaning}' IS DISTINCT FROM 'PROVISIONAL_RESERVATION' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_snapshot_ck', + MESSAGE = 'Reservation Confirmation snapshot identity must exactly match its relational identity'; + END IF; + + PERFORM 1 + FROM "inventory"."obligations" AS reservation + WHERE reservation.tenant_id = NEW.tenant_id + AND reservation.obligation_id = NEW.reservation_id + AND reservation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND reservation.attempt_id = NEW.attempt_id + AND ( + ( + TG_OP = 'INSERT' + AND reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + ) + OR ( + TG_OP = 'UPDATE' + AND ( + ( + reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + ) + OR ( + reservation.lifecycle_meaning = 'COMMITTED_OBLIGATION' + AND reservation.accepted_order_id IS NOT NULL + AND reservation.order_evidence_ref IS NOT NULL + AND reservation.order_evidence_observed_at IS NOT NULL + ) + ) + ) + ) + AND reservation.source_system IS NULL + AND reservation.source_order_id IS NULL + AND reservation.source_obligation_id IS NULL + AND reservation.customer_configuration_id + = NEW.snapshot #>> '{reservation,authority,customerConfigurationId}' + AND reservation.owner_configuration_id = NEW.owner_configuration_id + AND reservation.authority_backend_kind = NEW.issuer_backend_kind + AND reservation.authority_backend_id = NEW.issuer_backend_id + AND reservation.authority_selected_at + = (NEW.snapshot #>> '{reservation,authority,selectedAt}')::timestamptz + AND reservation.authority_revision + = (NEW.snapshot #>> '{reservation,authority,revision}')::integer + AND reservation.established_at + = (NEW.snapshot #>> '{reservation,establishedAt}')::timestamptz + FOR UPDATE; + + IF NOT FOUND + OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = NEW.tenant_id + AND stored_requirement.obligation_id = NEW.reservation_id + ) IS DISTINCT FROM pg_catalog.jsonb_array_length(NEW.snapshot #> '{reservation,requirements}') + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS expected_requirement(entry) + WHERE (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(expected_requirement.entry)) <> 8 + OR pg_catalog.jsonb_typeof(expected_requirement.entry -> 'allocations') IS DISTINCT FROM 'array' + OR pg_catalog.jsonb_array_length(expected_requirement.entry -> 'allocations') < 1 + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements(expected_requirement.entry -> 'allocations') AS allocation(entry) + WHERE (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(allocation.entry)) <> 4 + ) + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_requirements" AS stored_requirement + WHERE stored_requirement.tenant_id = NEW.tenant_id + AND stored_requirement.obligation_id = NEW.reservation_id + AND stored_requirement.purchase_demand_occurrence_id + = expected_requirement.entry ->> 'purchaseDemandOccurrenceId' + AND stored_requirement.binding_id + = (expected_requirement.entry #>> '{bindingRef,resourceId}')::uuid + AND stored_requirement.catalog_selection = expected_requirement.entry -> 'catalogSelection' + AND stored_requirement.exact_selection_meaning_id + = expected_requirement.entry #>> '{exactSelectionMeaning,id}' + AND stored_requirement.exact_selection_meaning_kind + = expected_requirement.entry #>> '{exactSelectionMeaning,kind}' + AND stored_requirement.stock_item_id + = (expected_requirement.entry #>> '{stockItem,stockItemRef,resourceId}')::uuid + AND stored_requirement.stock_item_revision + = (expected_requirement.entry #>> '{stockItem,revision}')::integer + AND stored_requirement.stock_item_snapshot = expected_requirement.entry -> 'stockItem' + AND stored_requirement.requested_amount = (expected_requirement.entry ->> 'quantity')::numeric + AND stored_requirement.unit_module_id = expected_requirement.entry #>> '{unitRef,moduleId}' + AND stored_requirement.unit_resource_id + = (expected_requirement.entry #>> '{unitRef,resourceId}')::uuid + AND stored_requirement.unit_resource_type = expected_requirement.entry #>> '{unitRef,resourceType}' + AND stored_requirement.unit_tenant_id + = (expected_requirement.entry #>> '{unitRef,tenantId}')::uuid + ) + ) + OR ( + SELECT pg_catalog.count(*) + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = NEW.tenant_id + AND stored_allocation.obligation_id = NEW.reservation_id + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS expected_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + expected_requirement.entry -> 'allocations' + ) AS expected_allocation(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS expected_requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + expected_requirement.entry -> 'allocations' + ) AS expected_allocation(entry) + WHERE NOT EXISTS ( + SELECT 1 + FROM "inventory"."obligation_allocations" AS stored_allocation + WHERE stored_allocation.tenant_id = NEW.tenant_id + AND stored_allocation.obligation_id = NEW.reservation_id + AND stored_allocation.allocation_id = expected_allocation.entry ->> 'allocationId' + AND stored_allocation.purchase_demand_occurrence_id + = expected_requirement.entry ->> 'purchaseDemandOccurrenceId' + AND stored_allocation.stock_item_id + = (expected_allocation.entry #>> '{stockItemRef,resourceId}')::uuid + AND stored_allocation.stock_position_id + = (expected_allocation.entry #>> '{positionRef,resourceId}')::uuid + AND stored_allocation.allocated_amount + = (expected_allocation.entry #>> '{quantity,amount}')::numeric + AND stored_allocation.unit_module_id + = expected_allocation.entry #>> '{quantity,unitRef,moduleId}' + AND stored_allocation.unit_resource_id + = (expected_allocation.entry #>> '{quantity,unitRef,resourceId}')::uuid + AND stored_allocation.unit_resource_type + = expected_allocation.entry #>> '{quantity,unitRef,resourceType}' + AND stored_allocation.unit_tenant_id + = (expected_allocation.entry #>> '{quantity,unitRef,tenantId}')::uuid + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_exact_reservation_ck', + MESSAGE = 'Reservation Confirmation must reference one exact runtime Attempt and its immutable Reservation lineage'; + END IF; + + PERFORM 1 + FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.owner_configuration_id + AND authority.customer_configuration_id + = NEW.snapshot #>> '{reservation,authority,customerConfigurationId}' + AND authority.backend_kind = NEW.issuer_backend_kind + AND authority.backend_id = NEW.issuer_backend_id + AND authority.exact_reservation_capability = 'SUPPORTED' + AND authority.stock_correction_capability + = NEW.snapshot #>> '{reservation,authority,selection,stockCorrectionCapability}' + AND authority.selected_at + = (NEW.snapshot #>> '{reservation,authority,selectedAt}')::timestamptz + AND authority.revision = (NEW.snapshot #>> '{reservation,authority,revision}')::integer + AND NEW.snapshot #>> '{reservation,authority,tenantId}' = NEW.tenant_id::text + AND NEW.snapshot #>> '{reservation,authority,configurationId}' = NEW.owner_configuration_id::text + AND NEW.snapshot #>> '{reservation,authority,selection,backend}' = authority.backend_kind + AND NEW.snapshot #>> '{reservation,authority,selection,backendId}' = authority.backend_id + AND NEW.snapshot #>> '{reservation,authority,selection,exactReservationCapability}' + = authority.exact_reservation_capability + FOR KEY SHARE; + + IF NOT FOUND + OR pg_catalog.jsonb_typeof(NEW.snapshot -> 'authorityEvidence') IS DISTINCT FROM 'object' + OR NEW.snapshot #>> '{authorityEvidence,kind}' + IS DISTINCT FROM 'AUTHORITATIVE_RESERVATION_EVIDENCE' + OR NEW.snapshot #>> '{authorityEvidence,operation}' IS DISTINCT FROM 'RESERVATION_CONFIRMATION' + OR NEW.snapshot #>> '{authorityEvidence,effectId}' IS DISTINCT FROM NEW.authority_effect_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.snapshot #>> '{authorityEvidence,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,origin}' IS DISTINCT FROM (CASE NEW.issuer_backend_kind + WHEN 'external_business_system' THEN 'EXTERNAL_BUSINESS_SYSTEM' + ELSE 'ONTOS_WMS' + END) + OR NEW.snapshot #>> '{authorityEvidence,evidence,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,reservationId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,customerConfigurationId}' + IS DISTINCT FROM NEW.snapshot #>> '{reservation,authority,customerConfigurationId}' + OR NEW.snapshot #>> '{authorityEvidence,evidence,ownerEvidenceRef}' + IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validFrom}')::timestamptz + IS DISTINCT FROM NEW.issued_at + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validUntil}')::timestamptz + IS DISTINCT FROM NEW.expires_at + OR pg_catalog.jsonb_typeof(NEW.snapshot #> '{authorityEvidence,evidence,allocations}') + IS DISTINCT FROM 'array' + OR ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{authorityEvidence,evidence,allocations}' + ) AS authority_allocation(entry) + ) IS DISTINCT FROM ( + SELECT pg_catalog.count(*) + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS reservation_allocation(entry) + ) + OR EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{authorityEvidence,evidence,allocations}' + ) AS authority_allocation(entry) + WHERE (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(authority_allocation.entry)) <> 4 + OR NOT EXISTS ( + SELECT 1 + FROM pg_catalog.jsonb_array_elements( + NEW.snapshot #> '{reservation,requirements}' + ) AS requirement(entry) + CROSS JOIN LATERAL pg_catalog.jsonb_array_elements( + requirement.entry -> 'allocations' + ) AS reservation_allocation(entry) + WHERE reservation_allocation.entry ->> 'allocationId' + = authority_allocation.entry ->> 'allocationId' + AND reservation_allocation.entry -> 'stockItemRef' + = authority_allocation.entry -> 'stockItemRef' + AND reservation_allocation.entry -> 'positionRef' + = authority_allocation.entry -> 'stockPositionRef' + AND reservation_allocation.entry -> 'quantity' + = authority_allocation.entry -> 'quantity' + ) + ) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_exact_authority_ck', + MESSAGE = 'Reservation Confirmation authority evidence must exactly match the selected backend and Reservation'; + END IF; + + observation_tag := NEW.snapshot #>> '{health,observation,_tag}'; + IF observation_tag IS NULL + OR NEW.snapshot #>> '{health,observation,effectiveAt}' IS NULL + OR NEW.snapshot ->> 'issuedAt' IS NULL + OR (NEW.snapshot ->> 'issuedAt')::timestamptz IS DISTINCT FROM NEW.issued_at + OR NEW.snapshot ->> 'expiresAt' IS NULL + OR (NEW.snapshot ->> 'expiresAt')::timestamptz IS DISTINCT FROM NEW.expires_at + OR NEW.snapshot #>> '{issuanceRank,source}' IS DISTINCT FROM 'RESERVATION_AUTHORITY_EVIDENCE' + OR (NEW.snapshot #>> '{issuanceRank,issuedAt}')::timestamptz IS DISTINCT FROM NEW.issued_at + OR NEW.snapshot #>> '{issuanceRank,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR NEW.snapshot #>> '{health,state}' IS DISTINCT FROM NEW.current_health_state + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz < NEW.issued_at + OR ( + TG_OP = 'INSERT' + AND ( + NEW.current_revision IS DISTINCT FROM 1 + OR NEW.current_health_state IS DISTINCT FROM 'VALID' + OR observation_tag IS DISTINCT FROM 'ISSUED' + ) + ) + OR ( + observation_tag = 'ISSUED' + AND ( + NEW.current_revision IS DISTINCT FROM 1 + OR NEW.current_health_state IS DISTINCT FROM 'VALID' + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz IS DISTINCT FROM NEW.issued_at + OR NEW.snapshot #>> '{health,observation,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + ) + ) + OR ( + observation_tag = 'OWNER_HEALTHY' + AND ( + NEW.current_health_state IS DISTINCT FROM 'VALID' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,ownerEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'MATERIAL_IMPAIRMENT' + AND ( + NEW.current_health_state IS DISTINCT FROM 'AT_RISK' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,ownerEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'BINDING_CORRECTION' + AND ( + NEW.current_health_state IS DISTINCT FROM 'AT_RISK' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,correctionEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'DEFINITIVE_REVOCATION' + AND ( + NEW.current_health_state IS DISTINCT FROM 'REVOKED' + OR NEW.snapshot #>> '{health,observation,decision}' IS DISTINCT FROM 'DEFINITIVE' + OR coalesce( + pg_catalog.length(pg_catalog.btrim(NEW.snapshot #>> '{health,observation,ownerEvidenceRef}')), + 0 + ) NOT BETWEEN 1 AND 300 + ) + ) + OR ( + observation_tag = 'OWNER_UNVERIFIABLE' + AND ( + NEW.current_health_state IS DISTINCT FROM 'UNVERIFIABLE' + OR NEW.snapshot #>> '{health,observation,reason}' NOT IN ( + 'OWNER_EVIDENCE_MISSING', + 'OWNER_EVIDENCE_STALE', + 'OWNER_EVIDENCE_UNAVAILABLE', + 'OWNER_EVIDENCE_INDETERMINATE' + ) + ) + ) + OR ( + observation_tag = 'VALIDITY_ELAPSED' + AND ( + NEW.current_health_state IS DISTINCT FROM 'EXPIRED' + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz < NEW.expires_at + ) + ) + OR observation_tag NOT IN ( + 'ISSUED', + 'OWNER_HEALTHY', + 'MATERIAL_IMPAIRMENT', + 'BINDING_CORRECTION', + 'DEFINITIVE_REVOCATION', + 'OWNER_UNVERIFIABLE', + 'VALIDITY_ELAPSED' + ) + OR ( + observation_tag <> 'VALIDITY_ELAPSED' + AND (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz >= NEW.expires_at + ) + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot #> '{health,observation}')) + IS DISTINCT FROM (CASE observation_tag + WHEN 'DEFINITIVE_REVOCATION' THEN 4 + WHEN 'VALIDITY_ELAPSED' THEN 2 + ELSE 3 + END) + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_snapshot_ck', + MESSAGE = 'Reservation Confirmation snapshot, health, validity, and revision must be exact'; + END IF; + + RETURN NEW; +END; +$$; diff --git a/app/verticals/inventory/drizzle/20260925094955_allow-committed-confirmation-health-revisions/snapshot.json b/app/verticals/inventory/drizzle/20260925094955_allow-committed-confirmation-health-revisions/snapshot.json new file mode 100644 index 000000000..32eb29bc2 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925094955_allow-committed-confirmation-health-revisions/snapshot.json @@ -0,0 +1,13575 @@ +{ + "id": "39acf525-669d-45ac-825f-76627d4048b7", + "prevIds": [ + "6f5d93cb-9d97-4cdf-87d9-d4832ef9d766" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260925095228_allow-committed-protection-health-revisions/migration.sql b/app/verticals/inventory/drizzle/20260925095228_allow-committed-protection-health-revisions/migration.sql new file mode 100644 index 000000000..9edd6cdcf --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925095228_allow-committed-protection-health-revisions/migration.sql @@ -0,0 +1,162 @@ +-- Health-only protection revisions must still prove the exact immutable owner lineage. +CREATE OR REPLACE FUNCTION "inventory"."enforce_commitment_protection_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + authority "inventory"."backend_configurations"%ROWTYPE; + confirmation "inventory"."reservation_confirmations"%ROWTYPE; + candidate_confirmation jsonb := NEW.snapshot -> 'confirmation'; + expected_allocations jsonb; + actual_allocations jsonb; +BEGIN + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (NEW.snapshot #>> '{ref,resourceId}')::uuid IS DISTINCT FROM NEW.protection_id + OR NEW.snapshot #>> '{ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (NEW.snapshot #>> '{confirmation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.confirmation_id + OR NEW.snapshot #>> '{confirmation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (NEW.snapshot #>> '{confirmation,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR NEW.snapshot #>> '{confirmation,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (NEW.snapshot #>> '{confirmation,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.owner_configuration_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.snapshot #>> '{authorityEvidence,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.snapshot #>> '{authorityEvidence,effectId}' IS DISTINCT FROM NEW.authority_effect_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validFrom}')::timestamptz IS DISTINCT FROM NEW.established_at + OR (NEW.snapshot ->> 'establishedAt')::timestamptz IS DISTINCT FROM NEW.established_at + OR NEW.snapshot #>> '{health,state}' IS DISTINCT FROM NEW.current_health_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz IS DISTINCT FROM NEW.updated_at + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection snapshot must exactly match its relational identity and current health'; + END IF; + + SELECT selected.* INTO authority + FROM "inventory"."backend_configurations" AS selected + WHERE selected.tenant_id = NEW.tenant_id + AND selected.configuration_id = NEW.owner_configuration_id + AND selected.customer_configuration_id = NEW.snapshot #>> '{confirmation,reservation,authority,customerConfigurationId}' + AND selected.backend_kind = NEW.issuer_backend_kind + AND selected.backend_id = NEW.issuer_backend_id + FOR KEY SHARE; + IF NOT FOUND + OR NEW.snapshot #>> '{authorityEvidence,issuer,origin}' IS DISTINCT FROM (CASE NEW.issuer_backend_kind + WHEN 'external_business_system' THEN 'EXTERNAL_BUSINESS_SYSTEM' + WHEN 'ontos_wms' THEN 'ONTOS_WMS' + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_authority_ck', + MESSAGE = 'Commitment Protection must preserve the exact selected backend authority'; + END IF; + + SELECT current_confirmation.* INTO confirmation + FROM "inventory"."reservation_confirmations" AS current_confirmation + WHERE current_confirmation.tenant_id = NEW.tenant_id + AND current_confirmation.confirmation_id = NEW.confirmation_id + AND current_confirmation.reservation_id = NEW.reservation_id + AND current_confirmation.attempt_id = NEW.attempt_id + AND current_confirmation.owner_configuration_id = NEW.owner_configuration_id + AND current_confirmation.issuer_backend_kind = NEW.issuer_backend_kind + AND current_confirmation.issuer_backend_id = NEW.issuer_backend_id + FOR KEY SHARE; + IF NOT FOUND + OR NEW.established_at >= confirmation.expires_at + OR NOT EXISTS ( + SELECT 1 FROM "inventory"."reservation_confirmation_history" AS confirmation_history + WHERE confirmation_history.tenant_id = NEW.tenant_id + AND confirmation_history.confirmation_id = NEW.confirmation_id + AND confirmation_history.snapshot = candidate_confirmation + ) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_confirmation_ck', + MESSAGE = 'Commitment Protection must reference exact retained Confirmation proof established before exclusive expiry'; + END IF; + + PERFORM 1 FROM "inventory"."obligations" AS reservation + WHERE reservation.tenant_id = NEW.tenant_id + AND reservation.obligation_id = NEW.reservation_id + AND reservation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND reservation.attempt_id = NEW.attempt_id + AND reservation.owner_configuration_id = NEW.owner_configuration_id + AND ( + ( + TG_OP = 'INSERT' + AND reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + ) + OR ( + TG_OP = 'UPDATE' + AND ( + ( + reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + ) + OR ( + reservation.lifecycle_meaning = 'COMMITTED_OBLIGATION' + AND reservation.accepted_order_id IS NOT NULL + AND reservation.order_evidence_ref IS NOT NULL + AND reservation.order_evidence_observed_at IS NOT NULL + ) + ) + ) + ) + FOR KEY SHARE; + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_reservation_ck', + MESSAGE = 'Commitment Protection must reference its exact immutable Reservation and Attempt lineage'; + END IF; + + IF TG_OP = 'UPDATE' AND ( + NEW.protection_id IS DISTINCT FROM OLD.protection_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.confirmation_id IS DISTINCT FROM OLD.confirmation_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.issuer_backend_kind IS DISTINCT FROM OLD.issuer_backend_kind + OR NEW.issuer_backend_id IS DISTINCT FROM OLD.issuer_backend_id + OR NEW.authority_effect_id IS DISTINCT FROM OLD.authority_effect_id + OR NEW.owner_evidence_ref IS DISTINCT FROM OLD.owner_evidence_ref + OR NEW.established_at IS DISTINCT FROM OLD.established_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR (NEW.snapshot - 'health' - 'revision') IS DISTINCT FROM (OLD.snapshot - 'health' - 'revision') + ) THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection health revisions must preserve exact immutable relational and embedded evidence'; + END IF; + + IF TG_OP = 'UPDATE' THEN + RETURN NEW; + END IF; + + SELECT pg_catalog.jsonb_agg(allocation.entry ORDER BY allocation.entry ->> 'allocationId') + INTO expected_allocations + FROM pg_catalog.jsonb_array_elements(candidate_confirmation #> '{reservation,requirements}') AS requirement(entry), + LATERAL pg_catalog.jsonb_array_elements(requirement.entry -> 'allocations') AS allocation(entry); + SELECT pg_catalog.jsonb_agg(allocation.entry ORDER BY allocation.entry ->> 'allocationId') + INTO actual_allocations + FROM pg_catalog.jsonb_array_elements(NEW.snapshot #> '{authorityEvidence,evidence,allocations}') AS allocation(entry); + IF NEW.current_health_state IS DISTINCT FROM 'PROTECTED' + OR NEW.current_revision IS DISTINCT FROM 1 + OR NEW.snapshot #>> '{authorityEvidence,kind}' IS DISTINCT FROM 'AUTHORITATIVE_RESERVATION_EVIDENCE' + OR NEW.snapshot #>> '{authorityEvidence,operation}' IS DISTINCT FROM 'COMMITMENT_PROTECTION' + OR NEW.snapshot #>> '{authorityEvidence,evidence,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,reservationId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,customerConfigurationId}' IS DISTINCT FROM authority.customer_configuration_id + OR NEW.snapshot #>> '{health,observation,_tag}' IS DISTINCT FROM 'ESTABLISHED' + OR NEW.snapshot #>> '{health,observation,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{health,reconciliationRequired}')::boolean IS DISTINCT FROM false + OR expected_allocations IS DISTINCT FROM actual_allocations + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection establishment must preserve exact authority allocation, quantity, Unit, Item, Position, and evidence scope'; + END IF; + RETURN NEW; +END; +$$; diff --git a/app/verticals/inventory/drizzle/20260925095228_allow-committed-protection-health-revisions/snapshot.json b/app/verticals/inventory/drizzle/20260925095228_allow-committed-protection-health-revisions/snapshot.json new file mode 100644 index 000000000..8200e9931 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260925095228_allow-committed-protection-health-revisions/snapshot.json @@ -0,0 +1,13575 @@ +{ + "id": "e6af53c4-637c-4990-8918-8a603b96195b", + "prevIds": [ + "39acf525-669d-45ac-825f-76627d4048b7" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260928120000_finalize-commitment-protection-worker/migration.sql b/app/verticals/inventory/drizzle/20260928120000_finalize-commitment-protection-worker/migration.sql new file mode 100644 index 000000000..0af21b795 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260928120000_finalize-commitment-protection-worker/migration.sql @@ -0,0 +1,522 @@ +CREATE OR REPLACE FUNCTION "inventory"."enforce_commitment_protection_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + authority "inventory"."backend_configurations"%ROWTYPE; + confirmation "inventory"."reservation_confirmations"%ROWTYPE; + candidate_confirmation jsonb := NEW.snapshot -> 'confirmation'; + expected_allocations jsonb; + actual_allocations jsonb; +BEGIN + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (NEW.snapshot #>> '{ref,resourceId}')::uuid IS DISTINCT FROM NEW.protection_id + OR NEW.snapshot #>> '{ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (NEW.snapshot #>> '{confirmation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.confirmation_id + OR NEW.snapshot #>> '{confirmation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (NEW.snapshot #>> '{confirmation,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR NEW.snapshot #>> '{confirmation,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (NEW.snapshot #>> '{confirmation,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.owner_configuration_id + OR NEW.snapshot #>> '{authorityEvidence,issuer,backend}' IS DISTINCT FROM NEW.issuer_backend_kind + OR NEW.snapshot #>> '{authorityEvidence,issuer,backendId}' IS DISTINCT FROM NEW.issuer_backend_id + OR NEW.snapshot #>> '{authorityEvidence,effectId}' IS DISTINCT FROM NEW.authority_effect_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{authorityEvidence,evidence,validFrom}')::timestamptz IS DISTINCT FROM NEW.established_at + OR (NEW.snapshot ->> 'establishedAt')::timestamptz IS DISTINCT FROM NEW.established_at + OR NEW.snapshot #>> '{health,state}' IS DISTINCT FROM NEW.current_health_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot #>> '{health,observation,effectiveAt}')::timestamptz IS DISTINCT FROM NEW.updated_at + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection snapshot must exactly match its relational identity and current health'; + END IF; + + SELECT selected.* INTO authority + FROM "inventory"."backend_configurations" AS selected + WHERE selected.tenant_id = NEW.tenant_id + AND selected.configuration_id = NEW.owner_configuration_id + AND selected.customer_configuration_id = NEW.snapshot #>> '{confirmation,reservation,authority,customerConfigurationId}' + AND selected.backend_kind = NEW.issuer_backend_kind + AND selected.backend_id = NEW.issuer_backend_id + FOR KEY SHARE; + IF NOT FOUND + OR NEW.snapshot #>> '{authorityEvidence,issuer,origin}' IS DISTINCT FROM (CASE NEW.issuer_backend_kind + WHEN 'external_business_system' THEN 'EXTERNAL_BUSINESS_SYSTEM' + WHEN 'ontos_wms' THEN 'ONTOS_WMS' + END) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_authority_ck', + MESSAGE = 'Commitment Protection must preserve the exact selected backend authority'; + END IF; + + SELECT current_confirmation.* INTO confirmation + FROM "inventory"."reservation_confirmations" AS current_confirmation + WHERE current_confirmation.tenant_id = NEW.tenant_id + AND current_confirmation.confirmation_id = NEW.confirmation_id + AND current_confirmation.reservation_id = NEW.reservation_id + AND current_confirmation.attempt_id = NEW.attempt_id + AND current_confirmation.owner_configuration_id = NEW.owner_configuration_id + AND current_confirmation.issuer_backend_kind = NEW.issuer_backend_kind + AND current_confirmation.issuer_backend_id = NEW.issuer_backend_id + FOR KEY SHARE; + IF NOT FOUND + OR NEW.established_at >= confirmation.expires_at + OR NOT EXISTS ( + SELECT 1 FROM "inventory"."reservation_confirmation_history" AS confirmation_history + WHERE confirmation_history.tenant_id = NEW.tenant_id + AND confirmation_history.confirmation_id = NEW.confirmation_id + AND confirmation_history.snapshot = candidate_confirmation + ) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_confirmation_ck', + MESSAGE = 'Commitment Protection must reference exact retained Confirmation proof established before exclusive expiry'; + END IF; + + PERFORM 1 FROM "inventory"."obligations" AS reservation + WHERE reservation.tenant_id = NEW.tenant_id + AND reservation.obligation_id = NEW.reservation_id + AND reservation.origin_kind = 'ORDER_COMMITMENT_ATTEMPT' + AND reservation.attempt_id = NEW.attempt_id + AND reservation.owner_configuration_id = NEW.owner_configuration_id + AND ( + ( + TG_OP = 'INSERT' + AND reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + ) + OR ( + TG_OP = 'UPDATE' + AND ( + ( + reservation.lifecycle_meaning = 'PROVISIONAL_RESERVATION' + AND reservation.accepted_order_id IS NULL + AND reservation.order_evidence_ref IS NULL + AND reservation.order_evidence_observed_at IS NULL + ) + OR ( + reservation.lifecycle_meaning = 'COMMITTED_OBLIGATION' + AND reservation.accepted_order_id IS NOT NULL + AND reservation.order_evidence_ref IS NOT NULL + AND reservation.order_evidence_observed_at IS NOT NULL + ) + ) + ) + ) + FOR KEY SHARE; + IF NOT FOUND THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_exact_reservation_ck', + MESSAGE = 'Commitment Protection must reference its exact immutable Reservation and Attempt lineage'; + END IF; + + IF TG_OP = 'UPDATE' AND ( + NEW.protection_id IS DISTINCT FROM OLD.protection_id + OR NEW.tenant_id IS DISTINCT FROM OLD.tenant_id + OR NEW.confirmation_id IS DISTINCT FROM OLD.confirmation_id + OR NEW.reservation_id IS DISTINCT FROM OLD.reservation_id + OR NEW.attempt_id IS DISTINCT FROM OLD.attempt_id + OR NEW.owner_configuration_id IS DISTINCT FROM OLD.owner_configuration_id + OR NEW.issuer_backend_kind IS DISTINCT FROM OLD.issuer_backend_kind + OR NEW.issuer_backend_id IS DISTINCT FROM OLD.issuer_backend_id + OR NEW.authority_effect_id IS DISTINCT FROM OLD.authority_effect_id + OR NEW.owner_evidence_ref IS DISTINCT FROM OLD.owner_evidence_ref + OR NEW.established_at IS DISTINCT FROM OLD.established_at + OR NEW.created_at IS DISTINCT FROM OLD.created_at + OR (NEW.snapshot - 'health' - 'revision') IS DISTINCT FROM (OLD.snapshot - 'health' - 'revision') + ) THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection health revisions must preserve exact immutable relational and embedded evidence'; + END IF; + + IF TG_OP = 'UPDATE' THEN + RETURN NEW; + END IF; + + SELECT pg_catalog.jsonb_agg( + pg_catalog.jsonb_build_object( + 'allocationId', allocation.entry -> 'allocationId', + 'quantity', allocation.entry -> 'quantity', + 'stockItemRef', allocation.entry -> 'stockItemRef', + 'stockPositionRef', allocation.entry -> 'positionRef' + ) + ORDER BY allocation.entry ->> 'allocationId' + ) + INTO expected_allocations + FROM pg_catalog.jsonb_array_elements(candidate_confirmation #> '{reservation,requirements}') AS requirement(entry), + LATERAL pg_catalog.jsonb_array_elements(requirement.entry -> 'allocations') AS allocation(entry); + SELECT pg_catalog.jsonb_agg(allocation.entry ORDER BY allocation.entry ->> 'allocationId') + INTO actual_allocations + FROM pg_catalog.jsonb_array_elements(NEW.snapshot #> '{authorityEvidence,evidence,allocations}') AS allocation(entry); + IF NEW.current_health_state IS DISTINCT FROM 'PROTECTED' + OR NEW.current_revision IS DISTINCT FROM 1 + OR NEW.snapshot #>> '{authorityEvidence,kind}' IS DISTINCT FROM 'AUTHORITATIVE_RESERVATION_EVIDENCE' + OR NEW.snapshot #>> '{authorityEvidence,operation}' IS DISTINCT FROM 'COMMITMENT_PROTECTION' + OR NEW.snapshot #>> '{authorityEvidence,evidence,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,reservationId}' IS DISTINCT FROM NEW.reservation_id::text + OR NEW.snapshot #>> '{authorityEvidence,evidence,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR NEW.snapshot #>> '{authorityEvidence,evidence,customerConfigurationId}' IS DISTINCT FROM authority.customer_configuration_id + OR NEW.snapshot #>> '{health,observation,_tag}' IS DISTINCT FROM 'ESTABLISHED' + OR NEW.snapshot #>> '{health,observation,ownerEvidenceRef}' IS DISTINCT FROM NEW.owner_evidence_ref + OR (NEW.snapshot #>> '{health,reconciliationRequired}')::boolean IS DISTINCT FROM false + OR expected_allocations IS DISTINCT FROM actual_allocations + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_commitment_protections_snapshot_ck', + MESSAGE = 'Commitment Protection establishment must preserve exact authority allocation, quantity, Unit, Item, Position, and evidence scope'; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_commitment_protection_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() RETURNS trigger +LANGUAGE plpgsql +SET search_path = pg_catalog, inventory +AS $$ +DECLARE + intent jsonb := NEW.intent_json; + intent_kind text := NEW.intent_json ->> '_tag'; + parsed_canonical jsonb; + resolution_business_request jsonb; + resolution_identity text; +BEGIN + BEGIN + parsed_canonical := NEW.intent_canonical::jsonb; + EXCEPTION WHEN OTHERS THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect intent canonical fingerprint must be valid JSON'; + END; + IF pg_catalog.jsonb_typeof(NEW.snapshot) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(NEW.snapshot)) <> 8 + OR pg_catalog.jsonb_typeof(intent) IS DISTINCT FROM 'object' + OR (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent)) <> 2 + OR pg_catalog.jsonb_typeof(intent -> 'request') IS DISTINCT FROM 'object' + OR NEW.snapshot ->> 'tenantId' IS DISTINCT FROM NEW.tenant_id::text + OR NEW.snapshot ->> 'effectId' IS DISTINCT FROM NEW.effect_id + OR NEW.snapshot ->> 'currentState' IS DISTINCT FROM NEW.current_state + OR (NEW.snapshot ->> 'revision')::integer IS DISTINCT FROM NEW.current_revision + OR (NEW.snapshot ->> 'requestedAt')::timestamptz IS DISTINCT FROM NEW.requested_at + OR (NEW.snapshot ->> 'updatedAt')::timestamptz IS DISTINCT FROM NEW.updated_at + OR NEW.updated_at < NEW.requested_at + OR NEW.snapshot -> 'intent' IS DISTINCT FROM intent + OR NEW.snapshot -> 'resolution' IS DISTINCT FROM coalesce(NEW.resolution_json, 'null'::jsonb) + OR intent IS DISTINCT FROM parsed_canonical + OR intent_kind IS DISTINCT FROM NEW.effect_kind + OR (NEW.current_state = 'REQUESTED' AND (NEW.current_revision <> 1 OR NEW.resolution_json IS NOT NULL)) + OR (NEW.current_state IN ('SUCCEEDED', 'REJECTED') AND NEW.resolution_json IS NULL) + THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect ledger relational state must exactly match its canonical snapshot'; + END IF; + + IF NEW.effect_kind = 'RESERVATION_CREATE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 5 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,authority,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + ELSIF NEW.effect_kind = 'RESERVATION_RELEASE' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 3 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,reservation,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,reservation,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,reservation,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + ELSIF NEW.effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 7 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,confirmation,ref,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR intent #>> '{request,protectionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,confirmation,reservation,authority,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,confirmation,reservation,ref,resourceId}')::uuid IS DISTINCT FROM NEW.reservation_id + OR intent #>> '{request,confirmation,reservation,origin,attemptId}' IS DISTINCT FROM NEW.attempt_id + OR (intent #>> '{request,confirmation,reservation,authority,configurationId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,confirmation,reservation,authority,selection,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,confirmation,reservation,authority,selection,backendId}' IS DISTINCT FROM NEW.authority_backend_id THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Commitment Protection ledger scope does not match its canonical business intent'; + END IF; + ELSIF NEW.effect_kind IN ('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE') THEN + IF (SELECT pg_catalog.count(*) FROM pg_catalog.jsonb_object_keys(intent -> 'request')) <> 12 + OR intent #>> '{request,effectId}' IS DISTINCT FROM NEW.effect_id + OR intent #>> '{request,positionRef,tenantId}' IS DISTINCT FROM NEW.tenant_id::text + OR (intent #>> '{request,legalEntityId}')::uuid IS DISTINCT FROM NEW.legal_entity_id + OR intent #>> '{request,customerConfigurationId}' IS DISTINCT FROM NEW.customer_configuration_id + OR (intent #>> '{request,backendConfigurationRef,resourceId}')::uuid IS DISTINCT FROM NEW.authority_configuration_id + OR intent #>> '{request,backend}' IS DISTINCT FROM NEW.authority_backend_kind + OR intent #>> '{request,backendId}' IS DISTINCT FROM NEW.authority_backend_id + OR NEW.reservation_id IS NOT NULL OR NEW.attempt_id IS NOT NULL THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + ELSE + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; + END IF; + + PERFORM 1 FROM "inventory"."backend_configurations" AS authority + WHERE authority.tenant_id = NEW.tenant_id + AND authority.configuration_id = NEW.authority_configuration_id + AND authority.customer_configuration_id = NEW.customer_configuration_id + AND authority.backend_kind = NEW.authority_backend_kind + AND authority.backend_id = NEW.authority_backend_id + FOR KEY SHARE; + IF NOT FOUND THEN RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck'; END IF; + + IF NEW.resolution_json IS NOT NULL THEN + resolution_identity := NEW.resolution_json #>> '{effect,request,effectId}'; + resolution_business_request := CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN (NEW.resolution_json #> '{effect,request}') - 'mutationId' - 'requestedAt' - 'sourceActionInvocationId' + WHEN 'RESERVATION_RELEASE' THEN (NEW.resolution_json #> '{effect,request}') - 'mutationId' - 'requestedAt' - 'sourceActionInvocationId' + WHEN 'ESTABLISH_COMMITMENT_PROTECTION' THEN NEW.resolution_json #> '{effect,request}' + WHEN 'PHYSICAL_RECEIPT' THEN (NEW.resolution_json #> '{effect,request}') - 'actionInvocationId' - 'requestedAt' + WHEN 'PHYSICAL_ISSUE' THEN (NEW.resolution_json #> '{effect,request}') - 'actionInvocationId' - 'requestedAt' + END; + IF NEW.resolution_json ->> '_tag' IS DISTINCT FROM NEW.effect_kind + OR resolution_identity IS DISTINCT FROM NEW.effect_id + OR resolution_business_request IS DISTINCT FROM intent -> 'request' + OR ( + NEW.effect_kind = 'ESTABLISH_COMMITMENT_PROTECTION' + AND NEW.resolution_json #>> '{effect,_tag}' = 'PROTECTED' + AND ( + NEW.resolution_json #> '{effect,protection,ref}' IS DISTINCT FROM intent #> '{request,protectionRef}' + OR NEW.resolution_json #> '{effect,protection,confirmation}' IS DISTINCT FROM intent #> '{request,confirmation}' + OR NEW.resolution_json #>> '{effect,protection,authorityEvidence,effectId}' IS DISTINCT FROM NEW.effect_id + OR NEW.resolution_json #>> '{effect,protection,authorityEvidence,operation}' IS DISTINCT FROM 'COMMITMENT_PROTECTION' + ) + ) + OR NEW.current_state IS DISTINCT FROM (CASE NEW.effect_kind + WHEN 'RESERVATION_CREATE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'RECONCILIATION_REQUIRED' THEN 'INDETERMINATE' WHEN 'ESTABLISHED' THEN 'SUCCEEDED' WHEN 'RESOLVED_NO_RESERVATION' THEN 'REJECTED' END + WHEN 'RESERVATION_RELEASE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'RELEASED' THEN 'SUCCEEDED' WHEN 'NOT_RELEASABLE' THEN 'REJECTED' END + WHEN 'ESTABLISH_COMMITMENT_PROTECTION' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'PROTECTED' THEN 'SUCCEEDED' WHEN 'NOT_PROTECTABLE' THEN 'REJECTED' END + WHEN 'PHYSICAL_RECEIPT' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'APPLIED' THEN 'SUCCEEDED' WHEN 'REJECTED' THEN 'REJECTED' END + WHEN 'PHYSICAL_ISSUE' THEN CASE NEW.resolution_json #>> '{effect,_tag}' WHEN 'INDETERMINATE' THEN 'INDETERMINATE' WHEN 'APPLIED' THEN 'SUCCEEDED' WHEN 'REJECTED' THEN 'REJECTED' END + END) THEN + RAISE EXCEPTION USING ERRCODE = '23514', CONSTRAINT = 'inventory_effect_ledger_exact_scope_ck', + MESSAGE = 'Inventory effect resolution must preserve exact business intent, kind, identity, and terminal meaning'; + END IF; + END IF; + RETURN NEW; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."enforce_effect_ledger_exact_scope"() FROM PUBLIC, "ontos_runtime"; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."finalize_commitment_protection_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_effect_id text, + p_expected_revision integer, + p_expected_state text, + p_effect jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + v_current "inventory"."effect_ledger"%ROWTYPE; + v_existing "inventory"."commitment_protections"%ROWTYPE; + v_next jsonb; + v_next_state text; + v_protection jsonb := p_effect -> 'protection'; + v_resolution jsonb; + v_tag text := p_effect ->> '_tag'; + v_updated_at timestamptz := pg_catalog.clock_timestamp(); +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Commitment Protection worker scope mismatch'; + END IF; + + SELECT effect.* + INTO v_current + FROM "inventory"."effect_ledger" AS effect + WHERE effect.tenant_id = p_tenant_id + AND effect.legal_entity_id = p_legal_entity_id + AND effect.effect_id = p_effect_id + FOR UPDATE; + + IF NOT FOUND THEN + RETURN; + END IF; + + v_resolution := pg_catalog.jsonb_build_object('_tag', 'ESTABLISH_COMMITMENT_PROTECTION', 'effect', p_effect); + v_next_state := CASE v_tag WHEN 'PROTECTED' THEN 'SUCCEEDED' WHEN 'NOT_PROTECTABLE' THEN 'REJECTED' END; + + IF v_current.effect_kind IS DISTINCT FROM 'ESTABLISH_COMMITMENT_PROTECTION' + OR v_tag IS NULL + OR v_next_state IS NULL + OR p_effect -> 'request' IS DISTINCT FROM v_current.intent_json -> 'request' + OR p_effect #>> '{request,effectId}' IS DISTINCT FROM p_effect_id + OR p_effect #>> '{request,legalEntityId}' IS DISTINCT FROM p_legal_entity_id::text + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_commitment_protection_worker_finalization_ck', + MESSAGE = 'Commitment Protection finalization must preserve the exact durable request'; + END IF; + + IF v_current.current_state IN ('SUCCEEDED', 'REJECTED') THEN + IF v_current.resolution_json IS DISTINCT FROM v_resolution THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_commitment_protection_worker_finalization_ck', + MESSAGE = 'Terminal Commitment Protection evidence cannot be replaced'; + END IF; + RETURN QUERY SELECT v_current.snapshot; + RETURN; + END IF; + + IF v_current.current_revision IS DISTINCT FROM p_expected_revision + OR v_current.current_state IS DISTINCT FROM p_expected_state + OR p_expected_state NOT IN ('REQUESTED', 'INDETERMINATE') + THEN + RETURN; + END IF; + + IF v_tag = 'PROTECTED' THEN + INSERT INTO "inventory"."commitment_protections" ( + protection_id, + tenant_id, + confirmation_id, + reservation_id, + attempt_id, + owner_configuration_id, + issuer_backend_kind, + issuer_backend_id, + authority_effect_id, + owner_evidence_ref, + established_at, + current_health_state, + current_revision, + snapshot, + updated_at + ) VALUES ( + (v_protection #>> '{ref,resourceId}')::uuid, + p_tenant_id, + (v_protection #>> '{confirmation,ref,resourceId}')::uuid, + (v_protection #>> '{confirmation,reservation,ref,resourceId}')::uuid, + v_protection #>> '{confirmation,reservation,origin,attemptId}', + (v_protection #>> '{confirmation,reservation,authority,configurationId}')::uuid, + v_protection #>> '{authorityEvidence,issuer,backend}', + v_protection #>> '{authorityEvidence,issuer,backendId}', + v_protection #>> '{authorityEvidence,effectId}', + v_protection #>> '{authorityEvidence,evidence,ownerEvidenceRef}', + (v_protection ->> 'establishedAt')::timestamptz, + v_protection #>> '{health,state}', + (v_protection ->> 'revision')::integer, + v_protection, + (v_protection #>> '{health,observation,effectiveAt}')::timestamptz + ) + ON CONFLICT DO NOTHING; + + SELECT protection.* + INTO v_existing + FROM "inventory"."commitment_protections" AS protection + WHERE protection.tenant_id = p_tenant_id + AND ( + protection.protection_id = (v_protection #>> '{ref,resourceId}')::uuid + OR protection.authority_effect_id = p_effect_id + OR ( + protection.reservation_id = (v_protection #>> '{confirmation,reservation,ref,resourceId}')::uuid + AND protection.attempt_id = v_protection #>> '{confirmation,reservation,origin,attemptId}' + ) + ) + ORDER BY protection.protection_id + LIMIT 1 + FOR UPDATE; + + IF NOT FOUND OR v_existing.snapshot IS DISTINCT FROM v_protection THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_commitment_protection_worker_finalization_ck', + MESSAGE = 'Commitment Protection identity is already bound to different evidence'; + END IF; + + INSERT INTO "inventory"."commitment_protection_history" ( + tenant_id, protection_id, revision, health_state, snapshot, transitioned_at + ) VALUES ( + p_tenant_id, + v_existing.protection_id, + v_existing.current_revision, + v_existing.current_health_state, + v_existing.snapshot, + v_existing.updated_at + ) + ON CONFLICT (tenant_id, protection_id, revision) DO NOTHING; + + IF NOT EXISTS ( + SELECT 1 + FROM "inventory"."commitment_protection_history" AS history + WHERE history.tenant_id = p_tenant_id + AND history.protection_id = v_existing.protection_id + AND history.revision = v_existing.current_revision + AND history.snapshot = v_existing.snapshot + ) THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_commitment_protection_worker_finalization_ck', + MESSAGE = 'Commitment Protection history conflicts with terminal evidence'; + END IF; + END IF; + + v_next := pg_catalog.jsonb_build_object( + 'tenantId', p_tenant_id::text, + 'effectId', p_effect_id, + 'intent', v_current.intent_json, + 'currentState', v_next_state, + 'revision', p_expected_revision + 1, + 'requestedAt', v_current.snapshot ->> 'requestedAt', + 'updatedAt', pg_catalog.to_char(v_updated_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"'), + 'resolution', v_resolution + ); + + UPDATE "inventory"."effect_ledger" + SET current_state = v_next_state, + current_revision = p_expected_revision + 1, + resolution_json = v_resolution, + snapshot = v_next, + updated_at = v_updated_at + WHERE tenant_id = p_tenant_id + AND legal_entity_id = p_legal_entity_id + AND effect_id = p_effect_id + AND current_revision = p_expected_revision + AND current_state = p_expected_state + RETURNING * INTO v_current; + + IF NOT FOUND THEN + RETURN; + END IF; + + INSERT INTO "inventory"."effect_ledger_history" ( + tenant_id, effect_id, revision, state, snapshot, transitioned_at + ) VALUES ( + v_current.tenant_id, + v_current.effect_id, + v_current.current_revision, + v_current.current_state, + v_current.snapshot, + v_current.updated_at + ); + + RETURN QUERY SELECT v_current.snapshot; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."finalize_commitment_protection_for_worker"(uuid, uuid, text, integer, text, jsonb) FROM PUBLIC; +--> statement-breakpoint +GRANT EXECUTE ON FUNCTION "inventory"."finalize_commitment_protection_for_worker"(uuid, uuid, text, integer, text, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260928120000_finalize-commitment-protection-worker/snapshot.json b/app/verticals/inventory/drizzle/20260928120000_finalize-commitment-protection-worker/snapshot.json new file mode 100644 index 000000000..8200e9931 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260928120000_finalize-commitment-protection-worker/snapshot.json @@ -0,0 +1,13575 @@ +{ + "id": "e6af53c4-637c-4990-8918-8a603b96195b", + "prevIds": [ + "39acf525-669d-45ac-825f-76627d4048b7" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/drizzle/20260928120100_reservation-confirmation-worker-routines/migration.sql b/app/verticals/inventory/drizzle/20260928120100_reservation-confirmation-worker-routines/migration.sql new file mode 100644 index 000000000..da0bfd489 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260928120100_reservation-confirmation-worker-routines/migration.sql @@ -0,0 +1,376 @@ +CREATE OR REPLACE FUNCTION "inventory"."find_reservation_confirmation_by_ref_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_confirmation_id uuid +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Confirmation worker scope mismatch'; + END IF; + + RETURN QUERY + SELECT confirmation.snapshot + FROM "inventory"."reservation_confirmations" AS confirmation + INNER JOIN "inventory"."reservation_create_effects" AS create_effect + ON create_effect.tenant_id = confirmation.tenant_id + AND create_effect.reservation_id = confirmation.reservation_id + AND create_effect.attempt_id = confirmation.attempt_id + AND create_effect.state = 'ESTABLISHED' + WHERE confirmation.tenant_id = p_tenant_id + AND confirmation.confirmation_id = p_confirmation_id + AND create_effect.legal_entity_id = p_legal_entity_id; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."find_reservation_confirmation_by_attempt_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_reservation_id uuid, + p_attempt_id text +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Confirmation worker scope mismatch'; + END IF; + + RETURN QUERY + SELECT confirmation.snapshot + FROM "inventory"."reservation_confirmations" AS confirmation + INNER JOIN "inventory"."reservation_create_effects" AS create_effect + ON create_effect.tenant_id = confirmation.tenant_id + AND create_effect.reservation_id = confirmation.reservation_id + AND create_effect.attempt_id = confirmation.attempt_id + AND create_effect.state = 'ESTABLISHED' + WHERE confirmation.tenant_id = p_tenant_id + AND confirmation.reservation_id = p_reservation_id + AND confirmation.attempt_id = p_attempt_id + AND create_effect.legal_entity_id = p_legal_entity_id; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."create_or_read_reservation_confirmation_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_candidate jsonb +) RETURNS TABLE(record jsonb, outcome text) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + current_binding "inventory"."catalog_to_stock_bindings"%ROWTYPE; + current_effect "inventory"."reservation_create_effects"%ROWTYPE; + requirement jsonb; + stored_record jsonb; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + OR p_candidate #>> '{ref,tenantId}' IS DISTINCT FROM p_tenant_id::text + OR p_candidate #>> '{reservation,ref,tenantId}' IS DISTINCT FROM p_tenant_id::text + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Confirmation worker scope mismatch'; + END IF; + + SELECT create_effect.* + INTO current_effect + FROM "inventory"."reservation_create_effects" AS create_effect + WHERE create_effect.tenant_id = p_tenant_id + AND create_effect.legal_entity_id = p_legal_entity_id + AND create_effect.reservation_id = (p_candidate #>> '{reservation,ref,resourceId}')::uuid + AND create_effect.attempt_id = p_candidate #>> '{reservation,origin,attemptId}' + AND create_effect.state = 'ESTABLISHED' + FOR UPDATE; + + IF NOT FOUND OR current_effect.record_json -> 'reservation' IS DISTINCT FROM p_candidate -> 'reservation' THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_exact_reservation_ck', + MESSAGE = 'Reservation Confirmation worker input must match one established Reservation create effect'; + END IF; + + SELECT confirmation.snapshot + INTO stored_record + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = p_tenant_id + AND ( + confirmation.confirmation_id = (p_candidate #>> '{ref,resourceId}')::uuid + OR ( + confirmation.reservation_id = (p_candidate #>> '{reservation,ref,resourceId}')::uuid + AND confirmation.attempt_id = p_candidate #>> '{reservation,origin,attemptId}' + ) + OR confirmation.authority_effect_id = p_candidate #>> '{authorityEvidence,effectId}' + ) + LIMIT 1 + FOR UPDATE; + + IF FOUND THEN + IF ((stored_record - 'health') - 'revision') + IS DISTINCT FROM ((p_candidate - 'health') - 'revision') + THEN + IF stored_record #>> '{ref,resourceId}' + IS DISTINCT FROM p_candidate #>> '{ref,resourceId}' + AND stored_record #>> '{reservation,ref,resourceId}' + IS NOT DISTINCT FROM p_candidate #>> '{reservation,ref,resourceId}' + AND stored_record #>> '{reservation,origin,attemptId}' + IS NOT DISTINCT FROM p_candidate #>> '{reservation,origin,attemptId}' + THEN + RAISE EXCEPTION USING + ERRCODE = '23505', + CONSTRAINT = 'inventory_reservation_confirmations_reservation_attempt_uk', + MESSAGE = 'Reservation Confirmation Attempt already has a different Confirmation'; + END IF; + + RAISE EXCEPTION USING + ERRCODE = '23505', + CONSTRAINT = 'inventory_reservation_confirmations_scope_id_uk', + MESSAGE = 'Reservation Confirmation identity already belongs to different proof'; + END IF; + + RETURN QUERY SELECT stored_record, 'EXISTING'::text; + RETURN; + END IF; + + FOR requirement IN + SELECT expected.entry + FROM pg_catalog.jsonb_array_elements(p_candidate #> '{reservation,requirements}') AS expected(entry) + ORDER BY expected.entry #>> '{exactSelectionMeaning,kind}', expected.entry #>> '{exactSelectionMeaning,id}' + LOOP + SELECT binding.* + INTO current_binding + FROM "inventory"."catalog_to_stock_bindings" AS binding + WHERE binding.tenant_id = p_tenant_id + AND binding.exact_selection_kind = requirement #>> '{exactSelectionMeaning,kind}' + AND binding.exact_selection_meaning_id = requirement #>> '{exactSelectionMeaning,id}' + FOR UPDATE; + + IF NOT FOUND + OR current_binding.binding_id::text IS DISTINCT FROM requirement #>> '{bindingRef,resourceId}' + OR current_binding.stock_item_id::text IS DISTINCT FROM requirement #>> '{stockItem,stockItemRef,resourceId}' + THEN + RAISE EXCEPTION USING + ERRCODE = '23514', + CONSTRAINT = 'inventory_reservation_confirmations_exact_reservation_ck', + MESSAGE = 'Reservation Confirmation cannot issue against a corrected Catalog-to-Stock Binding'; + END IF; + END LOOP; + + INSERT INTO "inventory"."reservation_confirmations" ( + confirmation_id, + tenant_id, + reservation_id, + attempt_id, + owner_configuration_id, + issuer_backend_kind, + issuer_backend_id, + authority_effect_id, + owner_evidence_ref, + issued_at, + expires_at, + current_health_state, + current_revision, + snapshot, + updated_at + ) VALUES ( + (p_candidate #>> '{ref,resourceId}')::uuid, + p_tenant_id, + (p_candidate #>> '{reservation,ref,resourceId}')::uuid, + p_candidate #>> '{reservation,origin,attemptId}', + (p_candidate #>> '{reservation,authority,configurationId}')::uuid, + p_candidate #>> '{authorityEvidence,issuer,backend}', + p_candidate #>> '{authorityEvidence,issuer,backendId}', + p_candidate #>> '{authorityEvidence,effectId}', + p_candidate #>> '{issuanceRank,ownerEvidenceRef}', + (p_candidate ->> 'issuedAt')::timestamptz, + (p_candidate ->> 'expiresAt')::timestamptz, + p_candidate #>> '{health,state}', + (p_candidate ->> 'revision')::integer, + p_candidate, + (p_candidate #>> '{health,observation,effectiveAt}')::timestamptz + ) + ON CONFLICT DO NOTHING + RETURNING snapshot INTO stored_record; + + IF stored_record IS NOT NULL THEN + INSERT INTO "inventory"."reservation_confirmation_history" ( + tenant_id, + confirmation_id, + revision, + health_state, + snapshot, + transitioned_at + ) VALUES ( + p_tenant_id, + (stored_record #>> '{ref,resourceId}')::uuid, + (stored_record ->> 'revision')::integer, + stored_record #>> '{health,state}', + stored_record, + (stored_record #>> '{health,observation,effectiveAt}')::timestamptz + ); + RETURN QUERY SELECT stored_record, 'INSERTED'::text; + RETURN; + END IF; + + SELECT confirmation.snapshot + INTO stored_record + FROM "inventory"."reservation_confirmations" AS confirmation + WHERE confirmation.tenant_id = p_tenant_id + AND ( + confirmation.confirmation_id = (p_candidate #>> '{ref,resourceId}')::uuid + OR ( + confirmation.reservation_id = (p_candidate #>> '{reservation,ref,resourceId}')::uuid + AND confirmation.attempt_id = p_candidate #>> '{reservation,origin,attemptId}' + ) + OR confirmation.authority_effect_id = p_candidate #>> '{authorityEvidence,effectId}' + ) + LIMIT 1; + + IF stored_record IS NOT NULL THEN + IF ((stored_record - 'health') - 'revision') + IS DISTINCT FROM ((p_candidate - 'health') - 'revision') + THEN + IF stored_record #>> '{ref,resourceId}' + IS DISTINCT FROM p_candidate #>> '{ref,resourceId}' + AND stored_record #>> '{reservation,ref,resourceId}' + IS NOT DISTINCT FROM p_candidate #>> '{reservation,ref,resourceId}' + AND stored_record #>> '{reservation,origin,attemptId}' + IS NOT DISTINCT FROM p_candidate #>> '{reservation,origin,attemptId}' + THEN + RAISE EXCEPTION USING + ERRCODE = '23505', + CONSTRAINT = 'inventory_reservation_confirmations_reservation_attempt_uk', + MESSAGE = 'Reservation Confirmation Attempt already has a different Confirmation'; + END IF; + + RAISE EXCEPTION USING + ERRCODE = '23505', + CONSTRAINT = 'inventory_reservation_confirmations_scope_id_uk', + MESSAGE = 'Reservation Confirmation identity already belongs to different proof'; + END IF; + + RETURN QUERY SELECT stored_record, 'EXISTING'::text; + RETURN; + END IF; + + RAISE EXCEPTION USING + ERRCODE = '40001', + MESSAGE = 'Reservation Confirmation create-or-read could not resolve the concurrent write'; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."read_reservation_confirmation_history_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_confirmation_id uuid +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Confirmation worker scope mismatch'; + END IF; + + RETURN QUERY + SELECT history.snapshot + FROM "inventory"."reservation_confirmation_history" AS history + INNER JOIN "inventory"."reservation_confirmations" AS confirmation + ON confirmation.tenant_id = history.tenant_id + AND confirmation.confirmation_id = history.confirmation_id + INNER JOIN "inventory"."reservation_create_effects" AS create_effect + ON create_effect.tenant_id = confirmation.tenant_id + AND create_effect.reservation_id = confirmation.reservation_id + AND create_effect.attempt_id = confirmation.attempt_id + AND create_effect.state = 'ESTABLISHED' + WHERE history.tenant_id = p_tenant_id + AND history.confirmation_id = p_confirmation_id + AND create_effect.legal_entity_id = p_legal_entity_id + ORDER BY history.revision; +END; +$$; +--> statement-breakpoint +CREATE OR REPLACE FUNCTION "inventory"."save_reservation_confirmation_revision_for_worker"( + p_tenant_id uuid, + p_legal_entity_id uuid, + p_current jsonb, + p_next jsonb +) RETURNS TABLE(record jsonb) +LANGUAGE plpgsql +SECURITY DEFINER +SET search_path = pg_catalog, pg_temp +AS $$ +DECLARE + stored_record jsonb; +BEGIN + IF p_tenant_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.tenant_id', true), '')::uuid + OR p_legal_entity_id IS DISTINCT FROM nullif(pg_catalog.current_setting('ontos.legal_entity_id', true), '')::uuid + OR p_current #>> '{ref,tenantId}' IS DISTINCT FROM p_tenant_id::text + OR p_next #>> '{ref,tenantId}' IS DISTINCT FROM p_tenant_id::text + OR NOT EXISTS ( + SELECT 1 + FROM "inventory"."reservation_create_effects" AS create_effect + WHERE create_effect.tenant_id = p_tenant_id + AND create_effect.legal_entity_id = p_legal_entity_id + AND create_effect.reservation_id = (p_current #>> '{reservation,ref,resourceId}')::uuid + AND create_effect.attempt_id = p_current #>> '{reservation,origin,attemptId}' + AND create_effect.state = 'ESTABLISHED' + ) + THEN + RAISE EXCEPTION USING ERRCODE = '42501', MESSAGE = 'Reservation Confirmation worker scope mismatch'; + END IF; + + UPDATE "inventory"."reservation_confirmations" AS confirmation + SET current_health_state = p_next #>> '{health,state}', + current_revision = (p_next ->> 'revision')::integer, + snapshot = p_next, + updated_at = (p_next #>> '{health,observation,effectiveAt}')::timestamptz + WHERE confirmation.tenant_id = p_tenant_id + AND confirmation.confirmation_id = (p_current #>> '{ref,resourceId}')::uuid + AND confirmation.current_revision = (p_current ->> 'revision')::integer + RETURNING confirmation.snapshot INTO stored_record; + + IF stored_record IS NOT NULL THEN + INSERT INTO "inventory"."reservation_confirmation_history" ( + tenant_id, + confirmation_id, + revision, + health_state, + snapshot, + transitioned_at + ) VALUES ( + p_tenant_id, + (stored_record #>> '{ref,resourceId}')::uuid, + (stored_record ->> 'revision')::integer, + stored_record #>> '{health,state}', + stored_record, + (stored_record #>> '{health,observation,effectiveAt}')::timestamptz + ); + RETURN QUERY SELECT stored_record; + END IF; +END; +$$; +--> statement-breakpoint +REVOKE ALL ON FUNCTION "inventory"."find_reservation_confirmation_by_ref_for_worker"(uuid, uuid, uuid) FROM PUBLIC; +REVOKE ALL ON FUNCTION "inventory"."find_reservation_confirmation_by_attempt_for_worker"(uuid, uuid, uuid, text) FROM PUBLIC; +REVOKE ALL ON FUNCTION "inventory"."create_or_read_reservation_confirmation_for_worker"(uuid, uuid, jsonb) FROM PUBLIC; +REVOKE ALL ON FUNCTION "inventory"."read_reservation_confirmation_history_for_worker"(uuid, uuid, uuid) FROM PUBLIC; +REVOKE ALL ON FUNCTION "inventory"."save_reservation_confirmation_revision_for_worker"(uuid, uuid, jsonb, jsonb) FROM PUBLIC; +GRANT EXECUTE ON FUNCTION "inventory"."find_reservation_confirmation_by_ref_for_worker"(uuid, uuid, uuid) TO "ontos_runtime"; +GRANT EXECUTE ON FUNCTION "inventory"."find_reservation_confirmation_by_attempt_for_worker"(uuid, uuid, uuid, text) TO "ontos_runtime"; +GRANT EXECUTE ON FUNCTION "inventory"."create_or_read_reservation_confirmation_for_worker"(uuid, uuid, jsonb) TO "ontos_runtime"; +GRANT EXECUTE ON FUNCTION "inventory"."read_reservation_confirmation_history_for_worker"(uuid, uuid, uuid) TO "ontos_runtime"; +GRANT EXECUTE ON FUNCTION "inventory"."save_reservation_confirmation_revision_for_worker"(uuid, uuid, jsonb, jsonb) TO "ontos_runtime"; diff --git a/app/verticals/inventory/drizzle/20260928120100_reservation-confirmation-worker-routines/snapshot.json b/app/verticals/inventory/drizzle/20260928120100_reservation-confirmation-worker-routines/snapshot.json new file mode 100644 index 000000000..43b1d6fb5 --- /dev/null +++ b/app/verticals/inventory/drizzle/20260928120100_reservation-confirmation-worker-routines/snapshot.json @@ -0,0 +1,13575 @@ +{ + "id": "cd37098e-7bb6-4dbd-bfa0-4e9db38a4666", + "prevIds": [ + "e6af53c4-637c-4990-8918-8a603b96195b" + ], + "version": "8", + "dialect": "postgres", + "ddl": [ + { + "name": "inventory", + "entityType": "schemas" + }, + { + "isRlsEnabled": true, + "name": "backend_configurations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "binding_correction_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_binding_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "catalog_to_stock_bindings", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protection_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "commitment_protections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "effect_ledger_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "external_stock_correlations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_allocations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligation_requirements", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "obligations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "physical_stock_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmation_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_confirmations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_create_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effect_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_release_effects", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impact_decisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "reservation_shortage_impacts", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertion_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_assertions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_conflict_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "source_import_ledger", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_open_reconciliations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_coverage", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_correction_source_evidence_current", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_corrections", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_items", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_location_revisions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_locations", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_positions", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibilities", + "entityType": "tables", + "schema": "inventory" + }, + { + "isRlsEnabled": true, + "name": "stock_sharing_eligibility_history", + "entityType": "tables", + "schema": "inventory" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "reconciliation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_revision", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "historical_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'POST_COMMIT_BINDING_MISMATCH'", + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'OPEN'", + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "binding_history_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "protection_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'PROTECTED'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "intent_canonical", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolution_json", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "namespace", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_scope", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "identifier_kind", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "external_value", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmed_at", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "allocated_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "purchase_demand_occurrence_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "binding_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "catalog_selection", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_amount", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "origin_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "accepted_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "order_evidence_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_system", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_order_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_obligation_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_exact_reservation_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_selected_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "authority_revision", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_stock_correction_capability", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "established_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "obligations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "kind", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "terminal_reason", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expires_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'VALID'", + "generated": null, + "identity": null, + "name": "current_health_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "request_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "release_effect_record_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "release_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "mutation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reservation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "attempt_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'REQUESTED'", + "generated": null, + "identity": null, + "name": "current_state", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "requested_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "released_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "priority_ordinal", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "affected_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "health_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_before", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "confirmation_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_issued_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "rank_owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_kind", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "change_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "available_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fenced_amount", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "occurred_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "boolean", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciliation_required", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reason", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "decision_count", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_authority", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "location_correlation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_assertions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_type", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "current_truth", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "detected_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "resolved_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "conflict_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "item_index", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "status", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "proposal_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "outcome_json", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "fact_meaning", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "received_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effect_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "relation", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ordering_evidence_value", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "action_invocation_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "principal_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_assertion_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_evidence_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "authority_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evidence_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "issuer_backend_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "source_reference", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "business_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "expected_position_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "position_revision_after", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "corrected_quantity_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "reconciles_correction_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "coverage_evidence_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "evaluated_material_effect_ids_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "record_json", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "applied_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "exact_selection_meaning_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "retired_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_items" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "stock_location_revision_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "display_name", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "scope_kind", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "physical_site_keys", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "address_evidence", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "successor_stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_reason", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transitioned_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_locations" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_item_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_location_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_module_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_resource_type", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_unit_tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "numeric(38,9)", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_amount", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "on_hand_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "ended_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_positions" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "customer_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "owner_configuration_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "stock_position_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "selling_legal_entity_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "channel", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_market_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "storefront_app_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_evidence_ref", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "commerce_validation_observed_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "text", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "'CURRENT'", + "generated": null, + "identity": null, + "name": "lifecycle_state", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_from", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": false, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "effective_to", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "1", + "generated": null, + "identity": null, + "name": "current_revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "created_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "updated_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "gen_random_uuid()", + "generated": null, + "identity": null, + "name": "history_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "tenant_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "uuid", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "eligibility_id", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "integer", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "revision", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "jsonb", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "snapshot", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": null, + "generated": null, + "identity": null, + "name": "transition_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "type": "timestamp with time zone", + "typeSchema": null, + "notNull": true, + "dimensions": 0, + "default": "now()", + "generated": null, + "identity": null, + "name": "recorded_at", + "entityType": "columns", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_backend_configurations_customer_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciliation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_observation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "corrected_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_binding_correction_reconciliations_open_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_binding_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_selection_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_catalog_to_stock_bindings_stock_item_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protection_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "protection_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_confirmation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "established_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_commitment_protections_health_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_reservation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"effect_kind\" = 'ESTABLISH_COMMITMENT_PROTECTION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_commitment_protection_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_effect_ledger_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correlation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "namespace", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_scope", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "identifier_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "external_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_current_key_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_external_stock_correlations_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "allocation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_allocations_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "purchase_demand_occurrence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_occurrence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "binding_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligation_requirements_binding_impact_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_system", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_obligation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'IMPORTED_PROVEN_ORDER'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_imported_lineage_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "accepted_order_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_obligations_runtime_accepted_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "requested_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_physical_stock_effects_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmation_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_reservation_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_authority_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_health_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issued_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_evidence_ref", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_confirmations_health_rank_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "attempt_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_attempt_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_create_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effect_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "release_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_scope_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reservation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_reservation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "mutation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_mutation_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "current_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "updated_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_release_effects_state_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "change_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "priority_ordinal", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"priority_ordinal\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_priority_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "confirmation_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impact_decisions_confirmation_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "physical_effect_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"physical_effect_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_effect_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"stock_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "occurred_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_position_time_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"status\" = 'INDETERMINATE'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_reservation_shortage_impacts_unresolved_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_assertions_position_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "conflict_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_latest_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "status", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_conflict_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "recorded_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_ledger_stream_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_source_identity_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "issuer_backend_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "fact_meaning", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"status\" = 'ACCEPTED'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_source_import_accepted_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_open_correction_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_kind", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "ordering_evidence_value", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_order_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_reference", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_source_reference_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "authority_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "business_observed_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_stream_observed_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_correction_source_evidence_current_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_tenant_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_assertion_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_assertion_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_assertion_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "source_evidence_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"source_evidence_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_source_evidence_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "reconciles_correction_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"reconciles_correction_id\" is not null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_reconciles_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "applied_at", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_corrections_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "exact_selection_meaning_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_exact_meaning_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_items_current_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_items" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "lifecycle_state", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_locations_lifecycle_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": "\"lifecycle_state\" = 'CURRENT'", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_current_scope_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_item_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_item_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_location_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_positions_location_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "customer_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "owner_configuration_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "stock_position_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": false, + "where": "\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null", + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibilities_current_position_idx", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "history_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_scope_id_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + { + "value": "tenant_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "eligibility_id", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + }, + { + "value": "revision", + "isExpression": false, + "asc": true, + "nullsFirst": false, + "opclass": null + } + ], + "isUnique": true, + "where": null, + "with": "", + "method": "btree", + "concurrently": false, + "name": "inventory_stock_sharing_eligibility_history_revision_uk", + "entityType": "indexes", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "historical_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_historical_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "current_stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_binding_correction_reconciliations_current_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_catalog_to_stock_bindings_stock_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "protection_id" + ], + "schemaTo": "inventory", + "tableTo": "commitment_protections", + "columnsTo": [ + "tenant_id", + "protection_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protection_history_protection_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_commitment_protections_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "effect_ledger", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_effect_ledger_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_external_stock_correlations_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "schemaTo": "inventory", + "tableTo": "obligation_requirements", + "columnsTo": [ + "tenant_id", + "obligation_id", + "purchase_demand_occurrence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_requirement_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_allocations_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "obligation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_obligation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligation_requirements_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_obligations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "obligations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_physical_stock_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmation_history_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_confirmations_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "backend_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_create_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "release_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_release_effects", + "columnsTo": [ + "tenant_id", + "release_effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effect_history_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reservation_id" + ], + "schemaTo": "inventory", + "tableTo": "obligations", + "columnsTo": [ + "tenant_id", + "obligation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_reservation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_release_effects_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_shortage_impacts", + "columnsTo": [ + "tenant_id", + "change_kind", + "change_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_impact_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "confirmation_id" + ], + "schemaTo": "inventory", + "tableTo": "reservation_confirmations", + "columnsTo": [ + "tenant_id", + "confirmation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impact_decisions_confirmation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "physical_effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_reservation_shortage_impacts_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertion_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_authority_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "item_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_item_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "location_correlation_id" + ], + "schemaTo": "inventory", + "tableTo": "external_stock_correlations", + "columnsTo": [ + "tenant_id", + "correlation_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_assertions_location_correlation_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_conflict_revisions_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_source_import_ledger_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_open_correction_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "effect_id" + ], + "schemaTo": "inventory", + "tableTo": "physical_stock_effects", + "columnsTo": [ + "tenant_id", + "effect_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_coverage_effect_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_correction_source_evidence_current_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_assertion_id" + ], + "schemaTo": "inventory", + "tableTo": "source_assertions", + "columnsTo": [ + "tenant_id", + "assertion_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_assertion_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "source_evidence_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_correction_source_evidence", + "columnsTo": [ + "tenant_id", + "evidence_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_source_evidence_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "authority_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_authority_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "reconciles_correction_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_corrections", + "columnsTo": [ + "tenant_id", + "correction_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_corrections_reconciles_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_location_revisions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "successor_stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_locations_successor_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_item_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_items", + "columnsTo": [ + "tenant_id", + "stock_item_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_item_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_locations", + "columnsTo": [ + "tenant_id", + "stock_location_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_location_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_positions_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "owner_configuration_id" + ], + "schemaTo": "inventory", + "tableTo": "backend_configurations", + "columnsTo": [ + "tenant_id", + "configuration_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_backend_configuration_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_position_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_positions", + "columnsTo": [ + "tenant_id", + "stock_position_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibilities_position_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "eligibility_id" + ], + "schemaTo": "inventory", + "tableTo": "stock_sharing_eligibilities", + "columnsTo": [ + "tenant_id", + "eligibility_id" + ], + "onUpdate": "NO ACTION", + "onDelete": "RESTRICT", + "name": "inventory_stock_sharing_eligibility_history_eligibility_fk", + "entityType": "fks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_effect_ledger_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "columns": [ + "tenant_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_create_effects_pkey", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id", + "confirmation_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impact_decisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "columns": [ + "tenant_id", + "change_kind", + "change_id" + ], + "nameExplicit": true, + "name": "inventory_reservation_shortage_impacts_pk", + "entityType": "pks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "columns": [ + "tenant_id", + "assertion_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_source_assertion_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "columns": [ + "tenant_id", + "conflict_id", + "revision" + ], + "nameExplicit": true, + "name": "inventory_source_conflict_revisions_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "columns": [ + "tenant_id", + "action_invocation_id", + "item_index" + ], + "nameExplicit": true, + "name": "inventory_source_import_ledger_pk", + "entityType": "pks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "columns": [ + "tenant_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_open_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "columns": [ + "tenant_id", + "evidence_id", + "effect_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_coverage_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "columns": [ + "tenant_id", + "customer_configuration_id", + "authority_configuration_id", + "position_id" + ], + "nameExplicit": true, + "name": "inventory_stock_correction_source_evidence_current_pk", + "entityType": "pks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "columns": [ + "configuration_id" + ], + "nameExplicit": false, + "name": "backend_configurations_pkey", + "schema": "inventory", + "table": "backend_configurations", + "entityType": "pks" + }, + { + "columns": [ + "reconciliation_id" + ], + "nameExplicit": false, + "name": "binding_correction_reconciliations_pkey", + "schema": "inventory", + "table": "binding_correction_reconciliations", + "entityType": "pks" + }, + { + "columns": [ + "binding_history_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_binding_history_pkey", + "schema": "inventory", + "table": "catalog_to_stock_binding_history", + "entityType": "pks" + }, + { + "columns": [ + "binding_id" + ], + "nameExplicit": false, + "name": "catalog_to_stock_bindings_pkey", + "schema": "inventory", + "table": "catalog_to_stock_bindings", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "commitment_protection_history_pkey", + "schema": "inventory", + "table": "commitment_protection_history", + "entityType": "pks" + }, + { + "columns": [ + "protection_id" + ], + "nameExplicit": false, + "name": "commitment_protections_pkey", + "schema": "inventory", + "table": "commitment_protections", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "effect_ledger_history_pkey", + "schema": "inventory", + "table": "effect_ledger_history", + "entityType": "pks" + }, + { + "columns": [ + "correlation_id" + ], + "nameExplicit": false, + "name": "external_stock_correlations_pkey", + "schema": "inventory", + "table": "external_stock_correlations", + "entityType": "pks" + }, + { + "columns": [ + "obligation_id" + ], + "nameExplicit": false, + "name": "obligations_pkey", + "schema": "inventory", + "table": "obligations", + "entityType": "pks" + }, + { + "columns": [ + "effect_id" + ], + "nameExplicit": false, + "name": "physical_stock_effects_pkey", + "schema": "inventory", + "table": "physical_stock_effects", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_confirmation_history_pkey", + "schema": "inventory", + "table": "reservation_confirmation_history", + "entityType": "pks" + }, + { + "columns": [ + "confirmation_id" + ], + "nameExplicit": false, + "name": "reservation_confirmations_pkey", + "schema": "inventory", + "table": "reservation_confirmations", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "reservation_release_effect_history_pkey", + "schema": "inventory", + "table": "reservation_release_effect_history", + "entityType": "pks" + }, + { + "columns": [ + "release_effect_record_id" + ], + "nameExplicit": false, + "name": "reservation_release_effects_pkey", + "schema": "inventory", + "table": "reservation_release_effects", + "entityType": "pks" + }, + { + "columns": [ + "assertion_id" + ], + "nameExplicit": false, + "name": "source_assertions_pkey", + "schema": "inventory", + "table": "source_assertions", + "entityType": "pks" + }, + { + "columns": [ + "evidence_id" + ], + "nameExplicit": false, + "name": "stock_correction_source_evidence_pkey", + "schema": "inventory", + "table": "stock_correction_source_evidence", + "entityType": "pks" + }, + { + "columns": [ + "correction_id" + ], + "nameExplicit": false, + "name": "stock_corrections_pkey", + "schema": "inventory", + "table": "stock_corrections", + "entityType": "pks" + }, + { + "columns": [ + "stock_item_id" + ], + "nameExplicit": false, + "name": "stock_items_pkey", + "schema": "inventory", + "table": "stock_items", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_revision_id" + ], + "nameExplicit": false, + "name": "stock_location_revisions_pkey", + "schema": "inventory", + "table": "stock_location_revisions", + "entityType": "pks" + }, + { + "columns": [ + "stock_location_id" + ], + "nameExplicit": false, + "name": "stock_locations_pkey", + "schema": "inventory", + "table": "stock_locations", + "entityType": "pks" + }, + { + "columns": [ + "stock_position_id" + ], + "nameExplicit": false, + "name": "stock_positions_pkey", + "schema": "inventory", + "table": "stock_positions", + "entityType": "pks" + }, + { + "columns": [ + "eligibility_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibilities_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibilities", + "entityType": "pks" + }, + { + "columns": [ + "history_id" + ], + "nameExplicit": false, + "name": "stock_sharing_eligibility_history_pkey", + "schema": "inventory", + "table": "stock_sharing_eligibility_history", + "entityType": "pks" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_revision_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id", + "revision" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_location_revisions_number_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "nameExplicit": true, + "columns": [ + "tenant_id", + "stock_location_id" + ], + "nullsNotDistinct": false, + "name": "inventory_stock_locations_scope_id_uk", + "entityType": "uniques", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "length(btrim(\"backend_id\")) between 1 and 300 and length(btrim(\"customer_configuration_id\")) between 1 and 300", + "name": "inventory_backend_configurations_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_backend_configurations_backend_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"exact_reservation_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"backend_kind\" <> 'ontos_wms' or \"stock_correction_capability\" = 'SUPPORTED')", + "name": "inventory_backend_configurations_stock_correction_capability_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"revision\" = 1", + "name": "inventory_backend_configurations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "value": "\"binding_revision\" >= 2 and char_length(btrim(\"correction_evidence_ref\")) between 1 and 300 and char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and \"reason\" = 'POST_COMMIT_BINDING_MISMATCH' and \"status\" = 'OPEN' and \"historical_stock_item_id\" <> \"current_stock_item_id\"", + "name": "inventory_binding_correction_reconciliations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_catalog_to_stock_binding_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "\"transition\" in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_catalog_to_stock_binding_history_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_catalog_to_stock_bindings_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_catalog_to_stock_bindings_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_catalog_to_stock_bindings_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "value": "\"health_state\" in ('PROTECTED', 'AT_RISK') and \"revision\" >= 1", + "name": "inventory_commitment_protection_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_commitment_protections_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"current_health_state\" in ('PROTECTED', 'AT_RISK') and \"current_revision\" >= 1", + "name": "inventory_commitment_protections_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "value": "\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')", + "name": "inventory_effect_ledger_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')", + "name": "inventory_effect_ledger_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and char_length(\"intent_canonical\") > 0", + "name": "inventory_effect_ledger_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"effect_kind\" in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is not null and \"attempt_id\" is not null and char_length(btrim(\"attempt_id\")) between 1 and 300) or (\"effect_kind\" not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and \"reservation_id\" is null and \"attempt_id\" is null)", + "name": "inventory_effect_ledger_reservation_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "(\"current_state\" = 'REQUESTED' and \"resolution_json\" is null) or (\"current_state\" = 'INDETERMINATE') or (\"current_state\" in ('SUCCEEDED', 'REJECTED') and \"resolution_json\" is not null)", + "name": "inventory_effect_ledger_resolution_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_effect_ledger_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and \"revision\" >= 1", + "name": "inventory_effect_ledger_history_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"namespace\")) between 1 and 300 and length(btrim(\"external_scope\")) between 1 and 300 and \"identifier_kind\" in ('ITEM', 'LOCATION') and length(btrim(\"external_value\")) between 1 and 300", + "name": "inventory_external_stock_correlations_key_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"identifier_kind\" = 'ITEM' and \"stock_item_id\" is not null and \"stock_location_id\" is null) or (\"identifier_kind\" = 'LOCATION' and \"stock_item_id\" is null and \"stock_location_id\" is not null)", + "name": "inventory_external_stock_correlations_target_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_external_stock_correlations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_external_stock_correlations_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_external_stock_correlations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "value": "char_length(btrim(\"allocation_id\")) between 1 and 300 and \"allocated_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_allocations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "value": "char_length(btrim(\"purchase_demand_occurrence_id\")) between 1 and 300 and char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_meaning_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and \"stock_item_revision\" >= 1 and \"requested_amount\" >= 0 and \"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_obligation_requirements_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and \"attempt_id\" is not null and \"source_system\" is null and \"source_order_id\" is null and \"source_obligation_id\" is null) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"attempt_id\" is null and \"source_system\" is not null and \"source_order_id\" is not null and \"source_obligation_id\" is not null)", + "name": "inventory_obligations_origin_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "(\"origin_kind\" = 'ORDER_COMMITMENT_ATTEMPT' and ((\"lifecycle_meaning\" = 'PROVISIONAL_RESERVATION' and \"accepted_order_id\" is null and \"order_evidence_ref\" is null and \"order_evidence_observed_at\" is null) or (\"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null))) or (\"origin_kind\" = 'IMPORTED_PROVEN_ORDER' and \"lifecycle_meaning\" = 'COMMITTED_OBLIGATION' and \"accepted_order_id\" is not null and \"order_evidence_ref\" is not null and \"order_evidence_observed_at\" is not null)", + "name": "inventory_obligations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"authority_backend_id\")) between 1 and 300 and (\"attempt_id\" is null or char_length(btrim(\"attempt_id\")) between 1 and 300) and (\"accepted_order_id\" is null or char_length(btrim(\"accepted_order_id\")) between 1 and 300) and (\"order_evidence_ref\" is null or char_length(btrim(\"order_evidence_ref\")) between 1 and 300) and (\"source_system\" is null or char_length(btrim(\"source_system\")) between 1 and 300) and (\"source_order_id\" is null or char_length(btrim(\"source_order_id\")) between 1 and 300) and (\"source_obligation_id\" is null or char_length(btrim(\"source_obligation_id\")) between 1 and 300)", + "name": "inventory_obligations_identity_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"authority_backend_kind\" in ('external_business_system', 'ontos_wms') and \"authority_exact_reservation_capability\" in ('SUPPORTED', 'UNSUPPORTED') and \"authority_stock_correction_capability\" in ('SUPPORTED', 'UNSUPPORTED') and (\"authority_backend_kind\" <> 'ontos_wms' or (\"authority_exact_reservation_capability\" = 'SUPPORTED' and \"authority_stock_correction_capability\" = 'SUPPORTED')) and \"authority_revision\" = 1", + "name": "inventory_obligations_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "obligations" + }, + { + "value": "\"kind\" in ('RECEIPT', 'ISSUE')", + "name": "inventory_physical_stock_effects_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_physical_stock_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "(\"state\" = 'REQUESTED' and \"evidence_json\" is null and \"terminal_reason\" is null) or (\"state\" = 'APPLIED' and \"evidence_json\" is not null and \"terminal_reason\" is null) or (\"state\" in ('REJECTED', 'INDETERMINATE') and \"evidence_json\" is null and \"terminal_reason\" is not null)", + "name": "inventory_physical_stock_effects_terminal_ck", + "entityType": "checks", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "value": "\"health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"revision\" >= 1", + "name": "inventory_reservation_confirmation_history_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "value": "char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and char_length(btrim(\"authority_effect_id\")) between 1 and 300 and char_length(btrim(\"owner_evidence_ref\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"issued_at\" < \"expires_at\"", + "name": "inventory_reservation_confirmations_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "\"current_health_state\" in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and \"current_revision\" >= 1", + "name": "inventory_reservation_confirmations_health_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "value": "char_length(btrim(\"effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"customer_configuration_id\")) between 1 and 300 and char_length(btrim(\"backend_id\")) between 1 and 300", + "name": "inventory_reservation_create_effects_identity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')", + "name": "inventory_reservation_create_effects_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "value": "\"state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"revision\" >= 1", + "name": "inventory_reservation_release_effect_history_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "value": "char_length(btrim(\"release_effect_id\")) between 1 and 300 and char_length(btrim(\"attempt_id\")) between 1 and 300 and char_length(btrim(\"issuer_backend_id\")) between 1 and 300 and \"issuer_backend_kind\" in ('external_business_system', 'ontos_wms') and \"current_state\" in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and \"current_revision\" >= 1 and ((\"current_state\" = 'RELEASED' and \"released_at\" is not null and \"owner_evidence_ref\" is not null) or (\"current_state\" <> 'RELEASED' and \"released_at\" is null and \"owner_evidence_ref\" is null))", + "name": "inventory_reservation_release_effects_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "value": "\"decision\" in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and \"health_before\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"health_after\" in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and \"confirmation_revision_before\" >= 1 and \"confirmation_revision_after\" >= \"confirmation_revision_before\" and char_length(btrim(\"rank_owner_evidence_ref\")) between 1 and 300 and ((\"decision\" = 'ORDER_UNRESOLVABLE' and \"priority_ordinal\" is null and \"affected_amount\" is null) or (\"decision\" in ('HONORABLE', 'SHORTAGE') and \"priority_ordinal\" >= 1 and \"affected_amount\" > 0))", + "name": "inventory_reservation_shortage_impact_decisions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "value": "(\"change_kind\" in ('RECEIPT', 'ISSUE') and \"physical_effect_id\" = \"change_id\" and \"stock_correction_id\" is null) or (\"change_kind\" = 'CORRECTION' and \"stock_correction_id\" = \"change_id\" and \"physical_effect_id\" is null)", + "name": "inventory_reservation_shortage_impacts_source_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "(\"status\" = 'DETERMINATE' and \"reconciliation_required\" = false and \"reason\" is null) or (\"status\" = 'INDETERMINATE' and \"reconciliation_required\" = true and \"reason\" = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')", + "name": "inventory_reservation_shortage_impacts_outcome_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"position_revision\" >= 1 and \"available_amount\" >= 0 and \"fenced_amount\" >= 0 and \"decision_count\" >= 0", + "name": "inventory_reservation_shortage_impacts_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_source_assertion_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "length(btrim(\"owner_evidence_ref\")) between 1 and 300", + "name": "inventory_source_assertion_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_assertions_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"issuer_authority\" in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')", + "name": "inventory_source_assertions_authority_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_source_assertions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"quantity_amount\")) between 1 and 50 and length(btrim(\"ordering_evidence_value\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_source_assertions_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_assertions_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_assertions" + }, + { + "value": "\"revision\" in (1, 2)", + "name": "inventory_source_conflict_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"revision\" = 1 and \"status\" = 'OPEN' and \"current_truth\" = 'INDETERMINATE' and \"resolved_at\" is null) or (\"revision\" = 2 and \"status\" = 'RESOLVED' and \"current_truth\" in ('CURRENT', 'CONFIGURATION_SINGULAR') and \"resolved_at\" is not null and \"resolved_at\" >= \"detected_at\")", + "name": "inventory_source_conflict_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"conflict_type\" in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')", + "name": "inventory_source_conflict_type_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "(\"conflict_type\" in ('BACKEND_CONFIGURATION', 'CORRELATION') and \"position_id\" is null and \"fact_meaning\" is null) or (\"conflict_type\" in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and \"position_id\" is not null and \"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND')", + "name": "inventory_source_conflict_scope_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_source_conflict_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "value": "\"item_index\" >= 0", + "name": "inventory_source_import_ledger_item_index_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'external_business_system'", + "name": "inventory_source_import_ledger_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"ordering_evidence_kind\" in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')", + "name": "inventory_source_import_ledger_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"status\" in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')", + "name": "inventory_source_import_ledger_status_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "length(btrim(\"customer_configuration_id\")) between 1 and 300 and length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300 and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_source_import_ledger_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "value": "\"fact_meaning\" = 'ABSOLUTE_PHYSICAL_ON_HAND' and \"issuer_backend_kind\" = 'ontos_wms'", + "name": "inventory_stock_correction_source_evidence_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY'", + "name": "inventory_stock_correction_source_evidence_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"unit_module_id\" = 'commerce.catalog' and \"unit_resource_type\" = 'commerce.catalog.product-unit' and \"unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_correction_source_evidence_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"quantity_amount\" ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(\"quantity_amount\", '.', 1)) <= 29 and (position('.' in \"quantity_amount\") = 0 or length(split_part(\"quantity_amount\", '.', 2)) <= 9)", + "name": "inventory_stock_correction_source_evidence_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300 and \"issuer_backend_id\" = btrim(\"issuer_backend_id\") and length(\"issuer_backend_id\") between 1 and 300 and \"ordering_evidence_value\" = btrim(\"ordering_evidence_value\") and length(\"ordering_evidence_value\") between 1 and 300 and \"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300 and \"source_reference\" = btrim(\"source_reference\") and length(\"source_reference\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "value": "\"relation\" in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')", + "name": "inventory_stock_correction_source_evidence_coverage_relation_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"owner_evidence_ref\" = btrim(\"owner_evidence_ref\") and length(\"owner_evidence_ref\") between 1 and 300", + "name": "inventory_stock_correction_source_evidence_coverage_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "value": "\"ordering_evidence_kind\" = 'OWNER_ORDER_KEY' and length(btrim(\"ordering_evidence_value\")) between 1 and 300", + "name": "inventory_stock_correction_source_evidence_current_ordering_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_corrections_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "length(btrim(\"issuer_backend_id\")) between 1 and 300 and length(btrim(\"owner_evidence_ref\")) between 1 and 300 and length(btrim(\"source_reference\")) between 1 and 300", + "name": "inventory_stock_corrections_provenance_text_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"issuer_backend_kind\" in ('external_business_system', 'ontos_wms')", + "name": "inventory_stock_corrections_issuer_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"evidence_kind\" = 'EXTERNAL_SOURCE_ASSERTION' and \"issuer_backend_kind\" = 'external_business_system' and \"source_assertion_id\" is not null and \"source_evidence_id\" is null) or (\"evidence_kind\" = 'ONTOS_WMS_OWNER_EVIDENCE' and \"issuer_backend_kind\" = 'ontos_wms' and \"source_assertion_id\" is null and \"source_evidence_id\" is not null)", + "name": "inventory_stock_corrections_evidence_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"state\" in ('APPLIED', 'INDETERMINATE')", + "name": "inventory_stock_corrections_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "(\"state\" = 'APPLIED' and \"corrected_quantity_amount\" is not null and \"corrected_quantity_amount\" >= 0) or (\"state\" = 'INDETERMINATE' and \"corrected_quantity_amount\" is null)", + "name": "inventory_stock_corrections_quantity_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "\"expected_position_revision\" >= 1 and \"position_revision_after\" = \"expected_position_revision\" + 1 and \"position_revision_after\" <= 2147483647", + "name": "inventory_stock_corrections_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "value": "char_length(btrim(\"exact_selection_meaning_id\")) between 1 and 300 and \"exact_selection_kind\" in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')", + "name": "inventory_stock_items_meaning_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_items_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_items_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'RETIRED')", + "name": "inventory_stock_items_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"retired_at\" is null) or (\"lifecycle_state\" = 'RETIRED' and \"retired_at\" is not null)", + "name": "inventory_stock_items_retirement_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_items" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_location_revisions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_locations_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"display_name\" = btrim(\"display_name\") and length(\"display_name\") between 1 and 300", + "name": "inventory_stock_locations_display_name_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"scope_kind\" in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')", + "name": "inventory_stock_locations_scope_kind_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "jsonb_typeof(\"physical_site_keys\") = 'array' and jsonb_array_length(\"physical_site_keys\") <= 100 and (\"scope_kind\" <> 'PHYSICAL_SITE' or jsonb_array_length(\"physical_site_keys\") = 1)", + "name": "inventory_stock_locations_site_keys_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"lifecycle_state\" in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')", + "name": "inventory_stock_locations_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "((\"lifecycle_state\" in ('ACTIVE', 'RETIRED')) and \"successor_stock_location_id\" is null) or ((\"lifecycle_state\" in ('REPLACED', 'MERGED')) and \"successor_stock_location_id\" is not null and \"successor_stock_location_id\" <> \"stock_location_id\")", + "name": "inventory_stock_locations_successor_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "(\"lifecycle_state\" = 'ACTIVE' and \"transition_reason\" is null and \"transitioned_at\" is null) or (\"lifecycle_state\" <> 'ACTIVE' and \"transition_reason\" = btrim(\"transition_reason\") and length(\"transition_reason\") between 1 and 1000 and \"transitioned_at\" is not null)", + "name": "inventory_stock_locations_transition_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_locations" + }, + { + "value": "\"customer_configuration_id\" = btrim(\"customer_configuration_id\") and length(\"customer_configuration_id\") between 1 and 300", + "name": "inventory_stock_positions_customer_configuration_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"stock_unit_module_id\" = 'commerce.catalog' and \"stock_unit_resource_type\" = 'commerce.catalog.product-unit' and \"stock_unit_tenant_id\" = \"tenant_id\"", + "name": "inventory_stock_positions_unit_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"lifecycle_state\" in ('CURRENT', 'HISTORICAL')", + "name": "inventory_stock_positions_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"ended_at\" is null) or (\"lifecycle_state\" = 'HISTORICAL' and \"ended_at\" is not null)", + "name": "inventory_stock_positions_ended_at_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "not (\"lifecycle_state\" = 'HISTORICAL' and \"on_hand_state\" = 'CURRENT')", + "name": "inventory_stock_positions_historical_on_hand_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"on_hand_state\" in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')", + "name": "inventory_stock_positions_on_hand_state_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "((\"on_hand_state\" in ('CURRENT', 'STALE')) and \"on_hand_amount\" is not null and \"on_hand_amount\" >= 0 and \"on_hand_evidence_ref\" is not null and \"on_hand_observed_at\" is not null) or ((\"on_hand_state\" in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and \"on_hand_amount\" is null and \"on_hand_evidence_ref\" is null and \"on_hand_observed_at\" is null)", + "name": "inventory_stock_positions_on_hand_value_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_positions_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_positions" + }, + { + "value": "\"channel\" in ('B2C', 'B2B') and char_length(btrim(\"commerce_validation_evidence_ref\")) between 1 and 300 and (\"commerce_market_id\" is null or char_length(btrim(\"commerce_market_id\")) between 1 and 300) and (\"storefront_app_id\" is null or \"storefront_app_id\" ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')", + "name": "inventory_stock_sharing_eligibilities_subject_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "(\"lifecycle_state\" = 'CURRENT' and \"effective_to\" is null) or (\"lifecycle_state\" = 'ENDED' and \"effective_to\" is not null and \"effective_from\" < \"effective_to\")", + "name": "inventory_stock_sharing_eligibilities_lifecycle_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"current_revision\" >= 1", + "name": "inventory_stock_sharing_eligibilities_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "value": "\"revision\" >= 1", + "name": "inventory_stock_sharing_eligibility_history_revision_ck", + "entityType": "checks", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_backend_configurations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"backend_configurations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_backend_configurations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "backend_configurations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_binding_correction_reconciliations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"binding_correction_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_binding_correction_reconciliations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "binding_correction_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_binding_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_binding_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_binding_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_binding_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_catalog_to_stock_bindings_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"catalog_to_stock_bindings\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_catalog_to_stock_bindings_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "catalog_to_stock_bindings" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protection_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protection_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protection_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protection_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_commitment_protections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"commitment_protections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_commitment_protections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "commitment_protections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_effect_ledger_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"effect_ledger_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_effect_ledger_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "effect_ledger_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_external_stock_correlations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"external_stock_correlations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_external_stock_correlations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "external_stock_correlations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_allocations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_allocations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_allocations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_allocations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligation_requirements_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligation_requirements\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligation_requirements_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligation_requirements" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_obligations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"obligations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_obligations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "obligations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_physical_stock_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"physical_stock_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_physical_stock_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "physical_stock_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmation_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmation_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmation_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmation_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_confirmations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_confirmations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_confirmations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_confirmations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_create_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_create_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_create_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_create_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effect_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effect_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effect_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effect_history" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_release_effects_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_release_effects\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_release_effects_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_release_effects" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impact_decisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impact_decisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impact_decisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impact_decisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_reservation_shortage_impacts_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"reservation_shortage_impacts\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_reservation_shortage_impacts_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "reservation_shortage_impacts" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertion_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertion_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertion_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertion_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_assertions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_assertions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_assertions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_assertions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_conflict_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_conflict_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_conflict_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_conflict_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_source_import_ledger_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"source_import_ledger\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_source_import_ledger_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "source_import_ledger" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_open_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_open_reconciliations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_open_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_open_reconciliations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_coverage_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_coverage\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_coverage_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_coverage" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_correction_source_evidence_current_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_correction_source_evidence_current\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_correction_source_evidence_current_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_correction_source_evidence_current" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_corrections_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_corrections\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_corrections_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_corrections" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_items_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_items\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_items_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_items" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_location_revisions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_location_revisions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_location_revisions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_location_revisions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_locations_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_locations\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_locations_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_locations" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_positions_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_positions\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_positions_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_positions" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibilities_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibilities\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibilities_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibilities" + }, + { + "as": "PERMISSIVE", + "for": "SELECT", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_select", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "INSERT", + "roles": [ + "ontos_runtime" + ], + "using": null, + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_insert", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "UPDATE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "name": "inventory_stock_sharing_eligibility_history_tenant_update", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + }, + { + "as": "PERMISSIVE", + "for": "DELETE", + "roles": [ + "ontos_runtime" + ], + "using": "\"inventory\".\"stock_sharing_eligibility_history\".\"tenant_id\" = nullif(current_setting('ontos.tenant_id', true), '')::uuid", + "withCheck": null, + "name": "inventory_stock_sharing_eligibility_history_tenant_delete", + "entityType": "policies", + "schema": "inventory", + "table": "stock_sharing_eligibility_history" + } + ], + "renames": [] +} \ No newline at end of file diff --git a/app/verticals/inventory/locales/cs/inventory.json b/app/verticals/inventory/locales/cs/inventory.json new file mode 100644 index 000000000..832c1f999 --- /dev/null +++ b/app/verticals/inventory/locales/cs/inventory.json @@ -0,0 +1,21 @@ +{ + "inventory": { + "language": { + "cs": "Čeština", + "en": "Angličtina", + "switcher": "Jazyk" + }, + "routes": { + "home": "Domů" + }, + "seo": { + "description": "Route-owned UltraModern plocha s lokalizovaným SSR a frameworkem řízenými public metadata." + }, + "federatedSurface": "Federovaná plocha vlastněná tímto verticalem.", + "remoteUnavailable": "Remote vertical je nedostupný", + "role": "inventory", + "routeSurface": "Routovaná plocha vlastněná tímto verticalem.", + "title": "Inventory Vertical", + "widgetBody": "Vlastní routovanou plochu verticalu." + } +} diff --git a/app/verticals/inventory/locales/cs/translation.json b/app/verticals/inventory/locales/cs/translation.json new file mode 100644 index 000000000..832c1f999 --- /dev/null +++ b/app/verticals/inventory/locales/cs/translation.json @@ -0,0 +1,21 @@ +{ + "inventory": { + "language": { + "cs": "Čeština", + "en": "Angličtina", + "switcher": "Jazyk" + }, + "routes": { + "home": "Domů" + }, + "seo": { + "description": "Route-owned UltraModern plocha s lokalizovaným SSR a frameworkem řízenými public metadata." + }, + "federatedSurface": "Federovaná plocha vlastněná tímto verticalem.", + "remoteUnavailable": "Remote vertical je nedostupný", + "role": "inventory", + "routeSurface": "Routovaná plocha vlastněná tímto verticalem.", + "title": "Inventory Vertical", + "widgetBody": "Vlastní routovanou plochu verticalu." + } +} diff --git a/app/verticals/inventory/locales/en/inventory.json b/app/verticals/inventory/locales/en/inventory.json new file mode 100644 index 000000000..ddd1c11ae --- /dev/null +++ b/app/verticals/inventory/locales/en/inventory.json @@ -0,0 +1,21 @@ +{ + "inventory": { + "language": { + "cs": "Czech", + "en": "English", + "switcher": "Language" + }, + "routes": { + "home": "Home" + }, + "seo": { + "description": "Route-owned UltraModern surface with localized SSR and framework-owned public metadata." + }, + "federatedSurface": "Federated surface owned by this vertical.", + "remoteUnavailable": "Remote vertical unavailable", + "role": "inventory", + "routeSurface": "Route surface owned by this vertical.", + "title": "Inventory Vertical", + "widgetBody": "Owns a vertical route surface." + } +} diff --git a/app/verticals/inventory/locales/en/translation.json b/app/verticals/inventory/locales/en/translation.json new file mode 100644 index 000000000..ddd1c11ae --- /dev/null +++ b/app/verticals/inventory/locales/en/translation.json @@ -0,0 +1,21 @@ +{ + "inventory": { + "language": { + "cs": "Czech", + "en": "English", + "switcher": "Language" + }, + "routes": { + "home": "Home" + }, + "seo": { + "description": "Route-owned UltraModern surface with localized SSR and framework-owned public metadata." + }, + "federatedSurface": "Federated surface owned by this vertical.", + "remoteUnavailable": "Remote vertical unavailable", + "role": "inventory", + "routeSurface": "Route surface owned by this vertical.", + "title": "Inventory Vertical", + "widgetBody": "Owns a vertical route surface." + } +} diff --git a/app/verticals/inventory/modern.config.ts b/app/verticals/inventory/modern.config.ts new file mode 100644 index 000000000..7ecfe9e52 --- /dev/null +++ b/app/verticals/inventory/modern.config.ts @@ -0,0 +1,273 @@ +import { createRequire } from 'node:module'; +import { fileURLToPath } from 'node:url'; + +import { defineConfig } from '@modern-js/app-tools'; +import type { AppTools, AppToolsUserConfig, CliPlugin } from '@modern-js/app-tools'; +import { getBuildConfigEnvironment, resolveDeployTarget } from '@modern-js/app-tools-extensions/config'; +import { bffPlugin } from '@modern-js/plugin-bff-build-extensions'; +import { i18nPlugin } from '@modern-js/plugin-i18n'; +import { tanstackRouterPlugin } from '@modern-js/plugin-tanstack'; +import { presetUltramodern, ultramodernAppTools } from '@modern-js/ultramodern-app-tools'; +import { moduleFederationPlugin } from '@module-federation/modern-js-v3'; +import { pluginTailwindcss } from '@rsbuild/plugin-tailwindcss'; +import { withZephyr as withZephyrRspack } from 'zephyr-rspack-plugin'; + +import { + createCloudflareDataPlaneBindings, + createModernBuildContext, + createWorkerSsrPlugins, + createZephyrRspackPlugin, + resolveCloudflareExternal, +} from '../../packages/shared-contracts/tooling/modern-config.ts'; +import { ultramodernLocalisedUrls } from './src/routes/ultramodern-route-metadata.ts'; + +Object.assign(globalThis, { require: createRequire(import.meta.url) }); + +const appId = 'inventory'; +const cloudflareWorkerName = 'app-inventory'; +const { + assetPrefix, + buildCacheDirectory, + buildOutputRoot, + buildTarget, + buildTempDirectory, + cloudflareDeployEnabled, + envValue, + getBuildBoolean, + moduleFederationDevServerOrigin, + port, + siteUrl, +} = createModernBuildContext({ + appId, + cloudflarePublicUrlEnvironmentVariable: 'ULTRAMODERN_PUBLIC_URL_INVENTORY', + cloudflareWorkerName, + defaultPort: 4109, + deployTarget: resolveDeployTarget().target, + getBuildConfigEnvironment, + portEnvironmentVariable: 'VERTICAL_INVENTORY_PORT', +}); +// The dev server serves federated assets to every local app origin, so the +// allowed origin is negotiated per request instead of pinned to one header. +const moduleFederationDevServerAllowedOrigins = [ + ...new Set([moduleFederationDevServerOrigin, `http://localhost:${port}`]), +]; +const resolveEffectApiSourceDirectory = () => fileURLToPath(new URL('api/', import.meta.url)); +/* oxlint-disable promise/prefer-await-to-callbacks -- Rspack externals use a callback API. expires: 2026-12-31. */ +const cloudflareRuntimeExternal = ( + request: { dependencyType?: string; request?: string }, + callback: (error?: Error, result?: string | string[], type?: 'module-import') => void, +) => { + callback(...resolveCloudflareExternal(request, cloudflareDeployEnabled)); +}; +/* oxlint-enable promise/prefer-await-to-callbacks */ + +const zephyrRspackPlugin = (): CliPlugin => + createZephyrRspackPlugin({ + configure: () => withZephyrRspack(), + readEnvironment: envValue, + }); + +const whenEnabled = (enabled: boolean, configuration: Configuration) => + enabled ? configuration : undefined; + +// Only a Worker build binds the private data plane; its IDs are required there and unused elsewhere. +const cloudflareDataPlaneBindings = cloudflareDeployEnabled ? createCloudflareDataPlaneBindings(envValue) : undefined; +const cloudflareDeployment = whenEnabled(cloudflareDeployEnabled, { + deploy: { + worker: { + ...cloudflareDataPlaneBindings, + compatibilityDate: '2026-06-02', + name: cloudflareWorkerName, + security: { + contentSecurityPolicy: { + directives: { + 'base-uri': ["'self'"], + 'connect-src': ["'self'", 'https:', 'http:', 'wss:', 'ws:'], + 'default-src': ["'self'"], + 'font-src': ["'self'", 'data:', 'https:', 'http:'], + 'form-action': ["'self'"], + 'frame-ancestors': ["'self'"], + 'img-src': ["'self'", 'data:', 'blob:', 'https:', 'http:'], + 'manifest-src': ["'self'", 'https:', 'http:'], + 'object-src': ["'none'"], + 'script-src': ["'self'", "'unsafe-inline'", "'unsafe-eval'", 'https:', 'http:', 'blob:'], + 'style-src': ["'self'", "'unsafe-inline'", 'https:', 'http:'], + 'worker-src': ["'self'", 'blob:'], + }, + mode: 'report-only' as const, + reason: + 'Report-only by default so Cloudflare Module Federation SSR can prove remote script, style, and connect compatibility before enforcement.', + }, + enabled: true, + headers: { + contentTypeOptions: 'nosniff' as const, + permissionsPolicy: 'camera=(), geolocation=(), microphone=(), payment=(), usb=()', + referrerPolicy: 'strict-origin-when-cross-origin' as const, + }, + noindex: { + localhost: true, + previewHostnames: [], + workersDev: true, + }, + }, + ssr: true, + }, + }, +} satisfies Pick); + +const performanceConfig = { + buildCache: { + cacheDigest: [appId, buildTarget], + cacheDirectory: buildCacheDirectory, + }, + rsdoctor: { + disableClientServer: true, + enabled: getBuildBoolean('ULTRAMODERN_RSDOCTOR'), + }, +}; + +export default defineConfig( + presetUltramodern( + { + bff: { + effect: { + entry: './api/index', + openapi: { + path: '/openapi.json', + }, + + strictEffectApproach: true, + }, + prefix: '/inventory-api', + runtimeFramework: 'effect', + }, + builderPlugins: [pluginTailwindcss()], + ...cloudflareDeployment, + dev: { + // Remote dev manifests must publish an absolute publicPath so host + // shells load remoteEntry.js and exposed chunks from this dev server. + assetPrefix, + // MF assets are non-credentialed and only permit configured local app origins. + server: { + cors: { + origin: moduleFederationDevServerAllowedOrigins, + }, + headers: { + 'Access-Control-Allow-Headers': 'Accept, Authorization, Content-Type, X-Requested-With', + 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS', + }, + }, + }, + html: { + outputStructure: 'flat', + }, + output: { + assetPrefix, + disableTsChecker: true, + distPath: { + html: './', + root: buildOutputRoot, + }, + polyfill: 'off', + splitRouteChunks: true, + tempDir: buildTempDirectory, + }, + performance: performanceConfig, + plugins: [ + ultramodernAppTools(), + tanstackRouterPlugin(), + i18nPlugin({ + backend: { + enabled: true, + loadPath: '/locales/{{lng}}/{{ns}}.json', + }, + localeDetection: { + fallbackLanguage: 'en', + ignoreRedirectRoutes: [ + '/@mf-types', + '/assets', + '/bundles', + '/inventory-api', + '/locales', + '/mf-manifest.json', + '/mf-stats.json', + '/remoteEntry.js', + '/robots.txt', + '/site.webmanifest', + '/sitemap.xml', + '/static', + '/zephyr-manifest.json', + ], + languages: ['en', 'cs'], + localePathRedirect: true, + // SAFETY: the generated route metadata is a locale-to-route string map consumed read-only by the plugin. + localisedUrls: ultramodernLocalisedUrls as Record>, + }, + reactI18next: false, + }), + bffPlugin(), + moduleFederationPlugin(), + zephyrRspackPlugin(), + ], + server: { + port, + publicDir: ['./locales', './assets'], + }, + source: { + alias: { + '@modern-js/plugin-i18n/runtime$': '@modern-js/plugin-i18n/runtime/no-react-i18next', + }, + globalVars: { + ULTRAMODERN_SHELL_ORIGIN: moduleFederationDevServerOrigin, + ULTRAMODERN_SITE_URL: siteUrl, + }, + mainEntryName: 'index', + }, + tools: { + autoprefixer: { + overrideBrowserslist: ['defaults'], + }, + bundlerChain: (chain) => { + chain.output + .uniqueName('verticalInventory') + .chunkLoadingGlobal('__ULTRAMODERN_VERTICAL_INVENTORY_LOADED_CHUNKS__'); + }, + rspack: (config, { environment, rspack }) => { + if (!cloudflareDeployEnabled) { + return; + } + const configuredExternals = config.externals; + config.externals = [cloudflareRuntimeExternal]; + if (configuredExternals !== undefined) { + config.externals.push( + ...(Array.isArray(configuredExternals) ? configuredExternals : [configuredExternals]), + ); + } + if (environment.name === 'workerSSR') { + const effectApiSourceDirectory = resolveEffectApiSourceDirectory(); + const configuredNode = config.node; + config.node = configuredNode === false || configuredNode === undefined ? {} : configuredNode; + Object.assign(config.node, { + __dirname: false, + __filename: false, + }); + config.plugins.push(...createWorkerSsrPlugins(rspack, effectApiSourceDirectory)); + } + }, + tsChecker: { + typescript: { + build: false, + }, + }, + }, + } satisfies AppToolsUserConfig, + { + appId, + deliveryUnit: { + buildMarker: 'd87a59b2fccc989f', + unitId: 'app/inventory', + version: '0.1.0', + }, + }, + ), +); diff --git a/app/verticals/inventory/module-federation.config.ts b/app/verticals/inventory/module-federation.config.ts new file mode 100644 index 000000000..2e477abe3 --- /dev/null +++ b/app/verticals/inventory/module-federation.config.ts @@ -0,0 +1,47 @@ +import { createRequire } from 'node:module'; + +import { resolveEffectTsgoCompiler } from '@modern-js/app-tools-extensions/config'; +import { createModuleFederationConfig } from '@module-federation/modern-js-v3'; +import { decodeUnknownSync, String as SchemaString, Struct } from 'effect/Schema'; + +import { createSharedRuntimeConfig } from '../../module-federation.shared.ts'; +import { dependencies } from './package.json'; + +const require = createRequire(import.meta.url); +const PackageVersionSchema = Struct({ version: SchemaString }); +const packageVersion = (specifier: string): string => + decodeUnknownSync(PackageVersionSchema)(require(specifier)).version; +const i18nVersion = packageVersion('@modern-js/plugin-i18n/package.json'); +const runtimeVersion = packageVersion('@modern-js/runtime/package.json'); +const reactVersion = packageVersion('react/package.json'); +const reactDomVersion = packageVersion('react-dom/package.json'); + +const tsgoCompilerInstance = resolveEffectTsgoCompiler({ from: import.meta.url }); + +const moduleFederationConfig: Parameters[0] = createModuleFederationConfig({ + bridge: { + enableBridgeRouter: false, + }, + dts: { + displayErrorInTerminal: true, + generateTypes: { + compilerInstance: tsgoCompilerInstance, + }, + tsConfigPath: './tsconfig.mf-types.json', + }, + exposes: { + './Route': './src/federation-entry.tsx', + './Widget': './src/components/inventory-widget.tsx', + }, + filename: 'remoteEntry.js', + name: 'verticalInventory', + shared: createSharedRuntimeConfig({ + '@modern-js/plugin-i18n/runtime': i18nVersion, + '@modern-js/runtime': runtimeVersion, + '@tanstack/react-router': dependencies['@tanstack/react-router'], + react: reactVersion, + 'react-dom': reactDomVersion, + }), +}); + +export default moduleFederationConfig; diff --git a/app/verticals/inventory/package.json b/app/verticals/inventory/package.json new file mode 100644 index 000000000..0564032a5 --- /dev/null +++ b/app/verticals/inventory/package.json @@ -0,0 +1,134 @@ +{ + "name": "@app/inventory", + "version": "0.1.0", + "private": true, + "type": "module", + "exports": { + "./api": "./shared/api.ts", + "./api/client": "./src/api/inventory-client.ts", + "./backend-configuration": "./shared/domain/inventory-backend-configuration.ts", + "./launch-scope": "./shared/inventory-launch-scope.ts", + "./outbox/commerce-inventory-commitment-protection-changed-v1": "./shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts", + "./outbox/commerce-inventory-commitment-protection-establishment-requested-v1": "./shared/outbox/commerce-inventory-commitment-protection-establishment-requested-v1.ts", + "./outbox/commerce-inventory-committed-obligation-changed-v1": "./shared/outbox/commerce-inventory-committed-obligation-changed-v1.ts", + "./outbox/commerce-inventory-inventory-reservation-create-requested-v1": "./shared/outbox/commerce-inventory-inventory-reservation-create-requested-v1.ts", + "./outbox/commerce-inventory-inventory-reservation-release-requested-v1": "./shared/outbox/commerce-inventory-inventory-reservation-release-requested-v1.ts", + "./outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1": "./shared/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1.ts", + "./outbox/commerce-inventory-reservation-guarantee-changed-v1": "./shared/outbox/commerce-inventory-reservation-guarantee-changed-v1.ts", + "./outbox/commerce-inventory-stock-issue-requested-v1": "./shared/outbox/commerce-inventory-stock-issue-requested-v1.ts", + "./outbox/commerce-inventory-stock-position-evidence-changed-v1": "./shared/outbox/commerce-inventory-stock-position-evidence-changed-v1.ts", + "./outbox/commerce-inventory-stock-receipt-requested-v1": "./shared/outbox/commerce-inventory-stock-receipt-requested-v1.ts", + "./outbox-worker-host": "./src/worker-host/entry.ts", + "./privacy-owner-contract": "./shared/inventory-privacy-owner-contract.ts", + "./permissions/inventory.audit.read": "./shared/permissions/inventory-audit-read.ts", + "./permissions/inventory.catalog_to_stock_binding.manage": "./shared/permissions/inventory-catalog-to-stock-binding-manage.ts", + "./permissions/inventory.commitment_protection.establish": "./shared/permissions/inventory-commitment-protection-establish.ts", + "./permissions/inventory.external_stock_correlation.manage": "./shared/permissions/inventory-external-stock-correlation-manage.ts", + "./permissions/inventory.migration.manage": "./shared/permissions/inventory-migration-manage.ts", + "./permissions/inventory.recovery.execute": "./shared/permissions/inventory-recovery-execute.ts", + "./permissions/inventory.reservation.establish": "./shared/permissions/inventory-reservation-establish.ts", + "./permissions/inventory.reservation.release": "./shared/permissions/inventory-reservation-release.ts", + "./permissions/inventory.resource.read": "./shared/permissions/inventory-resource-read.ts", + "./permissions/inventory.stock_sharing_eligibility.manage": "./shared/permissions/inventory-stock-sharing-eligibility-manage.ts", + "./permissions/inventory.stock.correct": "./shared/permissions/inventory-stock-correct.ts", + "./permissions/inventory.stock.issue": "./shared/permissions/inventory-stock-issue.ts", + "./permissions/inventory.stock.receipt": "./shared/permissions/inventory-stock-receipt.ts", + "./reservation-evidence-handoff": "./shared/domain/inventory-reservation-evidence-handoff.ts", + "./resources/catalog-to-stock-binding": "./shared/resources/catalog-to-stock-binding.ts", + "./resources/commitment-protection": "./shared/resources/commitment-protection.ts", + "./resources/external-stock-correlation": "./shared/resources/external-stock-correlation.ts", + "./resources/imported-committed-obligation": "./shared/resources/imported-committed-obligation.ts", + "./resources/inventory-backend-configuration": "./shared/resources/inventory-backend-configuration.ts", + "./resources/inventory-reservation": "./shared/resources/inventory-reservation.ts", + "./resources/inventory-source-conflict": "./shared/resources/inventory-source-conflict.ts", + "./resources/reservation-confirmation": "./shared/resources/reservation-confirmation.ts", + "./resources/stock-item": "./shared/resources/stock-item.ts", + "./resources/stock-location": "./shared/resources/stock-location.ts", + "./resources/stock-position": "./shared/resources/stock-position.ts", + "./resources/stock-sharing-eligibility": "./shared/resources/stock-sharing-eligibility.ts", + "./Route": "./src/federation-entry.tsx", + "./Widget": "./src/components/inventory-widget.tsx" + }, + "scripts": { + "build": "modern build && node ../../scripts/generate-ontos-module-contract.mts --vertical inventory --target dist && ultramodern-create ultramodern public-surface --app inventory --target dist && cross-env MODERNJS_DEPLOY=node modern deploy --skip-build", + "cloudflare:build": "cross-env MODERNJS_DEPLOY=cloudflare modern build && node ../../scripts/generate-ontos-module-contract.mts --vertical inventory --target cloudflare-dist && ultramodern-create ultramodern public-surface --app inventory --target cloudflare-dist && cross-env MODERNJS_DEPLOY=cloudflare modern deploy --skip-build && ultramodern-create ultramodern cloudflare-output-verify --app inventory", + "cloudflare:deploy": "cross-env ULTRAMODERN_CLOUDFLARE_REQUIRE_PUBLIC_URLS=true pnpm run cloudflare:build && wrangler deploy --config .output/wrangler.json", + "cloudflare:preview": "pnpm run cloudflare:build && wrangler dev --config .output/wrangler.json", + "cloudflare:proof": "ultramodern-create ultramodern cloudflare-proof --app inventory", + "db:check": "drizzle-kit check --config drizzle.config.ts", + "db:generate": "drizzle-kit generate --config drizzle.config.ts", + "db:migrate": "drizzle-kit migrate --config drizzle.config.ts", + "db:test": "rstest run tests/unit/database-schema-contract.test.ts --config rstest.config.ts", + "db:verify": "node scripts/verify-db-schema.mts", + "dev": "modern dev", + "serve": "modern serve", + "test:integration": "rstest --project integration", + "test:unit": "rstest --project unit", + "typecheck": "ultramodern-create ultramodern typecheck --project tsconfig.json", + "worker:start": "node --experimental-strip-types ./src/worker-host/main.ts" + }, + "dependencies": { + "@app/catalog": "workspace:*", + "@app/core-runtime": "workspace:*", + "@app/gateway-principal-verifier": "workspace:*", + "@app/shared-contracts": "workspace:*", + "@app/shared-design-tokens": "workspace:*", + "@effect/opentelemetry": "4.0.0-rc.117", + "@effect/sql-pg": "4.0.0-rc.117", + "@modern-js/bff-effect": "catalog:ultramodern", + "@modern-js/federation-runtime": "catalog:ultramodern", + "@modern-js/i18n-integration": "catalog:ultramodern", + "@modern-js/plugin-bff": "catalog:ultramodern", + "@modern-js/plugin-bff-extensions": "catalog:ultramodern", + "@modern-js/plugin-i18n": "catalog:ultramodern", + "@modern-js/plugin-tanstack": "catalog:ultramodern", + "@modern-js/runtime": "catalog:ultramodern", + "@modern-js/runtime-extensions": "catalog:ultramodern", + "@modern-js/runtime-renderer-extensions": "catalog:ultramodern", + "@module-federation/modern-js-v3": "npm:@bleedingdev/mf-modern-js-v3@2.9.3", + "@module-federation/runtime": "npm:@bleedingdev/mf-runtime@2.9.2", + "@tanstack/react-router": "1.170.39", + "drizzle-orm": "1.0.0-rc.5-ab785fc", + "effect": "4.0.0-rc.117", + "i18next": "26.4.2", + "pg": "8.22.0", + "react": "19.2.8", + "react-dom": "19.2.8" + }, + "devDependencies": { + "@effect/tsgo": "0.41.0", + "@modern-js/app-tools": "catalog:ultramodern", + "@modern-js/app-tools-extensions": "catalog:ultramodern", + "@modern-js/plugin-bff-build-extensions": "catalog:ultramodern", + "@modern-js/ultramodern-app-tools": "catalog:ultramodern", + "@rsbuild/plugin-tailwindcss": "^2.0.3", + "@rstest/core": "0.11.12", + "@types/node": "^26.4.1", + "@types/pg": "8.20.0", + "@types/react": "^19.2.18", + "@types/react-dom": "^19.2.7", + "@typescript/native": "npm:typescript@7.0.2", + "cross-env": "10.1.0", + "drizzle-kit": "1.0.0-rc.5-ab785fc", + "effect-rstest": "https://pkg.pr.new/ScriptedAlchemy/effect-rstest@cbbf87e05c7517a85eb412d33421cd2ab5234597", + "tailwindcss": "^4.3.3", + "typescript": "7.0.2", + "wrangler": "4.137.0", + "zephyr-rspack-plugin": "1.2.4" + }, + "modernjs": { + "preset": "presetUltramodern", + "role": "module-federation-remote", + "appId": "inventory", + "topology": "../../topology/reference-topology.json", + "apiRuntime": "effect", + "ontosModule": { + "contractPath": "/.well-known/ontos-module-manifest.json", + "manifest": "./vertical.manifest.ts", + "moduleId": "commerce.inventory", + "registration": "./vertical.registration.ts", + "schemaVersion": 2 + } + }, + "zephyr:dependencies": {} +} diff --git a/app/verticals/inventory/rstest.config.ts b/app/verticals/inventory/rstest.config.ts new file mode 100644 index 000000000..ee388fc69 --- /dev/null +++ b/app/verticals/inventory/rstest.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from '@rstest/core'; + +const swc = { + jsc: { parser: { disallowAmbiguousJsxLike: false, syntax: 'typescript' } }, +} as const; + +export default defineConfig({ + projects: [ + { + include: ['tests/integration/**/*.test.ts'], + name: 'integration', + root: new URL('.', import.meta.url).pathname, + testEnvironment: 'node', + testTimeout: 30_000, + tools: { swc }, + }, + { + include: ['tests/unit/**/*.test.ts'], + name: 'unit', + root: new URL('.', import.meta.url).pathname, + testEnvironment: 'node', + tools: { swc }, + }, + ], + root: new URL('.', import.meta.url).pathname, +}); diff --git a/app/verticals/inventory/scripts/verify-db-schema.mts b/app/verticals/inventory/scripts/verify-db-schema.mts new file mode 100644 index 000000000..0110c8cb0 --- /dev/null +++ b/app/verticals/inventory/scripts/verify-db-schema.mts @@ -0,0 +1,243 @@ +// @effect-diagnostics globalConsole:off strictEffectProvide:off -- Operator verifier is an executable boundary; expires: 2027-03-31. +import { DatabaseConfig, loadDatabaseConnectionPair } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { getTableConfig } from 'drizzle-orm/pg-core'; +import { Array as EffectArray, Effect, Layer, Order, Schema } from 'effect'; + +import { compareInventoryCatalog } from '../src/database/catalog.ts'; +import { InventoryDatabase, InventoryDatabaseLive } from '../src/database/client.ts'; +import { INVENTORY_SCHEMA_NAME, INVENTORY_TABLES } from '../src/database/schema.ts'; + +class VerificationError extends Schema.TaggedError()('InventoryVerificationError', { + reason: Schema.String, +}) {} + +interface TableRow extends Readonly> { + readonly table_name: string; +} + +interface ColumnRow extends Readonly> { + readonly column_name: string; + readonly table_name: string; +} + +interface InfrastructureRow extends Readonly> { + readonly commitment_protection_trigger_count: number; + readonly effect_ledger_contract_current: boolean; + readonly force_rls_count: number; + readonly journal_count: number; + readonly policy_count: number; + readonly private_trigger_function_executable: boolean; + readonly required_index_count: number; + readonly required_trigger_count: number; + readonly role_bypass_rls: boolean; + readonly role_super: boolean; + readonly runtime_create: boolean; + readonly runtime_delete_count: number; + readonly runtime_insert_count: number; + readonly runtime_select_count: number; + readonly runtime_update_count: number; + readonly runtime_usage: boolean; + readonly table_count: number; + readonly worker_routines_executable: boolean; + readonly wrong_owner_count: number; +} + +const expectedColumns = EffectArray.sort( + INVENTORY_TABLES.flatMap((table) => { + const config = getTableConfig(table); + return config.columns.map((column) => `${config.name}.${column.name}`); + }), + Order.String, +); +const effectLedgerClaimSignature = 'inventory.claim_inventory_effect_ledger(uuid,uuid,text,jsonb)'; +const effectLedgerExactScopeSignature = 'inventory.enforce_effect_ledger_exact_scope()'; +const reservedProtectionKind = 'ESTABLISH_COMMITMENT_PROTECTION'; +const unsupportedCorrectionKind = 'STOCK_CORRECTION'; + +// oxlint-disable-next-line complexity -- One operator report exact-matches the complete owner catalog and its security posture; expires: 2027-03-31. +const verification = Effect.gen(function* verifyDatabase() { + const connections = yield* loadDatabaseConnectionPair(); + const database = yield* InventoryDatabase; + for (const table of INVENTORY_TABLES) { + yield* database.executor + .select() + .from(table) + .limit(0) + .pipe(Effect.mapError(() => new VerificationError({ reason: 'Typed Inventory table verification failed' }))); + } + + const catalog = yield* database.executor.execute( + sql`select relation.relname as table_name from pg_catalog.pg_class relation + join pg_catalog.pg_namespace namespace on namespace.oid = relation.relnamespace + where namespace.nspname = ${INVENTORY_SCHEMA_NAME} and relation.relkind in (${'r'}, ${'p'}) + order by relation.relname`, + 'objects', + ); + const difference = compareInventoryCatalog(catalog.map(({ table_name }) => `${INVENTORY_SCHEMA_NAME}.${table_name}`)); + if (difference.missing.length > 0 || difference.unexpected.length > 0) { + return yield* new VerificationError({ + reason: `Inventory mismatch; missing=[${difference.missing.join(', ')}], unexpected=[${difference.unexpected.join(', ')}]`, + }); + } + + const columns = yield* database.executor.execute( + sql`select table_name, column_name from information_schema.columns + where table_schema = ${INVENTORY_SCHEMA_NAME} order by table_name, column_name`, + 'objects', + ); + const actualColumns = EffectArray.sort( + columns.map(({ column_name, table_name }) => `${table_name}.${column_name}`), + Order.String, + ); + if ( + actualColumns.length !== expectedColumns.length || + actualColumns.some((column, index) => column !== expectedColumns[index]) + ) { + return yield* new VerificationError({ reason: 'Inventory column inventory mismatch' }); + } + + const [infrastructure] = yield* database.executor.execute( + sql`select + count(distinct relation.oid)::integer as table_count, + count(distinct relation.oid) filter (where relation.relrowsecurity and relation.relforcerowsecurity)::integer as force_rls_count, + count(distinct relation.oid) filter (where pg_catalog.pg_get_userbyid(relation.relowner) <> ${connections.admin.user})::integer as wrong_owner_count, + coalesce((select pg_catalog.pg_get_constraintdef(constraint_record.oid) like ${`%${reservedProtectionKind}%`} and pg_catalog.pg_get_constraintdef(constraint_record.oid) not like ${`%${unsupportedCorrectionKind}%`} from pg_catalog.pg_constraint constraint_record join pg_catalog.pg_class governed on governed.oid = constraint_record.conrelid join pg_catalog.pg_namespace ns on ns.oid = governed.relnamespace where ns.nspname = ${INVENTORY_SCHEMA_NAME} and governed.relname = ${'effect_ledger'} and constraint_record.conname = ${'inventory_effect_ledger_kind_ck'}), false) + and pg_catalog.pg_get_functiondef(pg_catalog.to_regprocedure(${effectLedgerExactScopeSignature})) like ${`%${reservedProtectionKind}%`} + and pg_catalog.pg_get_functiondef(pg_catalog.to_regprocedure(${effectLedgerExactScopeSignature})) not like ${`%${unsupportedCorrectionKind}%`} + and pg_catalog.pg_get_functiondef(pg_catalog.to_regprocedure(${effectLedgerClaimSignature})) like ${`%${reservedProtectionKind}%`} + and pg_catalog.pg_get_functiondef(pg_catalog.to_regprocedure(${effectLedgerClaimSignature})) not like ${`%${unsupportedCorrectionKind}%`} as effect_ledger_contract_current, + (select count(*)::integer from pg_catalog.pg_policy policy join pg_catalog.pg_class governed on governed.oid = policy.polrelid join pg_catalog.pg_namespace ns on ns.oid = governed.relnamespace where ns.nspname = ${INVENTORY_SCHEMA_NAME}) as policy_count, + (select count(*)::integer + from pg_catalog.pg_index index_record + join pg_catalog.pg_class index_relation on index_relation.oid = index_record.indexrelid + join pg_catalog.pg_namespace index_namespace on index_namespace.oid = index_relation.relnamespace + where index_namespace.nspname = ${INVENTORY_SCHEMA_NAME} + and index_relation.relname = ${'inventory_obligations_runtime_accepted_order_uk'} + and index_record.indisunique + and pg_catalog.pg_get_indexdef(index_record.indexrelid) like ${'%(tenant_id, accepted_order_id)%'} + and pg_catalog.pg_get_indexdef(index_record.indexrelid) like ${"%WHERE ((origin_kind = 'ORDER_COMMITMENT_ATTEMPT'::text) AND (lifecycle_meaning = 'COMMITTED_OBLIGATION'::text))%"}) as required_index_count, + (select count(*)::integer from pg_catalog.pg_trigger trigger_record join pg_catalog.pg_class triggered on triggered.oid = trigger_record.tgrelid join pg_catalog.pg_namespace ns on ns.oid = triggered.relnamespace where ns.nspname = ${INVENTORY_SCHEMA_NAME} and trigger_record.tgname in (${'inventory_backend_configurations_explicit_cutover_trg'}, ${'inventory_catalog_to_stock_binding_history_no_delete_trg'}, ${'inventory_catalog_to_stock_binding_history_no_update_trg'}, ${'inventory_catalog_to_stock_bindings_compatibility_trg'}, ${'inventory_effect_ledger_exact_scope_trg'}, ${'inventory_effect_ledger_history_no_delete_trg'}, ${'inventory_effect_ledger_history_no_update_trg'}, ${'inventory_effect_ledger_history_scope_trg'}, ${'inventory_effect_ledger_transition_trg'}, ${'inventory_external_stock_correlations_immutable_identity_trg'}, ${'inventory_external_stock_correlations_no_delete_trg'}, ${'inventory_external_stock_correlations_nonoverlap_trg'}, ${'inventory_obligation_allocations_append_only_trg'}, ${'inventory_obligation_allocations_exact_coverage_trg'}, ${'inventory_obligation_allocations_exact_scope_trg'}, ${'inventory_obligation_requirements_append_only_trg'}, ${'inventory_obligation_requirements_exact_coverage_trg'}, ${'inventory_obligation_requirements_exact_scope_trg'}, ${'inventory_obligations_exact_authority_trg'}, ${'inventory_obligations_immutable_origin_trg'}, ${'inventory_physical_stock_effects_exact_scope_trg'}, ${'inventory_physical_stock_effects_immutable_identity_trg'}, ${'inventory_reservation_confirmation_history_no_delete_trg'}, ${'inventory_reservation_confirmation_history_no_update_trg'}, ${'inventory_reservation_confirmation_history_scope_trg'}, ${'inventory_reservation_confirmations_lifecycle_trg'}, ${'inventory_reservation_confirmations_scope_trg'}, ${'inventory_reservation_create_effects_transition_trg'}, ${'inventory_reservation_release_effect_history_no_delete_trg'}, ${'inventory_reservation_release_effect_history_no_update_trg'}, ${'inventory_reservation_release_effect_history_scope_trg'}, ${'inventory_reservation_release_effects_scope_trg'}, ${'inventory_reservation_release_effects_transition_trg'}, ${'inventory_reservation_shortage_impact_decisions_decision_set_trg'}, ${'inventory_reservation_shortage_impact_decisions_exact_scope_trg'}, ${'inventory_reservation_shortage_impact_decisions_no_mutation_trg'}, ${'inventory_reservation_shortage_impacts_decision_set_trg'}, ${'inventory_reservation_shortage_impacts_source_trg'}, ${'inventory_reservation_shortage_impacts_no_mutation_trg'}, ${'inventory_source_assertion_coverage_complete_trg'}, ${'inventory_source_assertion_coverage_exact_scope_trg'}, ${'inventory_source_assertion_coverage_immutable_trg'}, ${'inventory_source_assertions_exact_scope_trg'}, ${'inventory_source_assertions_immutable_trg'}, ${'inventory_source_conflict_revisions_exact_scope_trg'}, ${'inventory_source_conflict_revisions_immutable_trg'}, ${'inventory_source_conflict_revisions_sequence_trg'}, ${'inventory_source_import_ledger_exact_scope_trg'}, ${'inventory_source_import_ledger_immutable_trg'}, ${'inventory_stock_correction_open_transition_trg'}, ${'inventory_stock_correction_source_evidence_coverage_complete_trg'}, ${'inventory_stock_correction_source_evidence_coverage_exact_scope_trg'}, ${'inventory_stock_correction_source_evidence_coverage_immutable_trg'}, ${'inventory_stock_correction_source_evidence_current_transition_trg'}, ${'inventory_stock_correction_source_evidence_exact_scope_trg'}, ${'inventory_stock_correction_source_evidence_immutable_trg'}, ${'inventory_stock_corrections_exact_scope_trg'}, ${'inventory_stock_corrections_immutable_trg'}, ${'inventory_stock_items_current_binding_target_trg'}, ${'inventory_stock_items_immutable_meaning_trg'}, ${'inventory_stock_locations_immutable_identity_trg'}, ${'inventory_stock_location_revisions_append_only_trg'}, ${'inventory_stock_positions_exact_item_unit_trg'}, ${'inventory_stock_positions_immutable_scope_trg'}, ${'inventory_stock_positions_owner_configuration_trg'}, ${'inventory_stock_sharing_eligibilities_immutable_identity_trg'}, ${'inventory_stock_sharing_eligibilities_scope_trg'}, ${'inventory_stock_sharing_eligibility_history_no_delete_trg'}, ${'inventory_stock_sharing_eligibility_history_no_update_trg'}) and not trigger_record.tgisinternal) as required_trigger_count, + (select count(*)::integer from pg_catalog.pg_trigger trigger_record join pg_catalog.pg_class triggered on triggered.oid = trigger_record.tgrelid join pg_catalog.pg_namespace ns on ns.oid = triggered.relnamespace where ns.nspname = ${INVENTORY_SCHEMA_NAME} and trigger_record.tgname in (${'inventory_commitment_protection_history_no_delete_trg'}, ${'inventory_commitment_protection_history_no_update_trg'}, ${'inventory_commitment_protection_history_scope_trg'}, ${'inventory_commitment_protections_lifecycle_trg'}, ${'inventory_commitment_protections_scope_trg'}) and not trigger_record.tgisinternal) as commitment_protection_trigger_count, + (select count(*)::integer from pg_catalog.pg_class journal join pg_catalog.pg_namespace ns on ns.oid = journal.relnamespace where ns.nspname = ${'drizzle'} and journal.relname = ${'__drizzle_migrations_inventory'}) as journal_count, + has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_backend_configuration_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_catalog_to_stock_binding_compatibility()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_catalog_to_stock_binding_history_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_commitment_protection_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_commitment_protection_lifecycle()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_commitment_protection_history_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_commitment_protection_history_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_effect_ledger_exact_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_effect_ledger_history_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_effect_ledger_transition()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_effect_ledger_history_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_external_stock_correlation_nonoverlap()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_external_stock_correlation_identity_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_obligation_allocation_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_obligation_authority()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_obligation_requirement_coverage()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_obligation_requirement_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_obligation_allocation_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_obligation_origin_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_obligation_requirement_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_physical_stock_effect_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_physical_stock_effect_identity_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_create_effect_transition()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_confirmation_history_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_confirmation_lifecycle()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_confirmation_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_reservation_confirmation_history_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_release_effect_history_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_release_effect_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_release_effect_transition()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_reservation_release_effect_history_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_reservation_shortage_impact_source()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.verify_reservation_shortage_impact_decisions()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_reservation_shortage_impact_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_source_assertion_exact_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_source_assertion_coverage_complete()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_source_assertion_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_source_conflict_exact_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_source_conflict_revision()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_source_import_ledger_exact_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_source_import_ledger_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_correction_exact_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_correction_open_transition()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_correction_source_evidence_coverage_complete()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_correction_source_evidence_current_transition()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_correction_source_evidence_exact_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_correction_source_evidence_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_correction_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_position_stock_item_unit()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_position_owner_configuration()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.protect_current_catalog_to_stock_binding_target()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_item_meaning_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_location_identity_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_location_revision_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_position_scope_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.enforce_stock_sharing_eligibility_scope()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_sharing_eligibility_identity_mutation()'}, ${'EXECUTE'}) + or has_function_privilege(${'ontos_runtime'}, ${'inventory.reject_stock_sharing_eligibility_history_mutation()'}, ${'EXECUTE'}) as private_trigger_function_executable, + has_function_privilege(${'ontos_runtime'}, ${'inventory.read_physical_stock_effect_for_worker(uuid,uuid,uuid)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.finalize_physical_stock_effect_for_worker(uuid,uuid,uuid,jsonb)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.read_reservation_create_effect_for_worker(uuid,uuid,text)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.finalize_reservation_create_effect_for_worker(uuid,uuid,text,jsonb)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.find_reservation_shortage_impact_for_worker(uuid,uuid,text,uuid)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.read_reservation_shortage_impact_context_for_worker(uuid,uuid,text,uuid,uuid,timestamptz)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.apply_reservation_shortage_impact_for_worker(uuid,uuid,text,uuid,uuid,timestamptz,jsonb)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.read_reservation_release_effect_for_worker(uuid,uuid,text)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.finalize_reservation_release_effect_for_worker(uuid,uuid,text,integer,jsonb)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.claim_inventory_effect_ledger(uuid,uuid,text,jsonb)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.read_inventory_effect_ledger_for_worker(uuid,uuid,text)'}, ${'EXECUTE'}) + and has_function_privilege(${'ontos_runtime'}, ${'inventory.transition_inventory_effect_ledger_for_worker(uuid,uuid,text,integer,text,jsonb)'}, ${'EXECUTE'}) as worker_routines_executable, + has_schema_privilege(${'ontos_runtime'}, ${INVENTORY_SCHEMA_NAME}, ${'CREATE'}) as runtime_create, + has_schema_privilege(${'ontos_runtime'}, ${INVENTORY_SCHEMA_NAME}, ${'USAGE'}) as runtime_usage, + count(distinct relation.oid) filter (where has_table_privilege(${'ontos_runtime'}, relation.oid, ${'SELECT'}))::integer as runtime_select_count, + count(distinct relation.oid) filter (where has_table_privilege(${'ontos_runtime'}, relation.oid, ${'INSERT'}))::integer as runtime_insert_count, + count(distinct relation.oid) filter (where has_table_privilege(${'ontos_runtime'}, relation.oid, ${'UPDATE'}))::integer as runtime_update_count, + count(distinct relation.oid) filter (where has_table_privilege(${'ontos_runtime'}, relation.oid, ${'DELETE'}))::integer as runtime_delete_count, + runtime_role.rolsuper as role_super, + runtime_role.rolbypassrls as role_bypass_rls + from pg_catalog.pg_class relation + join pg_catalog.pg_namespace namespace on namespace.oid = relation.relnamespace + cross join pg_catalog.pg_roles runtime_role + where namespace.nspname = ${INVENTORY_SCHEMA_NAME} + and relation.relkind in (${'r'}, ${'p'}) + and runtime_role.rolname = ${'ontos_runtime'} + group by runtime_role.rolsuper, runtime_role.rolbypassrls`, + 'objects', + ); + if ( + infrastructure === undefined || + !infrastructure.effect_ledger_contract_current || + infrastructure.table_count !== INVENTORY_TABLES.length || + infrastructure.force_rls_count !== INVENTORY_TABLES.length || + infrastructure.wrong_owner_count !== 0 || + infrastructure.policy_count !== INVENTORY_TABLES.length * 4 || + infrastructure.required_index_count !== 1 || + infrastructure.required_trigger_count !== 69 || + infrastructure.commitment_protection_trigger_count !== 5 || + infrastructure.journal_count !== 1 || + infrastructure.private_trigger_function_executable || + !infrastructure.worker_routines_executable || + infrastructure.runtime_create || + !infrastructure.runtime_usage || + infrastructure.runtime_select_count !== INVENTORY_TABLES.length || + infrastructure.runtime_insert_count !== INVENTORY_TABLES.length || + infrastructure.runtime_update_count !== INVENTORY_TABLES.length || + infrastructure.runtime_delete_count !== INVENTORY_TABLES.length || + infrastructure.role_super || + infrastructure.role_bypass_rls + ) { + return yield* new VerificationError({ + reason: 'Inventory ownership, RLS, trigger, journal, or runtime-role verification failed', + }); + } + return { typedTableCount: INVENTORY_TABLES.length }; +}); + +const runtime = InventoryDatabaseLive.pipe( + Layer.provide(Layer.effect(DatabaseConfig, loadDatabaseConnectionPair().pipe(Effect.map(({ admin }) => admin)))), +); +const result = await Effect.runPromise(Effect.provide(verification, runtime)); +console.log(`Verified ${result.typedTableCount} typed tables in PostgreSQL schema ${INVENTORY_SCHEMA_NAME}`); diff --git a/app/verticals/inventory/shared/actions/change-stock-sharing-eligibility.ts b/app/verticals/inventory/shared/actions/change-stock-sharing-eligibility.ts new file mode 100644 index 000000000..6c2cbb263 --- /dev/null +++ b/app/verticals/inventory/shared/actions/change-stock-sharing-eligibility.ts @@ -0,0 +1,16 @@ +import { Schema } from 'effect'; + +import { + ChangeStockSharingEligibilityInputSchema, + StockSharingEligibilitySchema, +} from '../domain/stock-sharing-eligibility.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +export const ChangeStockSharingEligibilityPayloadSchema = Schema.Struct({ + ...ChangeStockSharingEligibilityInputSchema.fields, + positionRef: StockPositionRefSchema, +}); +export type ChangeStockSharingEligibilityPayload = typeof ChangeStockSharingEligibilityPayloadSchema.Type; + +export const ChangeStockSharingEligibilityResultSchema = StockSharingEligibilitySchema; +export type ChangeStockSharingEligibilityResult = typeof ChangeStockSharingEligibilityResultSchema.Type; diff --git a/app/verticals/inventory/shared/actions/compensate-inventory-pre-commit.ts b/app/verticals/inventory/shared/actions/compensate-inventory-pre-commit.ts new file mode 100644 index 000000000..265198333 --- /dev/null +++ b/app/verticals/inventory/shared/actions/compensate-inventory-pre-commit.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + CompensateInventoryPreCommitErrorSchema as ErrorSchema, + CompensateInventoryPreCommitPayloadSchema as PayloadSchema, + CompensateInventoryPreCommitResultSchema as ResultSchema, +} from '../domain/inventory-pre-commit-compensation.ts'; + +export const CompensateInventoryPreCommitErrorSchema = ErrorSchema; +export const CompensateInventoryPreCommitPayloadSchema = PayloadSchema; +export const CompensateInventoryPreCommitResultSchema = ResultSchema; +export type { CompensateInventoryPreCommitPayload } from '../domain/inventory-pre-commit-compensation.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/correct-catalog-to-stock-binding.ts b/app/verticals/inventory/shared/actions/correct-catalog-to-stock-binding.ts new file mode 100644 index 000000000..58a7f274c --- /dev/null +++ b/app/verticals/inventory/shared/actions/correct-catalog-to-stock-binding.ts @@ -0,0 +1,28 @@ +import { Schema } from 'effect'; + +import { CatalogToStockBindingUnavailable } from '../domain/catalog-to-stock-binding-unavailable.ts'; +import { + CatalogToStockBindingCorrectionInputSchema, + CatalogToStockBindingRejected, +} from '../domain/catalog-to-stock-binding.ts'; +import { CatalogToStockBindingRefSchema } from '../resources/catalog-to-stock-binding.ts'; + +export { CatalogToStockBindingSchema as CorrectCatalogToStockBindingResultSchema } from '../domain/catalog-to-stock-binding.ts'; + +export const CorrectCatalogToStockBindingPayloadSchema = Schema.Struct({ + bindingRef: CatalogToStockBindingRefSchema, + candidate: CatalogToStockBindingCorrectionInputSchema.fields.candidate, + evidence: CatalogToStockBindingCorrectionInputSchema.fields.evidence, +}).check( + Schema.makeFilter(({ bindingRef, candidate }) => + bindingRef.tenantId === candidate.catalogSelection.productRef.tenantId + ? undefined + : 'Binding and exact Catalog Selection must share one Tenant', + ), +); +export type CorrectCatalogToStockBindingPayload = typeof CorrectCatalogToStockBindingPayloadSchema.Type; + +export const CorrectCatalogToStockBindingErrorSchema = Schema.Union([ + CatalogToStockBindingRejected, + CatalogToStockBindingUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/correct-external-stock-correlation.ts b/app/verticals/inventory/shared/actions/correct-external-stock-correlation.ts new file mode 100644 index 000000000..dfae7fc45 --- /dev/null +++ b/app/verticals/inventory/shared/actions/correct-external-stock-correlation.ts @@ -0,0 +1,24 @@ +import { Schema } from 'effect'; + +import { + CorrectExternalStockCorrelationInputSchema, + ExternalStockCorrelationSchema, +} from '../domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationPersistenceUnavailable } from '../domain/external-stock-correlation-persistence-unavailable.ts'; +import { ExternalStockCorrelationRejected } from '../domain/external-stock-correlation-rejected.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; + +export const CorrectExternalStockCorrelationPayloadSchema = Schema.Struct({ + ...CorrectExternalStockCorrelationInputSchema.fields, + replacementCorrelationRef: ExternalStockCorrelationRefSchema, +}); +export type CorrectExternalStockCorrelationPayload = typeof CorrectExternalStockCorrelationPayloadSchema.Type; + +export const CorrectExternalStockCorrelationResultSchema = Schema.Struct({ + correlation: ExternalStockCorrelationSchema, +}); + +export const CorrectExternalStockCorrelationErrorSchema = Schema.Union([ + ExternalStockCorrelationRejected, + ExternalStockCorrelationPersistenceUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/correct-stock-position.ts b/app/verticals/inventory/shared/actions/correct-stock-position.ts new file mode 100644 index 000000000..f3ac8ac7a --- /dev/null +++ b/app/verticals/inventory/shared/actions/correct-stock-position.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + StockCorrectionErrorSchema, + StockCorrectionPayloadSchema, + StockCorrectionResultSchema, +} from '../domain/stock-correction.ts'; + +export const CorrectStockPositionErrorSchema = StockCorrectionErrorSchema; +export const CorrectStockPositionPayloadSchema = StockCorrectionPayloadSchema; +export const CorrectStockPositionResultSchema = StockCorrectionResultSchema; +export type { StockCorrectionPayload as CorrectStockPositionPayload } from '../domain/stock-correction.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/create-inventory-reservation.ts b/app/verticals/inventory/shared/actions/create-inventory-reservation.ts new file mode 100644 index 000000000..fa85c6ed3 --- /dev/null +++ b/app/verticals/inventory/shared/actions/create-inventory-reservation.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + CreateInventoryReservationErrorSchema as ErrorSchema, + CreateInventoryReservationPayloadSchema as PayloadSchema, + CreateInventoryReservationResultSchema as ResultSchema, +} from '../domain/inventory-reservation-create.ts'; + +export const CreateInventoryReservationErrorSchema = ErrorSchema; +export const CreateInventoryReservationPayloadSchema = PayloadSchema; +export const CreateInventoryReservationResultSchema = ResultSchema; +export type { CreateInventoryReservationPayload } from '../domain/inventory-reservation-create.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/end-catalog-to-stock-binding.ts b/app/verticals/inventory/shared/actions/end-catalog-to-stock-binding.ts new file mode 100644 index 000000000..c9968b9f1 --- /dev/null +++ b/app/verticals/inventory/shared/actions/end-catalog-to-stock-binding.ts @@ -0,0 +1,17 @@ +import { Schema } from 'effect'; + +import { CatalogToStockBindingUnavailable } from '../domain/catalog-to-stock-binding-unavailable.ts'; +import { + CatalogToStockBindingEndInputSchema, + CatalogToStockBindingRejected, +} from '../domain/catalog-to-stock-binding.ts'; + +export { CatalogToStockBindingEndResultSchema as EndCatalogToStockBindingResultSchema } from '../domain/catalog-to-stock-binding.ts'; + +export const EndCatalogToStockBindingPayloadSchema = CatalogToStockBindingEndInputSchema; +export type EndCatalogToStockBindingPayload = typeof EndCatalogToStockBindingPayloadSchema.Type; + +export const EndCatalogToStockBindingErrorSchema = Schema.Union([ + CatalogToStockBindingRejected, + CatalogToStockBindingUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/end-external-stock-correlation.ts b/app/verticals/inventory/shared/actions/end-external-stock-correlation.ts new file mode 100644 index 000000000..ca9c779d9 --- /dev/null +++ b/app/verticals/inventory/shared/actions/end-external-stock-correlation.ts @@ -0,0 +1,24 @@ +import { Schema } from 'effect'; + +import { + EndExternalStockCorrelationInputSchema, + ExternalStockCorrelationSchema, +} from '../domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationPersistenceUnavailable } from '../domain/external-stock-correlation-persistence-unavailable.ts'; +import { ExternalStockCorrelationRejected } from '../domain/external-stock-correlation-rejected.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; + +export const EndExternalStockCorrelationPayloadSchema = Schema.Struct({ + correlationRef: ExternalStockCorrelationRefSchema, + ...EndExternalStockCorrelationInputSchema.fields, +}); +export type EndExternalStockCorrelationPayload = typeof EndExternalStockCorrelationPayloadSchema.Type; + +export const EndExternalStockCorrelationResultSchema = Schema.Struct({ + correlation: ExternalStockCorrelationSchema, +}); + +export const EndExternalStockCorrelationErrorSchema = Schema.Union([ + ExternalStockCorrelationRejected, + ExternalStockCorrelationPersistenceUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/end-stock-sharing-eligibility.ts b/app/verticals/inventory/shared/actions/end-stock-sharing-eligibility.ts new file mode 100644 index 000000000..fb7f6228c --- /dev/null +++ b/app/verticals/inventory/shared/actions/end-stock-sharing-eligibility.ts @@ -0,0 +1,16 @@ +import { Schema } from 'effect'; + +import { + EndStockSharingEligibilityInputSchema, + StockSharingEligibilitySchema, +} from '../domain/stock-sharing-eligibility.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +export const EndStockSharingEligibilityPayloadSchema = Schema.Struct({ + ...EndStockSharingEligibilityInputSchema.fields, + positionRef: StockPositionRefSchema, +}); +export type EndStockSharingEligibilityPayload = typeof EndStockSharingEligibilityPayloadSchema.Type; + +export const EndStockSharingEligibilityResultSchema = StockSharingEligibilitySchema; +export type EndStockSharingEligibilityResult = typeof EndStockSharingEligibilityResultSchema.Type; diff --git a/app/verticals/inventory/shared/actions/establish-catalog-to-stock-binding.ts b/app/verticals/inventory/shared/actions/establish-catalog-to-stock-binding.ts new file mode 100644 index 000000000..1a996c5f3 --- /dev/null +++ b/app/verticals/inventory/shared/actions/establish-catalog-to-stock-binding.ts @@ -0,0 +1,29 @@ +import { Schema } from 'effect'; + +import { CatalogToStockBindingUnavailable } from '../domain/catalog-to-stock-binding-unavailable.ts'; +import { + CatalogToStockBindingCandidateSchema, + CatalogToStockBindingLifecycleEvidenceSchema, + CatalogToStockBindingRejected, +} from '../domain/catalog-to-stock-binding.ts'; +import { CatalogToStockBindingRefSchema } from '../resources/catalog-to-stock-binding.ts'; + +export { CatalogToStockBindingSchema as EstablishCatalogToStockBindingResultSchema } from '../domain/catalog-to-stock-binding.ts'; + +export const EstablishCatalogToStockBindingPayloadSchema = Schema.Struct({ + bindingRef: CatalogToStockBindingRefSchema, + candidate: CatalogToStockBindingCandidateSchema, + evidence: CatalogToStockBindingLifecycleEvidenceSchema, +}).check( + Schema.makeFilter(({ bindingRef, candidate }) => + bindingRef.tenantId === candidate.catalogSelection.productRef.tenantId + ? undefined + : 'Proposed binding and exact Catalog Selection must share one Tenant', + ), +); +export type EstablishCatalogToStockBindingPayload = typeof EstablishCatalogToStockBindingPayloadSchema.Type; + +export const EstablishCatalogToStockBindingErrorSchema = Schema.Union([ + CatalogToStockBindingRejected, + CatalogToStockBindingUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/establish-commitment-protection.ts b/app/verticals/inventory/shared/actions/establish-commitment-protection.ts new file mode 100644 index 000000000..11a689e24 --- /dev/null +++ b/app/verticals/inventory/shared/actions/establish-commitment-protection.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + EstablishCommitmentProtectionErrorSchema as ErrorSchema, + EstablishCommitmentProtectionPayloadSchema as PayloadSchema, + EstablishCommitmentProtectionResultSchema as ResultSchema, +} from '../domain/commitment-protection.ts'; + +export const EstablishCommitmentProtectionErrorSchema = ErrorSchema; +export const EstablishCommitmentProtectionPayloadSchema = PayloadSchema; +export const EstablishCommitmentProtectionResultSchema = ResultSchema; +export type { EstablishCommitmentProtectionPayload } from '../domain/commitment-protection.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/establish-external-stock-correlation.ts b/app/verticals/inventory/shared/actions/establish-external-stock-correlation.ts new file mode 100644 index 000000000..391246c24 --- /dev/null +++ b/app/verticals/inventory/shared/actions/establish-external-stock-correlation.ts @@ -0,0 +1,24 @@ +import { Schema } from 'effect'; + +import { + EstablishExternalStockCorrelationInputSchema, + ExternalStockCorrelationSchema, +} from '../domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationPersistenceUnavailable } from '../domain/external-stock-correlation-persistence-unavailable.ts'; +import { ExternalStockCorrelationRejected } from '../domain/external-stock-correlation-rejected.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; + +export const EstablishExternalStockCorrelationPayloadSchema = Schema.Struct({ + correlationRef: ExternalStockCorrelationRefSchema, + ...EstablishExternalStockCorrelationInputSchema.fields, +}); +export type EstablishExternalStockCorrelationPayload = typeof EstablishExternalStockCorrelationPayloadSchema.Type; + +export const EstablishExternalStockCorrelationResultSchema = Schema.Struct({ + correlation: ExternalStockCorrelationSchema, +}); + +export const EstablishExternalStockCorrelationErrorSchema = Schema.Union([ + ExternalStockCorrelationRejected, + ExternalStockCorrelationPersistenceUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/establish-stock-sharing-eligibility.ts b/app/verticals/inventory/shared/actions/establish-stock-sharing-eligibility.ts new file mode 100644 index 000000000..f994c2d43 --- /dev/null +++ b/app/verticals/inventory/shared/actions/establish-stock-sharing-eligibility.ts @@ -0,0 +1,47 @@ +import { Schema } from 'effect'; + +import { + EstablishStockSharingEligibilityInputSchema, + InventoryCommerceMarketRefSchema, + InventorySellingLegalEntityRefSchema, + InventoryStorefrontRefSchema, + StockSharingEligibilityRejected, + StockSharingEligibilitySchema, +} from '../domain/stock-sharing-eligibility.ts'; +import { StockSharingEligibilityUnavailable } from '../domain/stock-sharing-eligibility-unavailable.ts'; +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { StockSharingEligibilityRefSchema } from '../resources/stock-sharing-eligibility.ts'; + +export class StockSharingEligibilityLifecycleRejected extends Schema.TaggedError()( + 'StockSharingEligibilityLifecycleRejected', + { + code: Schema.Literal('stock_sharing_eligibility_lifecycle_rejected'), + reason: Schema.Literals(['POSITION_SCOPE_MISMATCH', 'TRUSTED_LEGAL_ENTITY_MISMATCH']), + }, +) {} + +export const StockSharingEligibilityLifecycleErrorSchema = Schema.Union([ + StockSharingEligibilityRejected, + StockSharingEligibilityLifecycleRejected, + StockSharingEligibilityUnavailable, +]); + +export const StockSharingEligibilityLifecycleAuditEvidenceSchema = Schema.Struct({ + channel: Schema.Literals(['B2C', 'B2B']), + commerceMarketId: Schema.optionalKey(InventoryCommerceMarketRefSchema.fields.resourceId), + customerConfigurationId: CustomerConfigurationIdSchema, + operation: Schema.Literals(['ESTABLISH', 'CHANGE', 'END']), + ownerConfigurationId: InventoryBackendConfigurationRefSchema.fields.resourceId, + positionId: StockPositionRefSchema.fields.resourceId, + relationId: StockSharingEligibilityRefSchema.fields.resourceId, + sellingLegalEntityId: InventorySellingLegalEntityRefSchema.fields.resourceId, + storefrontAppId: Schema.optionalKey(InventoryStorefrontRefSchema.fields.appId), +}); + +export const EstablishStockSharingEligibilityPayloadSchema = EstablishStockSharingEligibilityInputSchema; +export type EstablishStockSharingEligibilityPayload = typeof EstablishStockSharingEligibilityPayloadSchema.Type; + +export const EstablishStockSharingEligibilityResultSchema = StockSharingEligibilitySchema; +export type EstablishStockSharingEligibilityResult = typeof EstablishStockSharingEligibilityResultSchema.Type; diff --git a/app/verticals/inventory/shared/actions/import-source-assertion.ts b/app/verticals/inventory/shared/actions/import-source-assertion.ts new file mode 100644 index 000000000..64a3b6770 --- /dev/null +++ b/app/verticals/inventory/shared/actions/import-source-assertion.ts @@ -0,0 +1,60 @@ +import { Schema } from 'effect'; + +import { + InventorySourceImportOutcomeSchema, + InventorySourceImportUnavailable, +} from '../domain/inventory-source-import-outcome.ts'; +import { InventorySourceAssertionProposalSchema } from '../domain/inventory-source-assertion.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +const sameRef = (left: typeof StockPositionRefSchema.Type, right: typeof StockPositionRefSchema.Type) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +export const ImportSourceAssertionPayloadSchema = Schema.Struct({ + authorizationTargetRef: StockPositionRefSchema, + items: Schema.Array(InventorySourceAssertionProposalSchema).check(Schema.isMinLength(1), Schema.isMaxLength(100)), +}).check( + Schema.makeFilter(({ authorizationTargetRef, items }) => + items.every(({ positionRef }) => sameRef(positionRef, authorizationTargetRef)) + ? undefined + : 'Every Inventory Source Assertion in a batch must share the exact authorization target Position', + ), +); +export type ImportSourceAssertionPayload = typeof ImportSourceAssertionPayloadSchema.Type; + +const nonNegativeInt = Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)); + +export const InventorySourceImportBatchSummarySchema = Schema.Struct({ + accepted: nonNegativeInt, + allItemsDeterminate: Schema.Boolean, + duplicates: nonNegativeInt, + indeterminate: nonNegativeInt, + rejected: nonNegativeInt, + stale: nonNegativeInt, +}); +export type InventorySourceImportBatchSummary = typeof InventorySourceImportBatchSummarySchema.Type; + +export const ImportSourceAssertionResultSchema = Schema.Struct({ + items: Schema.Array(InventorySourceImportOutcomeSchema), + summary: InventorySourceImportBatchSummarySchema, +}); +export type ImportSourceAssertionResult = typeof ImportSourceAssertionResultSchema.Type; + +export class InventorySourceImportRequestRejected extends Schema.TaggedError()( + 'InventorySourceImportRequestRejected', + { + code: Schema.Literal('inventory_source_import_request_rejected'), + reason: Schema.Literals([ + 'Every Inventory Source Assertion must belong to the trusted Tenant', + 'Every Inventory Source Assertion must match the exact authorization target Position', + ]), + }, +) {} + +export const ImportSourceAssertionErrorSchema = Schema.Union([ + InventorySourceImportRequestRejected, + InventorySourceImportUnavailable, +]); diff --git a/app/verticals/inventory/shared/actions/recover-inventory-effect.ts b/app/verticals/inventory/shared/actions/recover-inventory-effect.ts new file mode 100644 index 000000000..721563573 --- /dev/null +++ b/app/verticals/inventory/shared/actions/recover-inventory-effect.ts @@ -0,0 +1,83 @@ +import { Match, Schema } from 'effect'; + +import { + AlreadyTerminalInventoryEffectResultSchema, + DefinitiveNonEffectInventoryEffectResultSchema, + IndeterminateInventoryEffectResultSchema, + InventoryEffectRecoveryRejected, + RecoveredInventoryEffectResultSchema, +} from '../domain/inventory-effect-recovery.ts'; +import { + InventoryEffectLedgerConflict, + InventoryEffectLedgerEffectIdSchema, + InventoryEffectLedgerKindSchema, + InventoryEffectLedgerRejected, + InventoryEffectLedgerUnavailable, +} from '../domain/inventory-effect-ledger.ts'; +import { CommitmentProtectionRefSchema } from '../resources/commitment-protection.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +export const RecoverInventoryEffectTargetRefSchema = Schema.Union([ + InventoryReservationRefSchema, + CommitmentProtectionRefSchema, + StockPositionRefSchema, +]); +export type RecoverInventoryEffectTargetRef = typeof RecoverInventoryEffectTargetRefSchema.Type; + +const targetTypeForKind = (kind: typeof InventoryEffectLedgerKindSchema.Type) => + Match.value(kind).pipe( + Match.whenOr( + 'RESERVATION_CREATE', + 'RESERVATION_RELEASE', + () => 'commerce.inventory.inventory-reservation' as const, + ), + Match.when('ESTABLISH_COMMITMENT_PROTECTION', () => 'commerce.inventory.commitment-protection' as const), + Match.whenOr('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', () => 'commerce.inventory.stock-position' as const), + Match.exhaustive, + ); + +export const RecoverInventoryEffectPayloadSchema = Schema.Struct({ + effectId: InventoryEffectLedgerEffectIdSchema, + expectedKind: InventoryEffectLedgerKindSchema, + targetRef: RecoverInventoryEffectTargetRefSchema, +}).check( + Schema.makeFilter(({ expectedKind, targetRef }) => + targetRef.resourceType === targetTypeForKind(expectedKind) + ? undefined + : 'Recovery kind must identify its exact durable Inventory target kind', + ), +); +export type RecoverInventoryEffectPayload = typeof RecoverInventoryEffectPayloadSchema.Type; + +type RecoverInventoryEffectResultMembers = readonly [ + typeof RecoveredInventoryEffectResultSchema, + typeof DefinitiveNonEffectInventoryEffectResultSchema, + typeof AlreadyTerminalInventoryEffectResultSchema, + typeof IndeterminateInventoryEffectResultSchema, +]; + +export const RecoverInventoryEffectResultSchema: Schema.Union = Schema.Union([ + RecoveredInventoryEffectResultSchema, + DefinitiveNonEffectInventoryEffectResultSchema, + AlreadyTerminalInventoryEffectResultSchema, + IndeterminateInventoryEffectResultSchema, +]); +export type RecoverInventoryEffectResult = typeof RecoverInventoryEffectResultSchema.Type; + +export class RecoverInventoryEffectActionRejected extends Schema.TaggedError()( + 'RecoverInventoryEffectActionRejected', + { + code: Schema.Literal('recover_inventory_effect_action_rejected'), + effectId: InventoryEffectLedgerEffectIdSchema, + reason: Schema.Literals(['TRUSTED_LEGAL_ENTITY_REQUIRED', 'ORIGINAL_EFFECT_SCOPE_MISMATCH']), + }, +) {} + +export const RecoverInventoryEffectErrorSchema = Schema.Union([ + InventoryEffectLedgerConflict, + InventoryEffectLedgerRejected, + InventoryEffectLedgerUnavailable, + InventoryEffectRecoveryRejected, + RecoverInventoryEffectActionRejected, +]); diff --git a/app/verticals/inventory/shared/actions/release-inventory-reservation.ts b/app/verticals/inventory/shared/actions/release-inventory-reservation.ts new file mode 100644 index 000000000..258e5d231 --- /dev/null +++ b/app/verticals/inventory/shared/actions/release-inventory-reservation.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + ReleaseInventoryReservationErrorSchema as ErrorSchema, + ReleaseInventoryReservationPayloadSchema as PayloadSchema, + ReleaseInventoryReservationResultSchema as ResultSchema, +} from '../domain/inventory-reservation-release.ts'; + +export const ReleaseInventoryReservationErrorSchema = ErrorSchema; +export const ReleaseInventoryReservationPayloadSchema = PayloadSchema; +export const ReleaseInventoryReservationResultSchema = ResultSchema; +export type { ReleaseInventoryReservationPayload } from '../domain/inventory-reservation-release.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/resolve-inventory-source-conflict.ts b/app/verticals/inventory/shared/actions/resolve-inventory-source-conflict.ts new file mode 100644 index 000000000..10443566e --- /dev/null +++ b/app/verticals/inventory/shared/actions/resolve-inventory-source-conflict.ts @@ -0,0 +1,16 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { Schema } from 'effect'; + +import { + InventorySourceConflictErrorSchema, + InventorySourceConflictResolutionInputSchema, + InventorySourceConflictResolvedSchema, +} from '../domain/inventory-source-conflict.ts'; + +export const ResolveInventorySourceConflictPayloadSchema = InventorySourceConflictResolutionInputSchema; +export type ResolveInventorySourceConflictPayload = typeof ResolveInventorySourceConflictPayloadSchema.Type; +export const ResolveInventorySourceConflictResultSchema = Schema.Struct({ + conflict: InventorySourceConflictResolvedSchema, +}); +export const ResolveInventorySourceConflictErrorSchema = InventorySourceConflictErrorSchema; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/select-inventory-backend.ts b/app/verticals/inventory/shared/actions/select-inventory-backend.ts new file mode 100644 index 000000000..1a360eac8 --- /dev/null +++ b/app/verticals/inventory/shared/actions/select-inventory-backend.ts @@ -0,0 +1,3 @@ +export { SelectInventoryBackendPayloadSchema } from '../domain/inventory-backend-configuration.ts'; +export { SelectInventoryBackendResultSchema } from '../domain/inventory-backend-configuration.ts'; +export type { SelectInventoryBackendPayload } from '../domain/inventory-backend-configuration.ts'; diff --git a/app/verticals/inventory/shared/actions/stock-issue.ts b/app/verticals/inventory/shared/actions/stock-issue.ts new file mode 100644 index 000000000..a209fc77d --- /dev/null +++ b/app/verticals/inventory/shared/actions/stock-issue.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + PhysicalStockEffectErrorSchema, + PhysicalStockEffectPayloadSchema, + RequestPhysicalStockEffectResultSchema, +} from '../domain/physical-stock-effect.ts'; + +export const StockIssueErrorSchema = PhysicalStockEffectErrorSchema; +export const StockIssuePayloadSchema = PhysicalStockEffectPayloadSchema; +export const StockIssueResultSchema = RequestPhysicalStockEffectResultSchema; +export type { PhysicalStockEffectPayload as StockIssuePayload } from '../domain/physical-stock-effect.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/actions/stock-receipt.ts b/app/verticals/inventory/shared/actions/stock-receipt.ts new file mode 100644 index 000000000..53a7958b9 --- /dev/null +++ b/app/verticals/inventory/shared/actions/stock-receipt.ts @@ -0,0 +1,12 @@ +/* oxlint-disable unicorn/prefer-export-from -- Codesmith Action HTTP requires concrete local schema export declarations. */ +import { + PhysicalStockEffectErrorSchema, + PhysicalStockEffectPayloadSchema, + RequestPhysicalStockEffectResultSchema, +} from '../domain/physical-stock-effect.ts'; + +export const StockReceiptErrorSchema = PhysicalStockEffectErrorSchema; +export const StockReceiptPayloadSchema = PhysicalStockEffectPayloadSchema; +export const StockReceiptResultSchema = RequestPhysicalStockEffectResultSchema; +export type { PhysicalStockEffectPayload as StockReceiptPayload } from '../domain/physical-stock-effect.ts'; +/* oxlint-enable unicorn/prefer-export-from */ diff --git a/app/verticals/inventory/shared/api.ts b/app/verticals/inventory/shared/api.ts new file mode 100644 index 000000000..35ddbb1f3 --- /dev/null +++ b/app/verticals/inventory/shared/api.ts @@ -0,0 +1,151 @@ +import { identity } from 'effect'; +import { + MicroVerticalBuildMarkerSchema, + MicroVerticalReadinessSchema, + createMicroVerticalOperationContext, +} from '@modern-js/bff-effect/microvertical-api'; +import type { MicroVerticalOperationContext } from '@modern-js/bff-effect/microvertical-api'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; + +// +import { CatalogToStockBindingResolutionApi } from './apis/catalog-to-stock-binding-resolution.ts'; +import { ChangeStockSharingEligibilityActionApi } from './apis/change-stock-sharing-eligibility-action.ts'; +import { CommitmentProtectionVerificationApi } from './apis/commitment-protection-verification.ts'; +import { CompensateInventoryPreCommitActionApi } from './apis/compensate-inventory-pre-commit-action.ts'; +import { CorrectCatalogToStockBindingActionApi } from './apis/correct-catalog-to-stock-binding-action.ts'; +import { CorrectExternalStockCorrelationActionApi } from './apis/correct-external-stock-correlation-action.ts'; +import { CorrectStockPositionActionApi } from './apis/correct-stock-position-action.ts'; +import { CreateInventoryReservationActionApi } from './apis/create-inventory-reservation-action.ts'; +import { CurrentStockEvidenceForAvailabilityApi } from './apis/current-stock-evidence-for-availability.ts'; +import { EndCatalogToStockBindingActionApi } from './apis/end-catalog-to-stock-binding-action.ts'; +import { EndExternalStockCorrelationActionApi } from './apis/end-external-stock-correlation-action.ts'; +import { EndStockSharingEligibilityActionApi } from './apis/end-stock-sharing-eligibility-action.ts'; +import { EstablishCatalogToStockBindingActionApi } from './apis/establish-catalog-to-stock-binding-action.ts'; +import { EstablishCommitmentProtectionActionApi } from './apis/establish-commitment-protection-action.ts'; +import { EstablishExternalStockCorrelationActionApi } from './apis/establish-external-stock-correlation-action.ts'; +import { EstablishStockSharingEligibilityActionApi } from './apis/establish-stock-sharing-eligibility-action.ts'; +import { ImportSourceAssertionActionApi } from './apis/import-source-assertion-action.ts'; +import { InventoryBackendConfigurationCurrentApi } from './apis/inventory-backend-configuration-current.ts'; +import { InventoryEffectOutcomeApi } from './apis/inventory-effect-outcome.ts'; +import { InventoryReconciliationEvidenceApi } from './apis/inventory-reconciliation-evidence.ts'; +import { InventoryReservationDetailApi } from './apis/inventory-reservation-detail.ts'; +import { InventorySourceConflictDetailApi } from './apis/inventory-source-conflict-detail.ts'; +import { RecoverInventoryEffectActionApi } from './apis/recover-inventory-effect-action.ts'; +import { ReleaseInventoryReservationActionApi } from './apis/release-inventory-reservation-action.ts'; +import { ReservationConfirmationVerificationApi } from './apis/reservation-confirmation-verification.ts'; +import { ResolveInventorySourceConflictActionApi } from './apis/resolve-inventory-source-conflict-action.ts'; +import { SelectInventoryBackendActionApi } from './apis/select-inventory-backend-action.ts'; +import { StockIssueActionApi } from './apis/stock-issue-action.ts'; +import { StockReceiptActionApi } from './apis/stock-receipt-action.ts'; +import { StockSharingEligibilityResolutionApi } from './apis/stock-sharing-eligibility-resolution.ts'; +// + +export const inventoryMarkerSchema = Schema.Struct({ + ...MicroVerticalBuildMarkerSchema.fields, + kind: Schema.Literal('microvertical-delivery-unit'), + schemaVersion: Schema.Literal(1), +}); +export type InventoryMarker = typeof inventoryMarkerSchema.Type; + +export const inventoryReadinessSchema = Schema.Struct({ + ...MicroVerticalReadinessSchema.fields, + marker: inventoryMarkerSchema, +}); +export type InventoryReadiness = typeof inventoryReadinessSchema.Type; + +export type OperationContext = MicroVerticalOperationContext; + +export const inventoryFoundationApi = HttpApi.make('InventoryApiFoundation').add( + HttpApiGroup.make('foundation').add( + HttpApiEndpoint.get('readiness', '/inventory/readiness', { success: inventoryReadinessSchema }), + ), +); +type GroupsOf = Api extends HttpApi.HttpApi ? Groups : never; + +type InventoryApiGroups = GroupsOf< + | typeof inventoryFoundationApi + | typeof CatalogToStockBindingResolutionApi + | typeof ChangeStockSharingEligibilityActionApi + | typeof CommitmentProtectionVerificationApi + | typeof CompensateInventoryPreCommitActionApi + | typeof CorrectCatalogToStockBindingActionApi + | typeof CorrectExternalStockCorrelationActionApi + | typeof CorrectStockPositionActionApi + | typeof CreateInventoryReservationActionApi + | typeof CurrentStockEvidenceForAvailabilityApi + | typeof EndCatalogToStockBindingActionApi + | typeof EndExternalStockCorrelationActionApi + | typeof EndStockSharingEligibilityActionApi + | typeof EstablishCatalogToStockBindingActionApi + | typeof EstablishCommitmentProtectionActionApi + | typeof EstablishExternalStockCorrelationActionApi + | typeof EstablishStockSharingEligibilityActionApi + | typeof ImportSourceAssertionActionApi + | typeof InventoryBackendConfigurationCurrentApi + | typeof InventoryEffectOutcomeApi + | typeof InventoryReconciliationEvidenceApi + | typeof InventoryReservationDetailApi + | typeof InventorySourceConflictDetailApi + | typeof RecoverInventoryEffectActionApi + | typeof ReleaseInventoryReservationActionApi + | typeof ReservationConfirmationVerificationApi + | typeof ResolveInventorySourceConflictActionApi + | typeof SelectInventoryBackendActionApi + | typeof StockIssueActionApi + | typeof StockReceiptActionApi + | typeof StockSharingEligibilityResolutionApi +>; + +type InventoryApi = HttpApi.HttpApi<'InventoryApi', InventoryApiGroups>; + +export const inventoryApi: InventoryApi = HttpApi.make('InventoryApi') + .addHttpApi(inventoryFoundationApi) + // + .addHttpApi(CatalogToStockBindingResolutionApi) + .addHttpApi(ChangeStockSharingEligibilityActionApi) + .addHttpApi(CommitmentProtectionVerificationApi) + .addHttpApi(CompensateInventoryPreCommitActionApi) + .addHttpApi(CorrectCatalogToStockBindingActionApi) + .addHttpApi(CorrectExternalStockCorrelationActionApi) + .addHttpApi(CorrectStockPositionActionApi) + .addHttpApi(CreateInventoryReservationActionApi) + .addHttpApi(CurrentStockEvidenceForAvailabilityApi) + .addHttpApi(EndCatalogToStockBindingActionApi) + .addHttpApi(EndExternalStockCorrelationActionApi) + .addHttpApi(EndStockSharingEligibilityActionApi) + .addHttpApi(EstablishCatalogToStockBindingActionApi) + .addHttpApi(EstablishCommitmentProtectionActionApi) + .addHttpApi(EstablishExternalStockCorrelationActionApi) + .addHttpApi(EstablishStockSharingEligibilityActionApi) + .addHttpApi(ImportSourceAssertionActionApi) + .addHttpApi(InventoryBackendConfigurationCurrentApi) + .addHttpApi(InventoryEffectOutcomeApi) + .addHttpApi(InventoryReconciliationEvidenceApi) + .addHttpApi(InventoryReservationDetailApi) + .addHttpApi(InventorySourceConflictDetailApi) + .addHttpApi(RecoverInventoryEffectActionApi) + .addHttpApi(ReleaseInventoryReservationActionApi) + .addHttpApi(ReservationConfirmationVerificationApi) + .addHttpApi(ResolveInventorySourceConflictActionApi) + .addHttpApi(SelectInventoryBackendActionApi) + .addHttpApi(StockIssueActionApi) + .addHttpApi(StockReceiptActionApi) + .addHttpApi(StockSharingEligibilityResolutionApi) + // + .annotate(HttpApi.ParseOptions, { onExcessProperty: 'error' }) + .pipe(identity); + +export const inventoryOperationContexts = { + readiness: createMicroVerticalOperationContext({ + method: 'GET', + operationId: 'InventoryApi:inventory:readiness', + routePath: '/inventory/readiness', + }), +} satisfies Record; + +export const inventoryApiContract = { + apiPrefix: '/inventory-api', + basePath: '/inventory-api/inventory', + ownerId: 'inventory', + readinessPath: '/inventory-api/inventory/readiness', +} as const; diff --git a/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution-domain-policy-problem.ts b/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution-domain-policy-problem.ts new file mode 100644 index 000000000..544d8f951 --- /dev/null +++ b/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution-domain-policy-problem.ts @@ -0,0 +1,15 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +import { CatalogToStockBindingResolutionFailure } from '../domain/catalog-to-stock-binding-resolution.ts'; + +export const CatalogToStockBindingResolutionDomainPolicyProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionDomainPolicyProblem', + 422, + { + outcome: Schema.Literals(['AMBIGUOUS', 'UNSUPPORTED']), + reasonCode: CatalogToStockBindingResolutionFailure.fields.reason, + }, +); +export type CatalogToStockBindingResolutionDomainPolicyProblem = + typeof CatalogToStockBindingResolutionDomainPolicyProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution-domain-unavailable-problem.ts new file mode 100644 index 000000000..ba6cf8b49 --- /dev/null +++ b/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution-domain-unavailable-problem.ts @@ -0,0 +1,16 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const CatalogToStockBindingResolutionDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CatalogToStockBindingResolutionDomainUnavailableProblem', + 503, + { + outcome: Schema.Literal('UNAVAILABLE'), + reasonCode: Schema.Literals([ + 'catalog_to_stock_binding_unavailable', + 'inventory_backend_configuration_persistence_unavailable', + ]), + }, +); +export type CatalogToStockBindingResolutionDomainUnavailableProblem = + typeof CatalogToStockBindingResolutionDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution.ts b/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution.ts new file mode 100644 index 000000000..167c945e6 --- /dev/null +++ b/app/verticals/inventory/shared/apis/catalog-to-stock-binding-resolution.ts @@ -0,0 +1,83 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { CatalogStockDemandSchema, ResolvedCatalogStockDemandSchema } from '../domain/catalog-to-stock-binding.ts'; +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { CatalogToStockBindingResolutionDomainPolicyProblemSchema } from './catalog-to-stock-binding-resolution-domain-policy-problem.ts'; +import { CatalogToStockBindingResolutionDomainUnavailableProblemSchema } from './catalog-to-stock-binding-resolution-domain-unavailable-problem.ts'; + +export { + type CatalogToStockBindingResolutionDomainPolicyProblem, + CatalogToStockBindingResolutionDomainPolicyProblemSchema, +} from './catalog-to-stock-binding-resolution-domain-policy-problem.ts'; +export { + type CatalogToStockBindingResolutionDomainUnavailableProblem, + CatalogToStockBindingResolutionDomainUnavailableProblemSchema, +} from './catalog-to-stock-binding-resolution-domain-unavailable-problem.ts'; + +export const CatalogToStockBindingResolutionRequestSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + demand: CatalogStockDemandSchema, +}); +export type CatalogToStockBindingResolutionRequest = typeof CatalogToStockBindingResolutionRequestSchema.Type; +export const CatalogToStockBindingResolutionResponseSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + outcome: Schema.Literal('RESOLVED'), + resolution: ResolvedCatalogStockDemandSchema, +}); +export type CatalogToStockBindingResolutionResponse = typeof CatalogToStockBindingResolutionResponseSchema.Type; + +export const CatalogToStockBindingResolutionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionAuthenticationProblem', + 401, +); +export const CatalogToStockBindingResolutionInvalidProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionInvalidProblem', + 400, +); +export const CatalogToStockBindingResolutionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CatalogToStockBindingResolutionUnavailableProblem', + 503, +); +export const CatalogToStockBindingResolutionForbiddenProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionForbiddenProblem', + 403, +); +export const CatalogToStockBindingResolutionNotFoundProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionNotFoundProblem', + 404, +); +export const CatalogToStockBindingResolutionPolicyProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionPolicyProblem', + 422, +); +export const CatalogToStockBindingResolutionPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionPolicyConflictProblem', + 409, +); +export const CatalogToStockBindingResolutionInternalProblemSchema = makeProblemDetailsSchema( + 'CatalogToStockBindingResolutionInternalProblem', + 500, +); + +export const CatalogToStockBindingResolutionApi = HttpApi.make('CatalogToStockBindingResolutionApi').add( + HttpApiGroup.make('catalogToStockBindingResolution').add( + HttpApiEndpoint.post('execute', '/reads/catalog-to-stock-binding-resolution', { + error: [ + CatalogToStockBindingResolutionInvalidProblemSchema, + CatalogToStockBindingResolutionAuthenticationProblemSchema, + CatalogToStockBindingResolutionForbiddenProblemSchema, + CatalogToStockBindingResolutionNotFoundProblemSchema, + CatalogToStockBindingResolutionPolicyConflictProblemSchema, + CatalogToStockBindingResolutionPolicyProblemSchema, + CatalogToStockBindingResolutionDomainPolicyProblemSchema, + CatalogToStockBindingResolutionDomainUnavailableProblemSchema, + CatalogToStockBindingResolutionUnavailableProblemSchema, + CatalogToStockBindingResolutionInternalProblemSchema, + ], + payload: CatalogToStockBindingResolutionRequestSchema, + success: CatalogToStockBindingResolutionResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/change-stock-sharing-eligibility-action.ts b/app/verticals/inventory/shared/apis/change-stock-sharing-eligibility-action.ts new file mode 100644 index 000000000..8e8c8f6a3 --- /dev/null +++ b/app/verticals/inventory/shared/apis/change-stock-sharing-eligibility-action.ts @@ -0,0 +1,170 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug change-stock-sharing-eligibility +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + ChangeStockSharingEligibilityPayloadSchema, + ChangeStockSharingEligibilityResultSchema, +} from '../actions/change-stock-sharing-eligibility.ts'; + +export { ChangeStockSharingEligibilityPayloadSchema } from '../actions/change-stock-sharing-eligibility.ts'; + +const ChangeStockSharingEligibilityActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const ChangeStockSharingEligibilityActionInvalidProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionInvalidProblem', + 400, +); +export const ChangeStockSharingEligibilityActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionAuthenticationProblem', + 401, +); +export const ChangeStockSharingEligibilityActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const ChangeStockSharingEligibilityActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const ChangeStockSharingEligibilityActionConflictProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'stock_sharing_eligibility_lifecycle_rejected', + ]), + }, +); +export const ChangeStockSharingEligibilityActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'stock_sharing_eligibility_rejected']) }, +); +export const ChangeStockSharingEligibilityActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionPreconditionProblem', + 428, +); +export const ChangeStockSharingEligibilityActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'stock_sharing_eligibility_unavailable', + ]), + }, +); +export const ChangeStockSharingEligibilityActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const ChangeStockSharingEligibilityActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const ChangeStockSharingEligibilityActionInternalProblemSchema = makeProblemDetailsSchema( + 'ChangeStockSharingEligibilityActionInternalProblem', + 500, +); + +export type ChangeStockSharingEligibilityActionProblem = + | typeof ChangeStockSharingEligibilityActionInvalidProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionAuthenticationProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionForbiddenProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionNotFoundProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionConflictProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionIneligibleProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionPreconditionProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionUnavailableProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionAlreadyCommittedProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionCommitIndeterminateProblemSchema.Type + | typeof ChangeStockSharingEligibilityActionInternalProblemSchema.Type; + +export class ChangeStockSharingEligibilityActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/ChangeStockSharingEligibilityActionSchemaErrorMiddleware', + { error: ChangeStockSharingEligibilityActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + ChangeStockSharingEligibilityActionInvalidProblemSchema, + ChangeStockSharingEligibilityActionAuthenticationProblemSchema, + ChangeStockSharingEligibilityActionForbiddenProblemSchema, + ChangeStockSharingEligibilityActionNotFoundProblemSchema, + ChangeStockSharingEligibilityActionConflictProblemSchema, + ChangeStockSharingEligibilityActionIneligibleProblemSchema, + ChangeStockSharingEligibilityActionPreconditionProblemSchema, + ChangeStockSharingEligibilityActionUnavailableProblemSchema, + ChangeStockSharingEligibilityActionAlreadyCommittedProblemSchema, + ChangeStockSharingEligibilityActionCommitIndeterminateProblemSchema, + ChangeStockSharingEligibilityActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const changeStockSharingEligibilityActionGroupDefinition = HttpApiGroup.make( + 'changeStockSharingEligibilityAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/change-stock-sharing-eligibility', { + error: actionErrors, + headers: ChangeStockSharingEligibilityActionHeadersSchema, + payload: Schema.toEncoded(ChangeStockSharingEligibilityPayloadSchema), + success: ChangeStockSharingEligibilityResultSchema, + }), + ) + .middleware(ChangeStockSharingEligibilityActionSchemaErrorMiddleware); + +export type ChangeStockSharingEligibilityActionGroupContract = HttpApiGroup.HttpApiGroup< + 'changeStockSharingEligibilityAction', + HttpApiGroup.Endpoints +>; + +const ChangeStockSharingEligibilityActionGroup: ChangeStockSharingEligibilityActionGroupContract = + changeStockSharingEligibilityActionGroupDefinition; + +export const ChangeStockSharingEligibilityActionApi = HttpApi.make('ChangeStockSharingEligibilityActionApi').add( + ChangeStockSharingEligibilityActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/commitment-protection-verification-domain-conflict-problem.ts b/app/verticals/inventory/shared/apis/commitment-protection-verification-domain-conflict-problem.ts new file mode 100644 index 000000000..93f04ca83 --- /dev/null +++ b/app/verticals/inventory/shared/apis/commitment-protection-verification-domain-conflict-problem.ts @@ -0,0 +1,10 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const CommitmentProtectionVerificationDomainConflictProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationDomainConflictProblem', + 409, + { reasonCode: Schema.Literal('commitment_protection_scope_conflict') }, +); +export type CommitmentProtectionVerificationDomainConflictProblem = + typeof CommitmentProtectionVerificationDomainConflictProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/commitment-protection-verification-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/commitment-protection-verification-domain-unavailable-problem.ts new file mode 100644 index 000000000..2b6993527 --- /dev/null +++ b/app/verticals/inventory/shared/apis/commitment-protection-verification-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const CommitmentProtectionVerificationDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CommitmentProtectionVerificationDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('commitment_protection_unavailable') }, +); +export type CommitmentProtectionVerificationDomainUnavailableProblem = + typeof CommitmentProtectionVerificationDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/commitment-protection-verification.ts b/app/verticals/inventory/shared/apis/commitment-protection-verification.ts new file mode 100644 index 000000000..f29a5656a --- /dev/null +++ b/app/verticals/inventory/shared/apis/commitment-protection-verification.ts @@ -0,0 +1,114 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Match, Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { CommitmentProtectionSchema } from '../domain/commitment-protection.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { CommitmentProtectionRefSchema } from '../resources/commitment-protection.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { CommitmentProtectionVerificationDomainConflictProblemSchema } from './commitment-protection-verification-domain-conflict-problem.ts'; +import { CommitmentProtectionVerificationDomainUnavailableProblemSchema } from './commitment-protection-verification-domain-unavailable-problem.ts'; + +export { + type CommitmentProtectionVerificationDomainConflictProblem, + CommitmentProtectionVerificationDomainConflictProblemSchema, +} from './commitment-protection-verification-domain-conflict-problem.ts'; +export { + type CommitmentProtectionVerificationDomainUnavailableProblem, + CommitmentProtectionVerificationDomainUnavailableProblemSchema, +} from './commitment-protection-verification-domain-unavailable-problem.ts'; + +export const CommitmentProtectionVerificationRequestSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + protectionRef: CommitmentProtectionRefSchema, + reservationRef: InventoryReservationRefSchema, +}).check( + Schema.makeFilter(({ protectionRef, reservationRef }) => + protectionRef.tenantId === reservationRef.tenantId + ? undefined + : 'Commitment Protection and Reservation must belong to one Tenant', + ), +); +export type CommitmentProtectionVerificationRequest = typeof CommitmentProtectionVerificationRequestSchema.Type; +export const CommitmentProtectionVerificationResponseSchema = Schema.Union([ + Schema.TaggedStruct('PROTECTED', { + nextStep: Schema.Literal('CONTINUE'), + protection: CommitmentProtectionSchema, + }), + Schema.TaggedStruct('AT_RISK', { + nextStep: Schema.Literal('RECONCILE'), + protection: CommitmentProtectionSchema, + reconciliationRequired: Schema.Literal(true), + }), +]).check( + Schema.makeFilter((result) => + Match.value(result).pipe( + Match.tag('PROTECTED', ({ protection }) => + protection.health.state === 'PROTECTED' + ? undefined + : 'Commitment Protection verification state must match the current owner health state', + ), + Match.tag('AT_RISK', ({ protection }) => + protection.health.state === 'AT_RISK' + ? undefined + : 'Commitment Protection verification state must match the current owner health state', + ), + Match.exhaustive, + ), + ), +); +export type CommitmentProtectionVerificationResponse = typeof CommitmentProtectionVerificationResponseSchema.Type; + +export const CommitmentProtectionVerificationAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationAuthenticationProblem', + 401, +); +export const CommitmentProtectionVerificationInvalidProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationInvalidProblem', + 400, +); +export const CommitmentProtectionVerificationUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CommitmentProtectionVerificationUnavailableProblem', + 503, +); +export const CommitmentProtectionVerificationForbiddenProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationForbiddenProblem', + 403, +); +export const CommitmentProtectionVerificationNotFoundProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationNotFoundProblem', + 404, +); +export const CommitmentProtectionVerificationPolicyProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationPolicyProblem', + 422, +); +export const CommitmentProtectionVerificationPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationPolicyConflictProblem', + 409, +); +export const CommitmentProtectionVerificationInternalProblemSchema = makeProblemDetailsSchema( + 'CommitmentProtectionVerificationInternalProblem', + 500, +); + +export const CommitmentProtectionVerificationApi = HttpApi.make('CommitmentProtectionVerificationApi').add( + HttpApiGroup.make('commitmentProtectionVerification').add( + HttpApiEndpoint.post('execute', '/reads/commitment-protection-verification', { + error: [ + CommitmentProtectionVerificationInvalidProblemSchema, + CommitmentProtectionVerificationAuthenticationProblemSchema, + CommitmentProtectionVerificationForbiddenProblemSchema, + CommitmentProtectionVerificationNotFoundProblemSchema, + CommitmentProtectionVerificationPolicyConflictProblemSchema, + CommitmentProtectionVerificationPolicyProblemSchema, + CommitmentProtectionVerificationDomainConflictProblemSchema, + CommitmentProtectionVerificationDomainUnavailableProblemSchema, + CommitmentProtectionVerificationUnavailableProblemSchema, + CommitmentProtectionVerificationInternalProblemSchema, + ], + payload: CommitmentProtectionVerificationRequestSchema, + success: CommitmentProtectionVerificationResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/compensate-inventory-pre-commit-action.ts b/app/verticals/inventory/shared/apis/compensate-inventory-pre-commit-action.ts new file mode 100644 index 000000000..ba740a55f --- /dev/null +++ b/app/verticals/inventory/shared/apis/compensate-inventory-pre-commit-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug compensate-inventory-pre-commit +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + CompensateInventoryPreCommitPayloadSchema, + CompensateInventoryPreCommitResultSchema, +} from '../actions/compensate-inventory-pre-commit.ts'; + +export { CompensateInventoryPreCommitPayloadSchema } from '../actions/compensate-inventory-pre-commit.ts'; + +const CompensateInventoryPreCommitActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const CompensateInventoryPreCommitActionInvalidProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionInvalidProblem', + 400, +); +export const CompensateInventoryPreCommitActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionAuthenticationProblem', + 401, +); +export const CompensateInventoryPreCommitActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const CompensateInventoryPreCommitActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const CompensateInventoryPreCommitActionConflictProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const CompensateInventoryPreCommitActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'inventory_pre_commit_compensation_rejected']) }, +); +export const CompensateInventoryPreCommitActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionPreconditionProblem', + 428, +); +export const CompensateInventoryPreCommitActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CompensateInventoryPreCommitActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_pre_commit_compensation_unavailable', + ]), + }, +); +export const CompensateInventoryPreCommitActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const CompensateInventoryPreCommitActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const CompensateInventoryPreCommitActionInternalProblemSchema = makeProblemDetailsSchema( + 'CompensateInventoryPreCommitActionInternalProblem', + 500, +); + +export type CompensateInventoryPreCommitActionProblem = + | typeof CompensateInventoryPreCommitActionInvalidProblemSchema.Type + | typeof CompensateInventoryPreCommitActionAuthenticationProblemSchema.Type + | typeof CompensateInventoryPreCommitActionForbiddenProblemSchema.Type + | typeof CompensateInventoryPreCommitActionNotFoundProblemSchema.Type + | typeof CompensateInventoryPreCommitActionConflictProblemSchema.Type + | typeof CompensateInventoryPreCommitActionIneligibleProblemSchema.Type + | typeof CompensateInventoryPreCommitActionPreconditionProblemSchema.Type + | typeof CompensateInventoryPreCommitActionUnavailableProblemSchema.Type + | typeof CompensateInventoryPreCommitActionAlreadyCommittedProblemSchema.Type + | typeof CompensateInventoryPreCommitActionCommitIndeterminateProblemSchema.Type + | typeof CompensateInventoryPreCommitActionInternalProblemSchema.Type; + +export class CompensateInventoryPreCommitActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/CompensateInventoryPreCommitActionSchemaErrorMiddleware', + { error: CompensateInventoryPreCommitActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + CompensateInventoryPreCommitActionInvalidProblemSchema, + CompensateInventoryPreCommitActionAuthenticationProblemSchema, + CompensateInventoryPreCommitActionForbiddenProblemSchema, + CompensateInventoryPreCommitActionNotFoundProblemSchema, + CompensateInventoryPreCommitActionConflictProblemSchema, + CompensateInventoryPreCommitActionIneligibleProblemSchema, + CompensateInventoryPreCommitActionPreconditionProblemSchema, + CompensateInventoryPreCommitActionUnavailableProblemSchema, + CompensateInventoryPreCommitActionAlreadyCommittedProblemSchema, + CompensateInventoryPreCommitActionCommitIndeterminateProblemSchema, + CompensateInventoryPreCommitActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const compensateInventoryPreCommitActionGroupDefinition = HttpApiGroup.make('compensateInventoryPreCommitAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/compensate-inventory-pre-commit', { + error: actionErrors, + headers: CompensateInventoryPreCommitActionHeadersSchema, + payload: Schema.toEncoded(CompensateInventoryPreCommitPayloadSchema), + success: CompensateInventoryPreCommitResultSchema, + }), + ) + .middleware(CompensateInventoryPreCommitActionSchemaErrorMiddleware); + +export type CompensateInventoryPreCommitActionGroupContract = HttpApiGroup.HttpApiGroup< + 'compensateInventoryPreCommitAction', + HttpApiGroup.Endpoints +>; + +const CompensateInventoryPreCommitActionGroup: CompensateInventoryPreCommitActionGroupContract = + compensateInventoryPreCommitActionGroupDefinition; + +export const CompensateInventoryPreCommitActionApi = HttpApi.make('CompensateInventoryPreCommitActionApi').add( + CompensateInventoryPreCommitActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/correct-catalog-to-stock-binding-action.ts b/app/verticals/inventory/shared/apis/correct-catalog-to-stock-binding-action.ts new file mode 100644 index 000000000..3b4c6df55 --- /dev/null +++ b/app/verticals/inventory/shared/apis/correct-catalog-to-stock-binding-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-catalog-to-stock-binding +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + CorrectCatalogToStockBindingPayloadSchema, + CorrectCatalogToStockBindingResultSchema, +} from '../actions/correct-catalog-to-stock-binding.ts'; + +export { CorrectCatalogToStockBindingPayloadSchema } from '../actions/correct-catalog-to-stock-binding.ts'; + +const CorrectCatalogToStockBindingActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const CorrectCatalogToStockBindingActionInvalidProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionInvalidProblem', + 400, +); +export const CorrectCatalogToStockBindingActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionAuthenticationProblem', + 401, +); +export const CorrectCatalogToStockBindingActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const CorrectCatalogToStockBindingActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const CorrectCatalogToStockBindingActionConflictProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const CorrectCatalogToStockBindingActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'catalog_to_stock_binding_rejected']) }, +); +export const CorrectCatalogToStockBindingActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionPreconditionProblem', + 428, +); +export const CorrectCatalogToStockBindingActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'catalog_to_stock_binding_unavailable', + ]), + }, +); +export const CorrectCatalogToStockBindingActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const CorrectCatalogToStockBindingActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const CorrectCatalogToStockBindingActionInternalProblemSchema = makeProblemDetailsSchema( + 'CorrectCatalogToStockBindingActionInternalProblem', + 500, +); + +export type CorrectCatalogToStockBindingActionProblem = + | typeof CorrectCatalogToStockBindingActionInvalidProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionAuthenticationProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionForbiddenProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionNotFoundProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionConflictProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionIneligibleProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionPreconditionProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionUnavailableProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionAlreadyCommittedProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionCommitIndeterminateProblemSchema.Type + | typeof CorrectCatalogToStockBindingActionInternalProblemSchema.Type; + +export class CorrectCatalogToStockBindingActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/CorrectCatalogToStockBindingActionSchemaErrorMiddleware', + { error: CorrectCatalogToStockBindingActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + CorrectCatalogToStockBindingActionInvalidProblemSchema, + CorrectCatalogToStockBindingActionAuthenticationProblemSchema, + CorrectCatalogToStockBindingActionForbiddenProblemSchema, + CorrectCatalogToStockBindingActionNotFoundProblemSchema, + CorrectCatalogToStockBindingActionConflictProblemSchema, + CorrectCatalogToStockBindingActionIneligibleProblemSchema, + CorrectCatalogToStockBindingActionPreconditionProblemSchema, + CorrectCatalogToStockBindingActionUnavailableProblemSchema, + CorrectCatalogToStockBindingActionAlreadyCommittedProblemSchema, + CorrectCatalogToStockBindingActionCommitIndeterminateProblemSchema, + CorrectCatalogToStockBindingActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const correctCatalogToStockBindingActionGroupDefinition = HttpApiGroup.make('correctCatalogToStockBindingAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/correct-catalog-to-stock-binding', { + error: actionErrors, + headers: CorrectCatalogToStockBindingActionHeadersSchema, + payload: Schema.toEncoded(CorrectCatalogToStockBindingPayloadSchema), + success: CorrectCatalogToStockBindingResultSchema, + }), + ) + .middleware(CorrectCatalogToStockBindingActionSchemaErrorMiddleware); + +export type CorrectCatalogToStockBindingActionGroupContract = HttpApiGroup.HttpApiGroup< + 'correctCatalogToStockBindingAction', + HttpApiGroup.Endpoints +>; + +const CorrectCatalogToStockBindingActionGroup: CorrectCatalogToStockBindingActionGroupContract = + correctCatalogToStockBindingActionGroupDefinition; + +export const CorrectCatalogToStockBindingActionApi = HttpApi.make('CorrectCatalogToStockBindingActionApi').add( + CorrectCatalogToStockBindingActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/correct-external-stock-correlation-action.ts b/app/verticals/inventory/shared/apis/correct-external-stock-correlation-action.ts new file mode 100644 index 000000000..5e9631af6 --- /dev/null +++ b/app/verticals/inventory/shared/apis/correct-external-stock-correlation-action.ts @@ -0,0 +1,164 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-external-stock-correlation +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + CorrectExternalStockCorrelationPayloadSchema, + CorrectExternalStockCorrelationResultSchema, +} from '../actions/correct-external-stock-correlation.ts'; + +export { CorrectExternalStockCorrelationPayloadSchema } from '../actions/correct-external-stock-correlation.ts'; + +const CorrectExternalStockCorrelationActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const CorrectExternalStockCorrelationActionInvalidProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionInvalidProblem', + 400, +); +export const CorrectExternalStockCorrelationActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionAuthenticationProblem', + 401, +); +export const CorrectExternalStockCorrelationActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const CorrectExternalStockCorrelationActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const CorrectExternalStockCorrelationActionConflictProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const CorrectExternalStockCorrelationActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'external_stock_correlation_rejected']) }, +); +export const CorrectExternalStockCorrelationActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionPreconditionProblem', + 428, +); +export const CorrectExternalStockCorrelationActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'external_stock_correlation_persistence_unavailable', + ]), + }, +); +export const CorrectExternalStockCorrelationActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const CorrectExternalStockCorrelationActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const CorrectExternalStockCorrelationActionInternalProblemSchema = makeProblemDetailsSchema( + 'CorrectExternalStockCorrelationActionInternalProblem', + 500, +); + +export type CorrectExternalStockCorrelationActionProblem = + | typeof CorrectExternalStockCorrelationActionInvalidProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionAuthenticationProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionForbiddenProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionNotFoundProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionConflictProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionIneligibleProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionPreconditionProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionUnavailableProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionAlreadyCommittedProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionCommitIndeterminateProblemSchema.Type + | typeof CorrectExternalStockCorrelationActionInternalProblemSchema.Type; + +export class CorrectExternalStockCorrelationActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/CorrectExternalStockCorrelationActionSchemaErrorMiddleware', + { error: CorrectExternalStockCorrelationActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + CorrectExternalStockCorrelationActionInvalidProblemSchema, + CorrectExternalStockCorrelationActionAuthenticationProblemSchema, + CorrectExternalStockCorrelationActionForbiddenProblemSchema, + CorrectExternalStockCorrelationActionNotFoundProblemSchema, + CorrectExternalStockCorrelationActionConflictProblemSchema, + CorrectExternalStockCorrelationActionIneligibleProblemSchema, + CorrectExternalStockCorrelationActionPreconditionProblemSchema, + CorrectExternalStockCorrelationActionUnavailableProblemSchema, + CorrectExternalStockCorrelationActionAlreadyCommittedProblemSchema, + CorrectExternalStockCorrelationActionCommitIndeterminateProblemSchema, + CorrectExternalStockCorrelationActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const correctExternalStockCorrelationActionGroupDefinition = HttpApiGroup.make( + 'correctExternalStockCorrelationAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/correct-external-stock-correlation', { + error: actionErrors, + headers: CorrectExternalStockCorrelationActionHeadersSchema, + payload: Schema.toEncoded(CorrectExternalStockCorrelationPayloadSchema), + success: CorrectExternalStockCorrelationResultSchema, + }), + ) + .middleware(CorrectExternalStockCorrelationActionSchemaErrorMiddleware); + +export type CorrectExternalStockCorrelationActionGroupContract = HttpApiGroup.HttpApiGroup< + 'correctExternalStockCorrelationAction', + HttpApiGroup.Endpoints +>; + +const CorrectExternalStockCorrelationActionGroup: CorrectExternalStockCorrelationActionGroupContract = + correctExternalStockCorrelationActionGroupDefinition; + +export const CorrectExternalStockCorrelationActionApi = HttpApi.make('CorrectExternalStockCorrelationActionApi').add( + CorrectExternalStockCorrelationActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/correct-stock-position-action.ts b/app/verticals/inventory/shared/apis/correct-stock-position-action.ts new file mode 100644 index 000000000..9651c3ed0 --- /dev/null +++ b/app/verticals/inventory/shared/apis/correct-stock-position-action.ts @@ -0,0 +1,168 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-stock-position +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + CorrectStockPositionPayloadSchema, + CorrectStockPositionResultSchema, +} from '../actions/correct-stock-position.ts'; + +export { CorrectStockPositionPayloadSchema } from '../actions/correct-stock-position.ts'; + +const CorrectStockPositionActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const CorrectStockPositionActionInvalidProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionInvalidProblem', + 400, +); +export const CorrectStockPositionActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionAuthenticationProblem', + 401, +); +export const CorrectStockPositionActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const CorrectStockPositionActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const CorrectStockPositionActionConflictProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'stock_correction_conflict', + ]), + }, +); +export const CorrectStockPositionActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'stock_correction_rejected']) }, +); +export const CorrectStockPositionActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionPreconditionProblem', + 428, +); +export const CorrectStockPositionActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CorrectStockPositionActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'stock_correction_unavailable', + ]), + }, +); +export const CorrectStockPositionActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const CorrectStockPositionActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const CorrectStockPositionActionInternalProblemSchema = makeProblemDetailsSchema( + 'CorrectStockPositionActionInternalProblem', + 500, +); + +export type CorrectStockPositionActionProblem = + | typeof CorrectStockPositionActionInvalidProblemSchema.Type + | typeof CorrectStockPositionActionAuthenticationProblemSchema.Type + | typeof CorrectStockPositionActionForbiddenProblemSchema.Type + | typeof CorrectStockPositionActionNotFoundProblemSchema.Type + | typeof CorrectStockPositionActionConflictProblemSchema.Type + | typeof CorrectStockPositionActionIneligibleProblemSchema.Type + | typeof CorrectStockPositionActionPreconditionProblemSchema.Type + | typeof CorrectStockPositionActionUnavailableProblemSchema.Type + | typeof CorrectStockPositionActionAlreadyCommittedProblemSchema.Type + | typeof CorrectStockPositionActionCommitIndeterminateProblemSchema.Type + | typeof CorrectStockPositionActionInternalProblemSchema.Type; + +export class CorrectStockPositionActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/CorrectStockPositionActionSchemaErrorMiddleware', + { error: CorrectStockPositionActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + CorrectStockPositionActionInvalidProblemSchema, + CorrectStockPositionActionAuthenticationProblemSchema, + CorrectStockPositionActionForbiddenProblemSchema, + CorrectStockPositionActionNotFoundProblemSchema, + CorrectStockPositionActionConflictProblemSchema, + CorrectStockPositionActionIneligibleProblemSchema, + CorrectStockPositionActionPreconditionProblemSchema, + CorrectStockPositionActionUnavailableProblemSchema, + CorrectStockPositionActionAlreadyCommittedProblemSchema, + CorrectStockPositionActionCommitIndeterminateProblemSchema, + CorrectStockPositionActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const correctStockPositionActionGroupDefinition = HttpApiGroup.make('correctStockPositionAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/correct-stock-position', { + error: actionErrors, + headers: CorrectStockPositionActionHeadersSchema, + payload: Schema.toEncoded(CorrectStockPositionPayloadSchema), + success: CorrectStockPositionResultSchema, + }), + ) + .middleware(CorrectStockPositionActionSchemaErrorMiddleware); + +export type CorrectStockPositionActionGroupContract = HttpApiGroup.HttpApiGroup< + 'correctStockPositionAction', + HttpApiGroup.Endpoints +>; + +const CorrectStockPositionActionGroup: CorrectStockPositionActionGroupContract = + correctStockPositionActionGroupDefinition; + +export const CorrectStockPositionActionApi = HttpApi.make('CorrectStockPositionActionApi').add( + CorrectStockPositionActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/create-inventory-reservation-action.ts b/app/verticals/inventory/shared/apis/create-inventory-reservation-action.ts new file mode 100644 index 000000000..0fae203b3 --- /dev/null +++ b/app/verticals/inventory/shared/apis/create-inventory-reservation-action.ts @@ -0,0 +1,175 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug create-inventory-reservation +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + CreateInventoryReservationPayloadSchema, + CreateInventoryReservationResultSchema, +} from '../actions/create-inventory-reservation.ts'; + +export { CreateInventoryReservationPayloadSchema } from '../actions/create-inventory-reservation.ts'; + +const CreateInventoryReservationActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const CreateInventoryReservationActionInvalidProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionInvalidProblem', + 400, +); +export const CreateInventoryReservationActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionAuthenticationProblem', + 401, +); +export const CreateInventoryReservationActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const CreateInventoryReservationActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const CreateInventoryReservationActionConflictProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'inventory_reservation_create_rejected', + ]), + }, +); +export const CreateInventoryReservationActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionIneligibleProblem', + 422, + { + code: Schema.Literals([ + 'action_policy_denied', + 'catalog_to_stock_binding_resolution_failure', + 'inventory_reservation_create_rejected', + 'inventory_reservation_guarantee_unsupported', + ]), + }, +); +export const CreateInventoryReservationActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionPreconditionProblem', + 428, +); +export const CreateInventoryReservationActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CreateInventoryReservationActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_reservation_create_unavailable', + ]), + }, +); +export const CreateInventoryReservationActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const CreateInventoryReservationActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const CreateInventoryReservationActionInternalProblemSchema = makeProblemDetailsSchema( + 'CreateInventoryReservationActionInternalProblem', + 500, +); + +export type CreateInventoryReservationActionProblem = + | typeof CreateInventoryReservationActionInvalidProblemSchema.Type + | typeof CreateInventoryReservationActionAuthenticationProblemSchema.Type + | typeof CreateInventoryReservationActionForbiddenProblemSchema.Type + | typeof CreateInventoryReservationActionNotFoundProblemSchema.Type + | typeof CreateInventoryReservationActionConflictProblemSchema.Type + | typeof CreateInventoryReservationActionIneligibleProblemSchema.Type + | typeof CreateInventoryReservationActionPreconditionProblemSchema.Type + | typeof CreateInventoryReservationActionUnavailableProblemSchema.Type + | typeof CreateInventoryReservationActionAlreadyCommittedProblemSchema.Type + | typeof CreateInventoryReservationActionCommitIndeterminateProblemSchema.Type + | typeof CreateInventoryReservationActionInternalProblemSchema.Type; + +export class CreateInventoryReservationActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/CreateInventoryReservationActionSchemaErrorMiddleware', + { error: CreateInventoryReservationActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + CreateInventoryReservationActionInvalidProblemSchema, + CreateInventoryReservationActionAuthenticationProblemSchema, + CreateInventoryReservationActionForbiddenProblemSchema, + CreateInventoryReservationActionNotFoundProblemSchema, + CreateInventoryReservationActionConflictProblemSchema, + CreateInventoryReservationActionIneligibleProblemSchema, + CreateInventoryReservationActionPreconditionProblemSchema, + CreateInventoryReservationActionUnavailableProblemSchema, + CreateInventoryReservationActionAlreadyCommittedProblemSchema, + CreateInventoryReservationActionCommitIndeterminateProblemSchema, + CreateInventoryReservationActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const createInventoryReservationActionGroupDefinition = HttpApiGroup.make('createInventoryReservationAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/create-inventory-reservation', { + error: actionErrors, + headers: CreateInventoryReservationActionHeadersSchema, + payload: Schema.toEncoded(CreateInventoryReservationPayloadSchema), + success: CreateInventoryReservationResultSchema, + }), + ) + .middleware(CreateInventoryReservationActionSchemaErrorMiddleware); + +export type CreateInventoryReservationActionGroupContract = HttpApiGroup.HttpApiGroup< + 'createInventoryReservationAction', + HttpApiGroup.Endpoints +>; + +const CreateInventoryReservationActionGroup: CreateInventoryReservationActionGroupContract = + createInventoryReservationActionGroupDefinition; + +export const CreateInventoryReservationActionApi = HttpApi.make('CreateInventoryReservationActionApi').add( + CreateInventoryReservationActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability-domain-policy-problem.ts b/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability-domain-policy-problem.ts new file mode 100644 index 000000000..8e51b722f --- /dev/null +++ b/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability-domain-policy-problem.ts @@ -0,0 +1,11 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; + +import { CurrentStockEvidenceForAvailabilityRejected } from '../domain/current-stock-evidence-for-availability.ts'; + +export const CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityDomainPolicyProblem', + 422, + { reasonCode: CurrentStockEvidenceForAvailabilityRejected.fields.reason }, +); +export type CurrentStockEvidenceForAvailabilityDomainPolicyProblem = + typeof CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability-domain-unavailable-problem.ts new file mode 100644 index 000000000..26e2a0a71 --- /dev/null +++ b/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('current_stock_evidence_for_availability_unavailable') }, +); +export type CurrentStockEvidenceForAvailabilityDomainUnavailableProblem = + typeof CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability.ts b/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability.ts new file mode 100644 index 000000000..7e210f1d8 --- /dev/null +++ b/app/verticals/inventory/shared/apis/current-stock-evidence-for-availability.ts @@ -0,0 +1,80 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { InventoryStockEvidenceForAvailabilitySchema } from '../domain/current-stock-evidence-for-availability.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema } from './current-stock-evidence-for-availability-domain-policy-problem.ts'; +import { CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema } from './current-stock-evidence-for-availability-domain-unavailable-problem.ts'; + +export { + type CurrentStockEvidenceForAvailabilityDomainPolicyProblem, + CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema, +} from './current-stock-evidence-for-availability-domain-policy-problem.ts'; +export { + type CurrentStockEvidenceForAvailabilityDomainUnavailableProblem, + CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema, +} from './current-stock-evidence-for-availability-domain-unavailable-problem.ts'; + +export const CurrentStockEvidenceForAvailabilityRequestSchema = Schema.Struct({ + positionRef: StockPositionRefSchema, +}); +export type CurrentStockEvidenceForAvailabilityRequest = typeof CurrentStockEvidenceForAvailabilityRequestSchema.Type; +export const CurrentStockEvidenceForAvailabilityResponseSchema = Schema.Struct({ + evidence: InventoryStockEvidenceForAvailabilitySchema, +}); +export type CurrentStockEvidenceForAvailabilityResponse = typeof CurrentStockEvidenceForAvailabilityResponseSchema.Type; + +export const CurrentStockEvidenceForAvailabilityAuthenticationProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityAuthenticationProblem', + 401, +); +export const CurrentStockEvidenceForAvailabilityInvalidProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityInvalidProblem', + 400, +); +export const CurrentStockEvidenceForAvailabilityUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityUnavailableProblem', + 503, +); +export const CurrentStockEvidenceForAvailabilityForbiddenProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityForbiddenProblem', + 403, +); +export const CurrentStockEvidenceForAvailabilityNotFoundProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityNotFoundProblem', + 404, +); +export const CurrentStockEvidenceForAvailabilityPolicyProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityPolicyProblem', + 422, +); +export const CurrentStockEvidenceForAvailabilityPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityPolicyConflictProblem', + 409, +); +export const CurrentStockEvidenceForAvailabilityInternalProblemSchema = makeProblemDetailsSchema( + 'CurrentStockEvidenceForAvailabilityInternalProblem', + 500, +); + +export const CurrentStockEvidenceForAvailabilityApi = HttpApi.make('CurrentStockEvidenceForAvailabilityApi').add( + HttpApiGroup.make('currentStockEvidenceForAvailability').add( + HttpApiEndpoint.post('execute', '/reads/current-stock-evidence-for-availability', { + error: [ + CurrentStockEvidenceForAvailabilityInvalidProblemSchema, + CurrentStockEvidenceForAvailabilityAuthenticationProblemSchema, + CurrentStockEvidenceForAvailabilityForbiddenProblemSchema, + CurrentStockEvidenceForAvailabilityNotFoundProblemSchema, + CurrentStockEvidenceForAvailabilityPolicyConflictProblemSchema, + CurrentStockEvidenceForAvailabilityPolicyProblemSchema, + CurrentStockEvidenceForAvailabilityDomainPolicyProblemSchema, + CurrentStockEvidenceForAvailabilityDomainUnavailableProblemSchema, + CurrentStockEvidenceForAvailabilityUnavailableProblemSchema, + CurrentStockEvidenceForAvailabilityInternalProblemSchema, + ], + payload: CurrentStockEvidenceForAvailabilityRequestSchema, + success: CurrentStockEvidenceForAvailabilityResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/end-catalog-to-stock-binding-action.ts b/app/verticals/inventory/shared/apis/end-catalog-to-stock-binding-action.ts new file mode 100644 index 000000000..beb5389b7 --- /dev/null +++ b/app/verticals/inventory/shared/apis/end-catalog-to-stock-binding-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-catalog-to-stock-binding +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EndCatalogToStockBindingPayloadSchema, + EndCatalogToStockBindingResultSchema, +} from '../actions/end-catalog-to-stock-binding.ts'; + +export { EndCatalogToStockBindingPayloadSchema } from '../actions/end-catalog-to-stock-binding.ts'; + +const EndCatalogToStockBindingActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EndCatalogToStockBindingActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionInvalidProblem', + 400, +); +export const EndCatalogToStockBindingActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionAuthenticationProblem', + 401, +); +export const EndCatalogToStockBindingActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EndCatalogToStockBindingActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EndCatalogToStockBindingActionConflictProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const EndCatalogToStockBindingActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'catalog_to_stock_binding_rejected']) }, +); +export const EndCatalogToStockBindingActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionPreconditionProblem', + 428, +); +export const EndCatalogToStockBindingActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EndCatalogToStockBindingActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'catalog_to_stock_binding_unavailable', + ]), + }, +); +export const EndCatalogToStockBindingActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EndCatalogToStockBindingActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EndCatalogToStockBindingActionInternalProblemSchema = makeProblemDetailsSchema( + 'EndCatalogToStockBindingActionInternalProblem', + 500, +); + +export type EndCatalogToStockBindingActionProblem = + | typeof EndCatalogToStockBindingActionInvalidProblemSchema.Type + | typeof EndCatalogToStockBindingActionAuthenticationProblemSchema.Type + | typeof EndCatalogToStockBindingActionForbiddenProblemSchema.Type + | typeof EndCatalogToStockBindingActionNotFoundProblemSchema.Type + | typeof EndCatalogToStockBindingActionConflictProblemSchema.Type + | typeof EndCatalogToStockBindingActionIneligibleProblemSchema.Type + | typeof EndCatalogToStockBindingActionPreconditionProblemSchema.Type + | typeof EndCatalogToStockBindingActionUnavailableProblemSchema.Type + | typeof EndCatalogToStockBindingActionAlreadyCommittedProblemSchema.Type + | typeof EndCatalogToStockBindingActionCommitIndeterminateProblemSchema.Type + | typeof EndCatalogToStockBindingActionInternalProblemSchema.Type; + +export class EndCatalogToStockBindingActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EndCatalogToStockBindingActionSchemaErrorMiddleware', + { error: EndCatalogToStockBindingActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EndCatalogToStockBindingActionInvalidProblemSchema, + EndCatalogToStockBindingActionAuthenticationProblemSchema, + EndCatalogToStockBindingActionForbiddenProblemSchema, + EndCatalogToStockBindingActionNotFoundProblemSchema, + EndCatalogToStockBindingActionConflictProblemSchema, + EndCatalogToStockBindingActionIneligibleProblemSchema, + EndCatalogToStockBindingActionPreconditionProblemSchema, + EndCatalogToStockBindingActionUnavailableProblemSchema, + EndCatalogToStockBindingActionAlreadyCommittedProblemSchema, + EndCatalogToStockBindingActionCommitIndeterminateProblemSchema, + EndCatalogToStockBindingActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const endCatalogToStockBindingActionGroupDefinition = HttpApiGroup.make('endCatalogToStockBindingAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/end-catalog-to-stock-binding', { + error: actionErrors, + headers: EndCatalogToStockBindingActionHeadersSchema, + payload: Schema.toEncoded(EndCatalogToStockBindingPayloadSchema), + success: EndCatalogToStockBindingResultSchema, + }), + ) + .middleware(EndCatalogToStockBindingActionSchemaErrorMiddleware); + +export type EndCatalogToStockBindingActionGroupContract = HttpApiGroup.HttpApiGroup< + 'endCatalogToStockBindingAction', + HttpApiGroup.Endpoints +>; + +const EndCatalogToStockBindingActionGroup: EndCatalogToStockBindingActionGroupContract = + endCatalogToStockBindingActionGroupDefinition; + +export const EndCatalogToStockBindingActionApi = HttpApi.make('EndCatalogToStockBindingActionApi').add( + EndCatalogToStockBindingActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/end-external-stock-correlation-action.ts b/app/verticals/inventory/shared/apis/end-external-stock-correlation-action.ts new file mode 100644 index 000000000..590a3b5a4 --- /dev/null +++ b/app/verticals/inventory/shared/apis/end-external-stock-correlation-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-external-stock-correlation +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EndExternalStockCorrelationPayloadSchema, + EndExternalStockCorrelationResultSchema, +} from '../actions/end-external-stock-correlation.ts'; + +export { EndExternalStockCorrelationPayloadSchema } from '../actions/end-external-stock-correlation.ts'; + +const EndExternalStockCorrelationActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EndExternalStockCorrelationActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionInvalidProblem', + 400, +); +export const EndExternalStockCorrelationActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionAuthenticationProblem', + 401, +); +export const EndExternalStockCorrelationActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EndExternalStockCorrelationActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EndExternalStockCorrelationActionConflictProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const EndExternalStockCorrelationActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'external_stock_correlation_rejected']) }, +); +export const EndExternalStockCorrelationActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionPreconditionProblem', + 428, +); +export const EndExternalStockCorrelationActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EndExternalStockCorrelationActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'external_stock_correlation_persistence_unavailable', + ]), + }, +); +export const EndExternalStockCorrelationActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EndExternalStockCorrelationActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EndExternalStockCorrelationActionInternalProblemSchema = makeProblemDetailsSchema( + 'EndExternalStockCorrelationActionInternalProblem', + 500, +); + +export type EndExternalStockCorrelationActionProblem = + | typeof EndExternalStockCorrelationActionInvalidProblemSchema.Type + | typeof EndExternalStockCorrelationActionAuthenticationProblemSchema.Type + | typeof EndExternalStockCorrelationActionForbiddenProblemSchema.Type + | typeof EndExternalStockCorrelationActionNotFoundProblemSchema.Type + | typeof EndExternalStockCorrelationActionConflictProblemSchema.Type + | typeof EndExternalStockCorrelationActionIneligibleProblemSchema.Type + | typeof EndExternalStockCorrelationActionPreconditionProblemSchema.Type + | typeof EndExternalStockCorrelationActionUnavailableProblemSchema.Type + | typeof EndExternalStockCorrelationActionAlreadyCommittedProblemSchema.Type + | typeof EndExternalStockCorrelationActionCommitIndeterminateProblemSchema.Type + | typeof EndExternalStockCorrelationActionInternalProblemSchema.Type; + +export class EndExternalStockCorrelationActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EndExternalStockCorrelationActionSchemaErrorMiddleware', + { error: EndExternalStockCorrelationActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EndExternalStockCorrelationActionInvalidProblemSchema, + EndExternalStockCorrelationActionAuthenticationProblemSchema, + EndExternalStockCorrelationActionForbiddenProblemSchema, + EndExternalStockCorrelationActionNotFoundProblemSchema, + EndExternalStockCorrelationActionConflictProblemSchema, + EndExternalStockCorrelationActionIneligibleProblemSchema, + EndExternalStockCorrelationActionPreconditionProblemSchema, + EndExternalStockCorrelationActionUnavailableProblemSchema, + EndExternalStockCorrelationActionAlreadyCommittedProblemSchema, + EndExternalStockCorrelationActionCommitIndeterminateProblemSchema, + EndExternalStockCorrelationActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const endExternalStockCorrelationActionGroupDefinition = HttpApiGroup.make('endExternalStockCorrelationAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/end-external-stock-correlation', { + error: actionErrors, + headers: EndExternalStockCorrelationActionHeadersSchema, + payload: Schema.toEncoded(EndExternalStockCorrelationPayloadSchema), + success: EndExternalStockCorrelationResultSchema, + }), + ) + .middleware(EndExternalStockCorrelationActionSchemaErrorMiddleware); + +export type EndExternalStockCorrelationActionGroupContract = HttpApiGroup.HttpApiGroup< + 'endExternalStockCorrelationAction', + HttpApiGroup.Endpoints +>; + +const EndExternalStockCorrelationActionGroup: EndExternalStockCorrelationActionGroupContract = + endExternalStockCorrelationActionGroupDefinition; + +export const EndExternalStockCorrelationActionApi = HttpApi.make('EndExternalStockCorrelationActionApi').add( + EndExternalStockCorrelationActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/end-stock-sharing-eligibility-action.ts b/app/verticals/inventory/shared/apis/end-stock-sharing-eligibility-action.ts new file mode 100644 index 000000000..6ca65034e --- /dev/null +++ b/app/verticals/inventory/shared/apis/end-stock-sharing-eligibility-action.ts @@ -0,0 +1,168 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-stock-sharing-eligibility +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EndStockSharingEligibilityPayloadSchema, + EndStockSharingEligibilityResultSchema, +} from '../actions/end-stock-sharing-eligibility.ts'; + +export { EndStockSharingEligibilityPayloadSchema } from '../actions/end-stock-sharing-eligibility.ts'; + +const EndStockSharingEligibilityActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EndStockSharingEligibilityActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionInvalidProblem', + 400, +); +export const EndStockSharingEligibilityActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionAuthenticationProblem', + 401, +); +export const EndStockSharingEligibilityActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EndStockSharingEligibilityActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EndStockSharingEligibilityActionConflictProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'stock_sharing_eligibility_lifecycle_rejected', + ]), + }, +); +export const EndStockSharingEligibilityActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'stock_sharing_eligibility_rejected']) }, +); +export const EndStockSharingEligibilityActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionPreconditionProblem', + 428, +); +export const EndStockSharingEligibilityActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EndStockSharingEligibilityActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'stock_sharing_eligibility_unavailable', + ]), + }, +); +export const EndStockSharingEligibilityActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EndStockSharingEligibilityActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EndStockSharingEligibilityActionInternalProblemSchema = makeProblemDetailsSchema( + 'EndStockSharingEligibilityActionInternalProblem', + 500, +); + +export type EndStockSharingEligibilityActionProblem = + | typeof EndStockSharingEligibilityActionInvalidProblemSchema.Type + | typeof EndStockSharingEligibilityActionAuthenticationProblemSchema.Type + | typeof EndStockSharingEligibilityActionForbiddenProblemSchema.Type + | typeof EndStockSharingEligibilityActionNotFoundProblemSchema.Type + | typeof EndStockSharingEligibilityActionConflictProblemSchema.Type + | typeof EndStockSharingEligibilityActionIneligibleProblemSchema.Type + | typeof EndStockSharingEligibilityActionPreconditionProblemSchema.Type + | typeof EndStockSharingEligibilityActionUnavailableProblemSchema.Type + | typeof EndStockSharingEligibilityActionAlreadyCommittedProblemSchema.Type + | typeof EndStockSharingEligibilityActionCommitIndeterminateProblemSchema.Type + | typeof EndStockSharingEligibilityActionInternalProblemSchema.Type; + +export class EndStockSharingEligibilityActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EndStockSharingEligibilityActionSchemaErrorMiddleware', + { error: EndStockSharingEligibilityActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EndStockSharingEligibilityActionInvalidProblemSchema, + EndStockSharingEligibilityActionAuthenticationProblemSchema, + EndStockSharingEligibilityActionForbiddenProblemSchema, + EndStockSharingEligibilityActionNotFoundProblemSchema, + EndStockSharingEligibilityActionConflictProblemSchema, + EndStockSharingEligibilityActionIneligibleProblemSchema, + EndStockSharingEligibilityActionPreconditionProblemSchema, + EndStockSharingEligibilityActionUnavailableProblemSchema, + EndStockSharingEligibilityActionAlreadyCommittedProblemSchema, + EndStockSharingEligibilityActionCommitIndeterminateProblemSchema, + EndStockSharingEligibilityActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const endStockSharingEligibilityActionGroupDefinition = HttpApiGroup.make('endStockSharingEligibilityAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/end-stock-sharing-eligibility', { + error: actionErrors, + headers: EndStockSharingEligibilityActionHeadersSchema, + payload: Schema.toEncoded(EndStockSharingEligibilityPayloadSchema), + success: EndStockSharingEligibilityResultSchema, + }), + ) + .middleware(EndStockSharingEligibilityActionSchemaErrorMiddleware); + +export type EndStockSharingEligibilityActionGroupContract = HttpApiGroup.HttpApiGroup< + 'endStockSharingEligibilityAction', + HttpApiGroup.Endpoints +>; + +const EndStockSharingEligibilityActionGroup: EndStockSharingEligibilityActionGroupContract = + endStockSharingEligibilityActionGroupDefinition; + +export const EndStockSharingEligibilityActionApi = HttpApi.make('EndStockSharingEligibilityActionApi').add( + EndStockSharingEligibilityActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/establish-catalog-to-stock-binding-action.ts b/app/verticals/inventory/shared/apis/establish-catalog-to-stock-binding-action.ts new file mode 100644 index 000000000..f0938459c --- /dev/null +++ b/app/verticals/inventory/shared/apis/establish-catalog-to-stock-binding-action.ts @@ -0,0 +1,164 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-catalog-to-stock-binding +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EstablishCatalogToStockBindingPayloadSchema, + EstablishCatalogToStockBindingResultSchema, +} from '../actions/establish-catalog-to-stock-binding.ts'; + +export { EstablishCatalogToStockBindingPayloadSchema } from '../actions/establish-catalog-to-stock-binding.ts'; + +const EstablishCatalogToStockBindingActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EstablishCatalogToStockBindingActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionInvalidProblem', + 400, +); +export const EstablishCatalogToStockBindingActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionAuthenticationProblem', + 401, +); +export const EstablishCatalogToStockBindingActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EstablishCatalogToStockBindingActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EstablishCatalogToStockBindingActionConflictProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const EstablishCatalogToStockBindingActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'catalog_to_stock_binding_rejected']) }, +); +export const EstablishCatalogToStockBindingActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionPreconditionProblem', + 428, +); +export const EstablishCatalogToStockBindingActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'catalog_to_stock_binding_unavailable', + ]), + }, +); +export const EstablishCatalogToStockBindingActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishCatalogToStockBindingActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishCatalogToStockBindingActionInternalProblemSchema = makeProblemDetailsSchema( + 'EstablishCatalogToStockBindingActionInternalProblem', + 500, +); + +export type EstablishCatalogToStockBindingActionProblem = + | typeof EstablishCatalogToStockBindingActionInvalidProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionAuthenticationProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionForbiddenProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionNotFoundProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionConflictProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionIneligibleProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionPreconditionProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionUnavailableProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionAlreadyCommittedProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionCommitIndeterminateProblemSchema.Type + | typeof EstablishCatalogToStockBindingActionInternalProblemSchema.Type; + +export class EstablishCatalogToStockBindingActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EstablishCatalogToStockBindingActionSchemaErrorMiddleware', + { error: EstablishCatalogToStockBindingActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EstablishCatalogToStockBindingActionInvalidProblemSchema, + EstablishCatalogToStockBindingActionAuthenticationProblemSchema, + EstablishCatalogToStockBindingActionForbiddenProblemSchema, + EstablishCatalogToStockBindingActionNotFoundProblemSchema, + EstablishCatalogToStockBindingActionConflictProblemSchema, + EstablishCatalogToStockBindingActionIneligibleProblemSchema, + EstablishCatalogToStockBindingActionPreconditionProblemSchema, + EstablishCatalogToStockBindingActionUnavailableProblemSchema, + EstablishCatalogToStockBindingActionAlreadyCommittedProblemSchema, + EstablishCatalogToStockBindingActionCommitIndeterminateProblemSchema, + EstablishCatalogToStockBindingActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const establishCatalogToStockBindingActionGroupDefinition = HttpApiGroup.make( + 'establishCatalogToStockBindingAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/establish-catalog-to-stock-binding', { + error: actionErrors, + headers: EstablishCatalogToStockBindingActionHeadersSchema, + payload: Schema.toEncoded(EstablishCatalogToStockBindingPayloadSchema), + success: EstablishCatalogToStockBindingResultSchema, + }), + ) + .middleware(EstablishCatalogToStockBindingActionSchemaErrorMiddleware); + +export type EstablishCatalogToStockBindingActionGroupContract = HttpApiGroup.HttpApiGroup< + 'establishCatalogToStockBindingAction', + HttpApiGroup.Endpoints +>; + +const EstablishCatalogToStockBindingActionGroup: EstablishCatalogToStockBindingActionGroupContract = + establishCatalogToStockBindingActionGroupDefinition; + +export const EstablishCatalogToStockBindingActionApi = HttpApi.make('EstablishCatalogToStockBindingActionApi').add( + EstablishCatalogToStockBindingActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/establish-commitment-protection-action.ts b/app/verticals/inventory/shared/apis/establish-commitment-protection-action.ts new file mode 100644 index 000000000..35fd3800f --- /dev/null +++ b/app/verticals/inventory/shared/apis/establish-commitment-protection-action.ts @@ -0,0 +1,170 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-commitment-protection +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EstablishCommitmentProtectionPayloadSchema, + EstablishCommitmentProtectionResultSchema, +} from '../actions/establish-commitment-protection.ts'; + +export { EstablishCommitmentProtectionPayloadSchema } from '../actions/establish-commitment-protection.ts'; + +const EstablishCommitmentProtectionActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EstablishCommitmentProtectionActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionInvalidProblem', + 400, +); +export const EstablishCommitmentProtectionActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionAuthenticationProblem', + 401, +); +export const EstablishCommitmentProtectionActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EstablishCommitmentProtectionActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EstablishCommitmentProtectionActionConflictProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'commitment_protection_conflict', + ]), + }, +); +export const EstablishCommitmentProtectionActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'commitment_protection_rejected']) }, +); +export const EstablishCommitmentProtectionActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionPreconditionProblem', + 428, +); +export const EstablishCommitmentProtectionActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EstablishCommitmentProtectionActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'commitment_protection_unavailable', + ]), + }, +); +export const EstablishCommitmentProtectionActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishCommitmentProtectionActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishCommitmentProtectionActionInternalProblemSchema = makeProblemDetailsSchema( + 'EstablishCommitmentProtectionActionInternalProblem', + 500, +); + +export type EstablishCommitmentProtectionActionProblem = + | typeof EstablishCommitmentProtectionActionInvalidProblemSchema.Type + | typeof EstablishCommitmentProtectionActionAuthenticationProblemSchema.Type + | typeof EstablishCommitmentProtectionActionForbiddenProblemSchema.Type + | typeof EstablishCommitmentProtectionActionNotFoundProblemSchema.Type + | typeof EstablishCommitmentProtectionActionConflictProblemSchema.Type + | typeof EstablishCommitmentProtectionActionIneligibleProblemSchema.Type + | typeof EstablishCommitmentProtectionActionPreconditionProblemSchema.Type + | typeof EstablishCommitmentProtectionActionUnavailableProblemSchema.Type + | typeof EstablishCommitmentProtectionActionAlreadyCommittedProblemSchema.Type + | typeof EstablishCommitmentProtectionActionCommitIndeterminateProblemSchema.Type + | typeof EstablishCommitmentProtectionActionInternalProblemSchema.Type; + +export class EstablishCommitmentProtectionActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EstablishCommitmentProtectionActionSchemaErrorMiddleware', + { error: EstablishCommitmentProtectionActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EstablishCommitmentProtectionActionInvalidProblemSchema, + EstablishCommitmentProtectionActionAuthenticationProblemSchema, + EstablishCommitmentProtectionActionForbiddenProblemSchema, + EstablishCommitmentProtectionActionNotFoundProblemSchema, + EstablishCommitmentProtectionActionConflictProblemSchema, + EstablishCommitmentProtectionActionIneligibleProblemSchema, + EstablishCommitmentProtectionActionPreconditionProblemSchema, + EstablishCommitmentProtectionActionUnavailableProblemSchema, + EstablishCommitmentProtectionActionAlreadyCommittedProblemSchema, + EstablishCommitmentProtectionActionCommitIndeterminateProblemSchema, + EstablishCommitmentProtectionActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const establishCommitmentProtectionActionGroupDefinition = HttpApiGroup.make( + 'establishCommitmentProtectionAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/establish-commitment-protection', { + error: actionErrors, + headers: EstablishCommitmentProtectionActionHeadersSchema, + payload: Schema.toEncoded(EstablishCommitmentProtectionPayloadSchema), + success: EstablishCommitmentProtectionResultSchema, + }), + ) + .middleware(EstablishCommitmentProtectionActionSchemaErrorMiddleware); + +export type EstablishCommitmentProtectionActionGroupContract = HttpApiGroup.HttpApiGroup< + 'establishCommitmentProtectionAction', + HttpApiGroup.Endpoints +>; + +const EstablishCommitmentProtectionActionGroup: EstablishCommitmentProtectionActionGroupContract = + establishCommitmentProtectionActionGroupDefinition; + +export const EstablishCommitmentProtectionActionApi = HttpApi.make('EstablishCommitmentProtectionActionApi').add( + EstablishCommitmentProtectionActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/establish-external-stock-correlation-action.ts b/app/verticals/inventory/shared/apis/establish-external-stock-correlation-action.ts new file mode 100644 index 000000000..4844ef96b --- /dev/null +++ b/app/verticals/inventory/shared/apis/establish-external-stock-correlation-action.ts @@ -0,0 +1,164 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-external-stock-correlation +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EstablishExternalStockCorrelationPayloadSchema, + EstablishExternalStockCorrelationResultSchema, +} from '../actions/establish-external-stock-correlation.ts'; + +export { EstablishExternalStockCorrelationPayloadSchema } from '../actions/establish-external-stock-correlation.ts'; + +const EstablishExternalStockCorrelationActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EstablishExternalStockCorrelationActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionInvalidProblem', + 400, +); +export const EstablishExternalStockCorrelationActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionAuthenticationProblem', + 401, +); +export const EstablishExternalStockCorrelationActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EstablishExternalStockCorrelationActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EstablishExternalStockCorrelationActionConflictProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const EstablishExternalStockCorrelationActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'external_stock_correlation_rejected']) }, +); +export const EstablishExternalStockCorrelationActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionPreconditionProblem', + 428, +); +export const EstablishExternalStockCorrelationActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'external_stock_correlation_persistence_unavailable', + ]), + }, +); +export const EstablishExternalStockCorrelationActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishExternalStockCorrelationActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishExternalStockCorrelationActionInternalProblemSchema = makeProblemDetailsSchema( + 'EstablishExternalStockCorrelationActionInternalProblem', + 500, +); + +export type EstablishExternalStockCorrelationActionProblem = + | typeof EstablishExternalStockCorrelationActionInvalidProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionAuthenticationProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionForbiddenProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionNotFoundProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionConflictProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionIneligibleProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionPreconditionProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionUnavailableProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionAlreadyCommittedProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionCommitIndeterminateProblemSchema.Type + | typeof EstablishExternalStockCorrelationActionInternalProblemSchema.Type; + +export class EstablishExternalStockCorrelationActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EstablishExternalStockCorrelationActionSchemaErrorMiddleware', + { error: EstablishExternalStockCorrelationActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EstablishExternalStockCorrelationActionInvalidProblemSchema, + EstablishExternalStockCorrelationActionAuthenticationProblemSchema, + EstablishExternalStockCorrelationActionForbiddenProblemSchema, + EstablishExternalStockCorrelationActionNotFoundProblemSchema, + EstablishExternalStockCorrelationActionConflictProblemSchema, + EstablishExternalStockCorrelationActionIneligibleProblemSchema, + EstablishExternalStockCorrelationActionPreconditionProblemSchema, + EstablishExternalStockCorrelationActionUnavailableProblemSchema, + EstablishExternalStockCorrelationActionAlreadyCommittedProblemSchema, + EstablishExternalStockCorrelationActionCommitIndeterminateProblemSchema, + EstablishExternalStockCorrelationActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const establishExternalStockCorrelationActionGroupDefinition = HttpApiGroup.make( + 'establishExternalStockCorrelationAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/establish-external-stock-correlation', { + error: actionErrors, + headers: EstablishExternalStockCorrelationActionHeadersSchema, + payload: Schema.toEncoded(EstablishExternalStockCorrelationPayloadSchema), + success: EstablishExternalStockCorrelationResultSchema, + }), + ) + .middleware(EstablishExternalStockCorrelationActionSchemaErrorMiddleware); + +export type EstablishExternalStockCorrelationActionGroupContract = HttpApiGroup.HttpApiGroup< + 'establishExternalStockCorrelationAction', + HttpApiGroup.Endpoints +>; + +const EstablishExternalStockCorrelationActionGroup: EstablishExternalStockCorrelationActionGroupContract = + establishExternalStockCorrelationActionGroupDefinition; + +export const EstablishExternalStockCorrelationActionApi = HttpApi.make( + 'EstablishExternalStockCorrelationActionApi', +).add(EstablishExternalStockCorrelationActionGroup); diff --git a/app/verticals/inventory/shared/apis/establish-stock-sharing-eligibility-action.ts b/app/verticals/inventory/shared/apis/establish-stock-sharing-eligibility-action.ts new file mode 100644 index 000000000..023a519e4 --- /dev/null +++ b/app/verticals/inventory/shared/apis/establish-stock-sharing-eligibility-action.ts @@ -0,0 +1,170 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-stock-sharing-eligibility +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + EstablishStockSharingEligibilityPayloadSchema, + EstablishStockSharingEligibilityResultSchema, +} from '../actions/establish-stock-sharing-eligibility.ts'; + +export { EstablishStockSharingEligibilityPayloadSchema } from '../actions/establish-stock-sharing-eligibility.ts'; + +const EstablishStockSharingEligibilityActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const EstablishStockSharingEligibilityActionInvalidProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionInvalidProblem', + 400, +); +export const EstablishStockSharingEligibilityActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionAuthenticationProblem', + 401, +); +export const EstablishStockSharingEligibilityActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const EstablishStockSharingEligibilityActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const EstablishStockSharingEligibilityActionConflictProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'stock_sharing_eligibility_lifecycle_rejected', + ]), + }, +); +export const EstablishStockSharingEligibilityActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'stock_sharing_eligibility_rejected']) }, +); +export const EstablishStockSharingEligibilityActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionPreconditionProblem', + 428, +); +export const EstablishStockSharingEligibilityActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'stock_sharing_eligibility_unavailable', + ]), + }, +); +export const EstablishStockSharingEligibilityActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishStockSharingEligibilityActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const EstablishStockSharingEligibilityActionInternalProblemSchema = makeProblemDetailsSchema( + 'EstablishStockSharingEligibilityActionInternalProblem', + 500, +); + +export type EstablishStockSharingEligibilityActionProblem = + | typeof EstablishStockSharingEligibilityActionInvalidProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionAuthenticationProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionForbiddenProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionNotFoundProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionConflictProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionIneligibleProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionPreconditionProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionUnavailableProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionAlreadyCommittedProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionCommitIndeterminateProblemSchema.Type + | typeof EstablishStockSharingEligibilityActionInternalProblemSchema.Type; + +export class EstablishStockSharingEligibilityActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/EstablishStockSharingEligibilityActionSchemaErrorMiddleware', + { error: EstablishStockSharingEligibilityActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + EstablishStockSharingEligibilityActionInvalidProblemSchema, + EstablishStockSharingEligibilityActionAuthenticationProblemSchema, + EstablishStockSharingEligibilityActionForbiddenProblemSchema, + EstablishStockSharingEligibilityActionNotFoundProblemSchema, + EstablishStockSharingEligibilityActionConflictProblemSchema, + EstablishStockSharingEligibilityActionIneligibleProblemSchema, + EstablishStockSharingEligibilityActionPreconditionProblemSchema, + EstablishStockSharingEligibilityActionUnavailableProblemSchema, + EstablishStockSharingEligibilityActionAlreadyCommittedProblemSchema, + EstablishStockSharingEligibilityActionCommitIndeterminateProblemSchema, + EstablishStockSharingEligibilityActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const establishStockSharingEligibilityActionGroupDefinition = HttpApiGroup.make( + 'establishStockSharingEligibilityAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/establish-stock-sharing-eligibility', { + error: actionErrors, + headers: EstablishStockSharingEligibilityActionHeadersSchema, + payload: Schema.toEncoded(EstablishStockSharingEligibilityPayloadSchema), + success: EstablishStockSharingEligibilityResultSchema, + }), + ) + .middleware(EstablishStockSharingEligibilityActionSchemaErrorMiddleware); + +export type EstablishStockSharingEligibilityActionGroupContract = HttpApiGroup.HttpApiGroup< + 'establishStockSharingEligibilityAction', + HttpApiGroup.Endpoints +>; + +const EstablishStockSharingEligibilityActionGroup: EstablishStockSharingEligibilityActionGroupContract = + establishStockSharingEligibilityActionGroupDefinition; + +export const EstablishStockSharingEligibilityActionApi = HttpApi.make('EstablishStockSharingEligibilityActionApi').add( + EstablishStockSharingEligibilityActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/import-source-assertion-action.ts b/app/verticals/inventory/shared/apis/import-source-assertion-action.ts new file mode 100644 index 000000000..bfe3e2c1a --- /dev/null +++ b/app/verticals/inventory/shared/apis/import-source-assertion-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug import-source-assertion +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + ImportSourceAssertionPayloadSchema, + ImportSourceAssertionResultSchema, +} from '../actions/import-source-assertion.ts'; + +export { ImportSourceAssertionPayloadSchema } from '../actions/import-source-assertion.ts'; + +const ImportSourceAssertionActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const ImportSourceAssertionActionInvalidProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionInvalidProblem', + 400, +); +export const ImportSourceAssertionActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionAuthenticationProblem', + 401, +); +export const ImportSourceAssertionActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const ImportSourceAssertionActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const ImportSourceAssertionActionConflictProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const ImportSourceAssertionActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'inventory_source_import_request_rejected']) }, +); +export const ImportSourceAssertionActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionPreconditionProblem', + 428, +); +export const ImportSourceAssertionActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'ImportSourceAssertionActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_source_import_unavailable', + ]), + }, +); +export const ImportSourceAssertionActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const ImportSourceAssertionActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const ImportSourceAssertionActionInternalProblemSchema = makeProblemDetailsSchema( + 'ImportSourceAssertionActionInternalProblem', + 500, +); + +export type ImportSourceAssertionActionProblem = + | typeof ImportSourceAssertionActionInvalidProblemSchema.Type + | typeof ImportSourceAssertionActionAuthenticationProblemSchema.Type + | typeof ImportSourceAssertionActionForbiddenProblemSchema.Type + | typeof ImportSourceAssertionActionNotFoundProblemSchema.Type + | typeof ImportSourceAssertionActionConflictProblemSchema.Type + | typeof ImportSourceAssertionActionIneligibleProblemSchema.Type + | typeof ImportSourceAssertionActionPreconditionProblemSchema.Type + | typeof ImportSourceAssertionActionUnavailableProblemSchema.Type + | typeof ImportSourceAssertionActionAlreadyCommittedProblemSchema.Type + | typeof ImportSourceAssertionActionCommitIndeterminateProblemSchema.Type + | typeof ImportSourceAssertionActionInternalProblemSchema.Type; + +export class ImportSourceAssertionActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/ImportSourceAssertionActionSchemaErrorMiddleware', + { error: ImportSourceAssertionActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + ImportSourceAssertionActionInvalidProblemSchema, + ImportSourceAssertionActionAuthenticationProblemSchema, + ImportSourceAssertionActionForbiddenProblemSchema, + ImportSourceAssertionActionNotFoundProblemSchema, + ImportSourceAssertionActionConflictProblemSchema, + ImportSourceAssertionActionIneligibleProblemSchema, + ImportSourceAssertionActionPreconditionProblemSchema, + ImportSourceAssertionActionUnavailableProblemSchema, + ImportSourceAssertionActionAlreadyCommittedProblemSchema, + ImportSourceAssertionActionCommitIndeterminateProblemSchema, + ImportSourceAssertionActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const importSourceAssertionActionGroupDefinition = HttpApiGroup.make('importSourceAssertionAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/import-source-assertion', { + error: actionErrors, + headers: ImportSourceAssertionActionHeadersSchema, + payload: Schema.toEncoded(ImportSourceAssertionPayloadSchema), + success: ImportSourceAssertionResultSchema, + }), + ) + .middleware(ImportSourceAssertionActionSchemaErrorMiddleware); + +export type ImportSourceAssertionActionGroupContract = HttpApiGroup.HttpApiGroup< + 'importSourceAssertionAction', + HttpApiGroup.Endpoints +>; + +const ImportSourceAssertionActionGroup: ImportSourceAssertionActionGroupContract = + importSourceAssertionActionGroupDefinition; + +export const ImportSourceAssertionActionApi = HttpApi.make('ImportSourceAssertionActionApi').add( + ImportSourceAssertionActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/inventory-backend-configuration-current-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/inventory-backend-configuration-current-domain-unavailable-problem.ts new file mode 100644 index 000000000..0bb1c6146 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-backend-configuration-current-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('inventory_backend_configuration_persistence_unavailable') }, +); +export type InventoryBackendConfigurationCurrentDomainUnavailableProblem = + typeof InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-backend-configuration-current.ts b/app/verticals/inventory/shared/apis/inventory-backend-configuration-current.ts new file mode 100644 index 000000000..a2a1de107 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-backend-configuration-current.ts @@ -0,0 +1,75 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { InventoryBackendConfigurationSchema } from '../domain/inventory-backend-configuration.ts'; +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema } from './inventory-backend-configuration-current-domain-unavailable-problem.ts'; + +export { + type InventoryBackendConfigurationCurrentDomainUnavailableProblem, + InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema, +} from './inventory-backend-configuration-current-domain-unavailable-problem.ts'; + +export const InventoryBackendConfigurationCurrentRequestSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, +}); +export type InventoryBackendConfigurationCurrentRequest = typeof InventoryBackendConfigurationCurrentRequestSchema.Type; +export const InventoryBackendConfigurationCurrentResponseSchema = Schema.Struct({ + configuration: InventoryBackendConfigurationSchema, +}); +export type InventoryBackendConfigurationCurrentResponse = + typeof InventoryBackendConfigurationCurrentResponseSchema.Type; + +export const InventoryBackendConfigurationCurrentAuthenticationProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentAuthenticationProblem', + 401, +); +export const InventoryBackendConfigurationCurrentInvalidProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentInvalidProblem', + 400, +); +export const InventoryBackendConfigurationCurrentUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentUnavailableProblem', + 503, +); +export const InventoryBackendConfigurationCurrentForbiddenProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentForbiddenProblem', + 403, +); +export const InventoryBackendConfigurationCurrentNotFoundProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentNotFoundProblem', + 404, +); +export const InventoryBackendConfigurationCurrentPolicyProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentPolicyProblem', + 422, +); +export const InventoryBackendConfigurationCurrentPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentPolicyConflictProblem', + 409, +); +export const InventoryBackendConfigurationCurrentInternalProblemSchema = makeProblemDetailsSchema( + 'InventoryBackendConfigurationCurrentInternalProblem', + 500, +); + +export const InventoryBackendConfigurationCurrentApi = HttpApi.make('InventoryBackendConfigurationCurrentApi').add( + HttpApiGroup.make('inventoryBackendConfigurationCurrent').add( + HttpApiEndpoint.post('execute', '/reads/inventory-backend-configuration-current', { + error: [ + InventoryBackendConfigurationCurrentInvalidProblemSchema, + InventoryBackendConfigurationCurrentAuthenticationProblemSchema, + InventoryBackendConfigurationCurrentForbiddenProblemSchema, + InventoryBackendConfigurationCurrentNotFoundProblemSchema, + InventoryBackendConfigurationCurrentPolicyConflictProblemSchema, + InventoryBackendConfigurationCurrentPolicyProblemSchema, + InventoryBackendConfigurationCurrentDomainUnavailableProblemSchema, + InventoryBackendConfigurationCurrentUnavailableProblemSchema, + InventoryBackendConfigurationCurrentInternalProblemSchema, + ], + payload: InventoryBackendConfigurationCurrentRequestSchema, + success: InventoryBackendConfigurationCurrentResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/inventory-effect-outcome-domain-conflict-problem.ts b/app/verticals/inventory/shared/apis/inventory-effect-outcome-domain-conflict-problem.ts new file mode 100644 index 000000000..0c9606e8b --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-effect-outcome-domain-conflict-problem.ts @@ -0,0 +1,9 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventoryEffectOutcomeDomainConflictProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomeDomainConflictProblem', + 409, + { reasonCode: Schema.Literals(['inventory_effect_ledger_conflict', 'inventory_effect_ledger_rejected']) }, +); +export type InventoryEffectOutcomeDomainConflictProblem = typeof InventoryEffectOutcomeDomainConflictProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-effect-outcome-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/inventory-effect-outcome-domain-unavailable-problem.ts new file mode 100644 index 000000000..682ad6a8a --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-effect-outcome-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventoryEffectOutcomeDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryEffectOutcomeDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('inventory_effect_ledger_unavailable') }, +); +export type InventoryEffectOutcomeDomainUnavailableProblem = + typeof InventoryEffectOutcomeDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-effect-outcome.ts b/app/verticals/inventory/shared/apis/inventory-effect-outcome.ts new file mode 100644 index 000000000..40a413dec --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-effect-outcome.ts @@ -0,0 +1,125 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Match, Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { + InventoryEffectLedgerEffectIdSchema, + InventoryEffectLedgerIntentSchema, + InventoryEffectLedgerResolutionSchema, +} from '../domain/inventory-effect-ledger.ts'; +import { InventoryEffectOutcomeDomainConflictProblemSchema } from './inventory-effect-outcome-domain-conflict-problem.ts'; +import { InventoryEffectOutcomeDomainUnavailableProblemSchema } from './inventory-effect-outcome-domain-unavailable-problem.ts'; + +export { + type InventoryEffectOutcomeDomainConflictProblem, + InventoryEffectOutcomeDomainConflictProblemSchema, +} from './inventory-effect-outcome-domain-conflict-problem.ts'; +export { + type InventoryEffectOutcomeDomainUnavailableProblem, + InventoryEffectOutcomeDomainUnavailableProblemSchema, +} from './inventory-effect-outcome-domain-unavailable-problem.ts'; + +export const InventoryEffectOutcomeRequestSchema = Schema.Struct({ + effectId: InventoryEffectLedgerEffectIdSchema, + intent: InventoryEffectLedgerIntentSchema, +}).check( + Schema.makeFilter(({ effectId, intent }) => + String(effectId) === String(intent.request.effectId) + ? undefined + : 'Inventory Effect lookup must retain the original effect identity from its exact intent', + ), +); +export type InventoryEffectOutcomeRequest = typeof InventoryEffectOutcomeRequestSchema.Type; +const effectOutcomeIdentity = { + effectId: InventoryEffectLedgerEffectIdSchema, + intent: InventoryEffectLedgerIntentSchema, +} as const; +export const InventoryEffectOutcomeResponseSchema = Schema.Union([ + Schema.TaggedStruct('UNRESOLVED', { + ...effectOutcomeIdentity, + currentState: Schema.Literal('REQUESTED'), + nextStep: Schema.Literal('RECOVER_ORIGINAL_EFFECT'), + }), + Schema.TaggedStruct('INDETERMINATE', { + ...effectOutcomeIdentity, + currentState: Schema.Literal('INDETERMINATE'), + nextStep: Schema.Literal('RECOVER_ORIGINAL_EFFECT'), + // oxlint-disable-next-line effect-native/no-nullable-schema-field -- The public outcome preserves the ledger's explicit null until owner recovery proves a resolution; expires: 2027-03-31. + resolution: Schema.NullOr(InventoryEffectLedgerResolutionSchema), + }), + Schema.TaggedStruct('RESOLVED', { + ...effectOutcomeIdentity, + currentState: Schema.Literals(['SUCCEEDED', 'REJECTED']), + nextStep: Schema.Literals(['CONTINUE', 'STOP']), + resolution: InventoryEffectLedgerResolutionSchema, + }), +]).check( + Schema.makeFilter((result) => + Match.value(result).pipe( + Match.tag('INDETERMINATE', () => true), + Match.tag('UNRESOLVED', () => true), + Match.tag('RESOLVED', ({ currentState, nextStep }) => + (currentState === 'SUCCEEDED' && nextStep === 'CONTINUE') || + (currentState === 'REJECTED' && nextStep === 'STOP') + ? undefined + : 'Resolved Inventory Effect outcome must preserve the terminal state safe next step', + ), + Match.exhaustive, + ), + ), +); +export type InventoryEffectOutcomeResponse = typeof InventoryEffectOutcomeResponseSchema.Type; + +export const InventoryEffectOutcomeAuthenticationProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomeAuthenticationProblem', + 401, +); +export const InventoryEffectOutcomeInvalidProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomeInvalidProblem', + 400, +); +export const InventoryEffectOutcomeUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryEffectOutcomeUnavailableProblem', + 503, +); +export const InventoryEffectOutcomeForbiddenProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomeForbiddenProblem', + 403, +); +export const InventoryEffectOutcomeNotFoundProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomeNotFoundProblem', + 404, +); +export const InventoryEffectOutcomePolicyProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomePolicyProblem', + 422, +); +export const InventoryEffectOutcomePolicyConflictProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomePolicyConflictProblem', + 409, +); +export const InventoryEffectOutcomeInternalProblemSchema = makeProblemDetailsSchema( + 'InventoryEffectOutcomeInternalProblem', + 500, +); + +export const InventoryEffectOutcomeApi = HttpApi.make('InventoryEffectOutcomeApi').add( + HttpApiGroup.make('inventoryEffectOutcome').add( + HttpApiEndpoint.post('execute', '/reads/inventory-effect-outcome', { + error: [ + InventoryEffectOutcomeInvalidProblemSchema, + InventoryEffectOutcomeAuthenticationProblemSchema, + InventoryEffectOutcomeForbiddenProblemSchema, + InventoryEffectOutcomeNotFoundProblemSchema, + InventoryEffectOutcomePolicyConflictProblemSchema, + InventoryEffectOutcomePolicyProblemSchema, + InventoryEffectOutcomeDomainConflictProblemSchema, + InventoryEffectOutcomeDomainUnavailableProblemSchema, + InventoryEffectOutcomeUnavailableProblemSchema, + InventoryEffectOutcomeInternalProblemSchema, + ], + payload: InventoryEffectOutcomeRequestSchema, + success: InventoryEffectOutcomeResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence-domain-policy-problem.ts b/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence-domain-policy-problem.ts new file mode 100644 index 000000000..9dfd78211 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence-domain-policy-problem.ts @@ -0,0 +1,10 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventoryReconciliationEvidenceDomainPolicyProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidenceDomainPolicyProblem', + 422, + { reasonCode: Schema.Literals(['CORRELATION_NOT_ENDED', 'EVIDENCE_LIMIT_EXCEEDED']) }, +); +export type InventoryReconciliationEvidenceDomainPolicyProblem = + typeof InventoryReconciliationEvidenceDomainPolicyProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence-domain-unavailable-problem.ts new file mode 100644 index 000000000..8f98defde --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventoryReconciliationEvidenceDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryReconciliationEvidenceDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('inventory_reconciliation_evidence_unavailable') }, +); +export type InventoryReconciliationEvidenceDomainUnavailableProblem = + typeof InventoryReconciliationEvidenceDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence.ts b/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence.ts new file mode 100644 index 000000000..79c887ba2 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reconciliation-evidence.ts @@ -0,0 +1,250 @@ +// @generated by OntOS Codesmith module-api v1 +import { PrivacyOwnerCoverageResultSchema, PrivacyOwnerScopeSchema } from '@app/shared-contracts'; +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Match, Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; + +import { CatalogToStockBindingHistoryEntrySchema } from '../domain/catalog-to-stock-binding.ts'; +import { CommitmentProtectionSchema } from '../domain/commitment-protection.ts'; +import { ExternalStockCorrelationSchema } from '../domain/external-stock-correlation.ts'; +import { + InventoryEffectLedgerEffectIdSchema, + InventoryEffectLedgerRecordSchema, +} from '../domain/inventory-effect-ledger.ts'; +import { InventorySourceConflictSchema } from '../domain/inventory-source-conflict.ts'; +import { ReservationConfirmationSchema } from '../domain/reservation-confirmation.ts'; +import { StockSharingEligibilitySchema } from '../domain/stock-sharing-eligibility.ts'; +import { CatalogToStockBindingRefSchema } from '../resources/catalog-to-stock-binding.ts'; +import { CommitmentProtectionRefSchema } from '../resources/commitment-protection.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { StockSharingEligibilityRefSchema } from '../resources/stock-sharing-eligibility.ts'; +import { inventoryPrivacyOwnerScopeParts } from '../inventory-privacy-owner-contract.ts'; +import { InventoryReconciliationEvidenceDomainPolicyProblemSchema } from './inventory-reconciliation-evidence-domain-policy-problem.ts'; +import { InventoryReconciliationEvidenceDomainUnavailableProblemSchema } from './inventory-reconciliation-evidence-domain-unavailable-problem.ts'; + +export { + type InventoryReconciliationEvidenceDomainPolicyProblem, + InventoryReconciliationEvidenceDomainPolicyProblemSchema, +} from './inventory-reconciliation-evidence-domain-policy-problem.ts'; +export { + type InventoryReconciliationEvidenceDomainUnavailableProblem, + InventoryReconciliationEvidenceDomainUnavailableProblemSchema, +} from './inventory-reconciliation-evidence-domain-unavailable-problem.ts'; + +export const INVENTORY_RECONCILIATION_EVIDENCE_LIMIT = 100; + +const BoundedBindingHistorySchema = Schema.Array(CatalogToStockBindingHistoryEntrySchema).check( + Schema.isMaxLength(INVENTORY_RECONCILIATION_EVIDENCE_LIMIT), +); +const BoundedSharingHistorySchema = Schema.Array(StockSharingEligibilitySchema).check( + Schema.isMaxLength(INVENTORY_RECONCILIATION_EVIDENCE_LIMIT), +); +const BoundedConfirmationHistorySchema = Schema.Array(ReservationConfirmationSchema).check( + Schema.isMaxLength(INVENTORY_RECONCILIATION_EVIDENCE_LIMIT), +); +const BoundedProtectionHistorySchema = Schema.Array(CommitmentProtectionSchema).check( + Schema.isMaxLength(INVENTORY_RECONCILIATION_EVIDENCE_LIMIT), +); + +const EffectOwnerRefSchema = Schema.Union([InventoryReservationRefSchema, StockPositionRefSchema]); + +const PrivacyLookupRefSchema = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(1000), Schema.isTrimmed()); + +export const InventoryPrivacyOwnerLookupSchema = Schema.Union([ + Schema.TaggedStruct('RESERVATION_OBLIGATION', { + lookupRef: PrivacyLookupRefSchema, + }), + Schema.TaggedStruct('BINDING_HISTORY', { + bindingRef: CatalogToStockBindingRefSchema, + lookupRef: PrivacyLookupRefSchema, + }), + Schema.TaggedStruct('CONFIRMATION_HISTORY', { + confirmationRef: ReservationConfirmationRefSchema, + lookupRef: PrivacyLookupRefSchema, + }), + Schema.TaggedStruct('PROTECTION_HISTORY', { + lookupRef: PrivacyLookupRefSchema, + protectionRef: CommitmentProtectionRefSchema, + }), + Schema.TaggedStruct('EFFECT_OUTCOME', { + effectId: InventoryEffectLedgerEffectIdSchema, + lookupRef: PrivacyLookupRefSchema, + }), + Schema.TaggedStruct('EXTERNAL_CORRELATION', { + correlationRef: ExternalStockCorrelationRefSchema, + lookupRef: PrivacyLookupRefSchema, + }), +]); +export type InventoryPrivacyOwnerLookup = typeof InventoryPrivacyOwnerLookupSchema.Type; + +const inventoryPrivacyOwnerScopeRefs = inventoryPrivacyOwnerScopeParts.map( + (scopePart) => `commerce.inventory/privacy-owner-scope/${scopePart}`, +); + +const hasExactReferenceSet = (left: readonly string[], right: readonly string[]): boolean => { + const rightSet = new Set(right); + return ( + left.length === right.length && rightSet.size === right.length && left.every((reference) => rightSet.has(reference)) + ); +}; + +const privacyLookupTenantId = (lookup: InventoryPrivacyOwnerLookup): null | string => + Match.value(lookup).pipe( + Match.tag('BINDING_HISTORY', ({ bindingRef }) => bindingRef.tenantId), + Match.tag('CONFIRMATION_HISTORY', ({ confirmationRef }) => confirmationRef.tenantId), + Match.tag('EXTERNAL_CORRELATION', ({ correlationRef }) => correlationRef.tenantId), + Match.tag('PROTECTION_HISTORY', ({ protectionRef }) => protectionRef.tenantId), + Match.tag('EFFECT_OUTCOME', () => null), + Match.tag('RESERVATION_OBLIGATION', () => null), + Match.exhaustive, + ); + +const InventoryPrivacyOwnerCoverageQuerySchema = Schema.TaggedStruct('PRIVACY_OWNER_COVERAGE', { + ownerRef: InventoryReservationRefSchema, + scope: PrivacyOwnerScopeSchema, + trustedLookups: Schema.Array(InventoryPrivacyOwnerLookupSchema).check( + Schema.isMaxLength(INVENTORY_RECONCILIATION_EVIDENCE_LIMIT), + ), +}).check( + Schema.makeFilter(({ ownerRef, scope, trustedLookups }) => { + const lookupRefs = trustedLookups.map((lookup: InventoryPrivacyOwnerLookup) => lookup.lookupRef); + if (scope.ownerCapability !== 'commerce.inventory') { + return { issue: 'privacy owner capability must be commerce.inventory', path: ['scope', 'ownerCapability'] }; + } + if (String(scope.tenantId) !== String(ownerRef.tenantId)) { + return { issue: 'privacy owner scope and owner Resource must share one Tenant', path: ['scope', 'tenantId'] }; + } + if (!hasExactReferenceSet(scope.requestedScopePartRefs, inventoryPrivacyOwnerScopeRefs)) { + return { + issue: 'privacy owner scope must request the exact Inventory owner responsibility set', + path: ['scope', 'requestedScopePartRefs'], + }; + } + if (!hasExactReferenceSet(scope.trustedLookupRefs, lookupRefs)) { + return { + issue: 'trusted Inventory lookup references must exactly match the typed owner lookups', + path: ['trustedLookups'], + }; + } + const hasCrossTenantLookup = trustedLookups.some((lookup: InventoryPrivacyOwnerLookup) => { + const lookupTenantId = privacyLookupTenantId(lookup); + return lookupTenantId !== null && lookupTenantId !== scope.tenantId; + }); + return hasCrossTenantLookup + ? { issue: 'every trusted Inventory lookup must remain in the authorized Tenant', path: ['trustedLookups'] } + : undefined; + }), +); + +export const InventoryReconciliationEvidenceQuerySchema = Schema.Union([ + Schema.TaggedStruct('BINDING_HISTORY', { bindingRef: CatalogToStockBindingRefSchema }), + Schema.TaggedStruct('ENDED_CORRELATION', { correlationRef: ExternalStockCorrelationRefSchema }), + Schema.TaggedStruct('SHARING_HISTORY', { relationRef: StockSharingEligibilityRefSchema }), + Schema.TaggedStruct('CONFIRMATION_HISTORY', { confirmationRef: ReservationConfirmationRefSchema }), + Schema.TaggedStruct('PROTECTION_HISTORY', { protectionRef: CommitmentProtectionRefSchema }), + Schema.TaggedStruct('EFFECT_OUTCOME', { + effectId: InventoryEffectLedgerEffectIdSchema, + ownerRef: EffectOwnerRefSchema, + }), + Schema.TaggedStruct('SOURCE_CONFLICT_DETAIL', { conflictRef: InventorySourceConflictRefSchema }), + InventoryPrivacyOwnerCoverageQuerySchema, +]); +export type InventoryReconciliationEvidenceQuery = typeof InventoryReconciliationEvidenceQuerySchema.Type; +export const InventoryReconciliationEvidenceRequestSchema = Schema.Struct({ + query: InventoryReconciliationEvidenceQuerySchema, +}); +export type InventoryReconciliationEvidenceRequest = typeof InventoryReconciliationEvidenceRequestSchema.Type; + +export const InventoryReconciliationEvidenceResponseSchema = Schema.Union([ + Schema.TaggedStruct('BINDING_HISTORY', { + bindingRef: CatalogToStockBindingRefSchema, + entries: BoundedBindingHistorySchema, + }), + Schema.TaggedStruct('ENDED_CORRELATION', { + correlation: ExternalStockCorrelationSchema, + correlationRef: ExternalStockCorrelationRefSchema, + }), + Schema.TaggedStruct('SHARING_HISTORY', { + entries: BoundedSharingHistorySchema, + relationRef: StockSharingEligibilityRefSchema, + }), + Schema.TaggedStruct('CONFIRMATION_HISTORY', { + confirmationRef: ReservationConfirmationRefSchema, + entries: BoundedConfirmationHistorySchema, + }), + Schema.TaggedStruct('PROTECTION_HISTORY', { + entries: BoundedProtectionHistorySchema, + protectionRef: CommitmentProtectionRefSchema, + }), + Schema.TaggedStruct('EFFECT_OUTCOME', { + ownerRef: EffectOwnerRefSchema, + record: InventoryEffectLedgerRecordSchema, + }), + Schema.TaggedStruct('SOURCE_CONFLICT_DETAIL', { + conflict: InventorySourceConflictSchema, + conflictRef: InventorySourceConflictRefSchema, + }), + Schema.TaggedStruct('PRIVACY_OWNER_COVERAGE', { + coverage: Schema.toEncoded(PrivacyOwnerCoverageResultSchema), + ownerRef: InventoryReservationRefSchema, + }), +]); +export type InventoryReconciliationEvidenceResponse = typeof InventoryReconciliationEvidenceResponseSchema.Type; + +export const InventoryReconciliationEvidenceAuthenticationProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidenceAuthenticationProblem', + 401, +); +export const InventoryReconciliationEvidenceInvalidProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidenceInvalidProblem', + 400, +); +export const InventoryReconciliationEvidenceUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryReconciliationEvidenceUnavailableProblem', + 503, +); +export const InventoryReconciliationEvidenceForbiddenProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidenceForbiddenProblem', + 403, +); +export const InventoryReconciliationEvidenceNotFoundProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidenceNotFoundProblem', + 404, +); +export const InventoryReconciliationEvidencePolicyProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidencePolicyProblem', + 422, +); +export const InventoryReconciliationEvidencePolicyConflictProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidencePolicyConflictProblem', + 409, +); +export const InventoryReconciliationEvidenceInternalProblemSchema = makeProblemDetailsSchema( + 'InventoryReconciliationEvidenceInternalProblem', + 500, +); + +export const InventoryReconciliationEvidenceApi = HttpApi.make('InventoryReconciliationEvidenceApi').add( + HttpApiGroup.make('inventoryReconciliationEvidence').add( + HttpApiEndpoint.post('execute', '/reads/inventory-reconciliation-evidence', { + error: [ + InventoryReconciliationEvidenceInvalidProblemSchema, + InventoryReconciliationEvidenceAuthenticationProblemSchema, + InventoryReconciliationEvidenceForbiddenProblemSchema, + InventoryReconciliationEvidenceNotFoundProblemSchema, + InventoryReconciliationEvidencePolicyConflictProblemSchema, + InventoryReconciliationEvidencePolicyProblemSchema, + InventoryReconciliationEvidenceDomainPolicyProblemSchema, + InventoryReconciliationEvidenceDomainUnavailableProblemSchema, + InventoryReconciliationEvidenceUnavailableProblemSchema, + InventoryReconciliationEvidenceInternalProblemSchema, + ], + payload: InventoryReconciliationEvidenceRequestSchema, + success: InventoryReconciliationEvidenceResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-conflict-problem.ts b/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-conflict-problem.ts new file mode 100644 index 000000000..d93f6e8a0 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-conflict-problem.ts @@ -0,0 +1,11 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; + +import { InventoryObligationRejected } from '../domain/inventory-obligation.ts'; + +export const InventoryReservationDetailDomainConflictProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailDomainConflictProblem', + 409, + { reasonCode: InventoryObligationRejected.fields.reason }, +); +export type InventoryReservationDetailDomainConflictProblem = + typeof InventoryReservationDetailDomainConflictProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-policy-problem.ts b/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-policy-problem.ts new file mode 100644 index 000000000..ae6da92a3 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-policy-problem.ts @@ -0,0 +1,11 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; + +import { InventoryObligationRejected } from '../domain/inventory-obligation.ts'; + +export const InventoryReservationDetailDomainPolicyProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailDomainPolicyProblem', + 422, + { reasonCode: InventoryObligationRejected.fields.reason }, +); +export type InventoryReservationDetailDomainPolicyProblem = + typeof InventoryReservationDetailDomainPolicyProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-unavailable-problem.ts new file mode 100644 index 000000000..273cd0895 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reservation-detail-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventoryReservationDetailDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryReservationDetailDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('inventory_obligation_persistence_unavailable') }, +); +export type InventoryReservationDetailDomainUnavailableProblem = + typeof InventoryReservationDetailDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-reservation-detail.ts b/app/verticals/inventory/shared/apis/inventory-reservation-detail.ts new file mode 100644 index 000000000..ace5759a1 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-reservation-detail.ts @@ -0,0 +1,94 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { + ProvisionalInventoryReservationSchema, + RuntimeCommittedInventoryObligationSchema, +} from '../domain/inventory-obligation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { InventoryReservationDetailDomainConflictProblemSchema } from './inventory-reservation-detail-domain-conflict-problem.ts'; +import { InventoryReservationDetailDomainPolicyProblemSchema } from './inventory-reservation-detail-domain-policy-problem.ts'; +import { InventoryReservationDetailDomainUnavailableProblemSchema } from './inventory-reservation-detail-domain-unavailable-problem.ts'; + +export { + type InventoryReservationDetailDomainConflictProblem, + InventoryReservationDetailDomainConflictProblemSchema, +} from './inventory-reservation-detail-domain-conflict-problem.ts'; +export { + type InventoryReservationDetailDomainPolicyProblem, + InventoryReservationDetailDomainPolicyProblemSchema, +} from './inventory-reservation-detail-domain-policy-problem.ts'; +export { + type InventoryReservationDetailDomainUnavailableProblem, + InventoryReservationDetailDomainUnavailableProblemSchema, +} from './inventory-reservation-detail-domain-unavailable-problem.ts'; + +export const RuntimeInventoryReservationSchema = Schema.Union([ + ProvisionalInventoryReservationSchema, + RuntimeCommittedInventoryObligationSchema, +]); + +export const InventoryReservationDetailRequestSchema = Schema.Struct({ + reservationRef: InventoryReservationRefSchema, +}); +export type InventoryReservationDetailRequest = typeof InventoryReservationDetailRequestSchema.Type; +export const InventoryReservationDetailResponseSchema = Schema.Struct({ + reservation: RuntimeInventoryReservationSchema, +}); +export type InventoryReservationDetailResponse = typeof InventoryReservationDetailResponseSchema.Type; + +export const InventoryReservationDetailAuthenticationProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailAuthenticationProblem', + 401, +); +export const InventoryReservationDetailInvalidProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailInvalidProblem', + 400, +); +export const InventoryReservationDetailUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventoryReservationDetailUnavailableProblem', + 503, +); +export const InventoryReservationDetailForbiddenProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailForbiddenProblem', + 403, +); +export const InventoryReservationDetailNotFoundProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailNotFoundProblem', + 404, +); +export const InventoryReservationDetailPolicyProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailPolicyProblem', + 422, +); +export const InventoryReservationDetailPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailPolicyConflictProblem', + 409, +); +export const InventoryReservationDetailInternalProblemSchema = makeProblemDetailsSchema( + 'InventoryReservationDetailInternalProblem', + 500, +); + +export const InventoryReservationDetailApi = HttpApi.make('InventoryReservationDetailApi').add( + HttpApiGroup.make('inventoryReservationDetail').add( + HttpApiEndpoint.post('execute', '/reads/inventory-reservation-detail', { + error: [ + InventoryReservationDetailInvalidProblemSchema, + InventoryReservationDetailAuthenticationProblemSchema, + InventoryReservationDetailForbiddenProblemSchema, + InventoryReservationDetailNotFoundProblemSchema, + InventoryReservationDetailPolicyConflictProblemSchema, + InventoryReservationDetailPolicyProblemSchema, + InventoryReservationDetailDomainConflictProblemSchema, + InventoryReservationDetailDomainPolicyProblemSchema, + InventoryReservationDetailDomainUnavailableProblemSchema, + InventoryReservationDetailUnavailableProblemSchema, + InventoryReservationDetailInternalProblemSchema, + ], + payload: InventoryReservationDetailRequestSchema, + success: InventoryReservationDetailResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/inventory-source-conflict-detail-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/inventory-source-conflict-detail-domain-unavailable-problem.ts new file mode 100644 index 000000000..72efa499a --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-source-conflict-detail-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const InventorySourceConflictDetailDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventorySourceConflictDetailDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('inventory_source_conflict_unavailable') }, +); +export type InventorySourceConflictDetailDomainUnavailableProblem = + typeof InventorySourceConflictDetailDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/inventory-source-conflict-detail.ts b/app/verticals/inventory/shared/apis/inventory-source-conflict-detail.ts new file mode 100644 index 000000000..586a3fe40 --- /dev/null +++ b/app/verticals/inventory/shared/apis/inventory-source-conflict-detail.ts @@ -0,0 +1,74 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { InventorySourceConflictSchema } from '../domain/inventory-source-conflict.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; +import { InventorySourceConflictDetailDomainUnavailableProblemSchema } from './inventory-source-conflict-detail-domain-unavailable-problem.ts'; + +export { + type InventorySourceConflictDetailDomainUnavailableProblem, + InventorySourceConflictDetailDomainUnavailableProblemSchema, +} from './inventory-source-conflict-detail-domain-unavailable-problem.ts'; + +export const InventorySourceConflictDetailRequestSchema = Schema.Struct({ + conflictRef: InventorySourceConflictRefSchema, +}); +export type InventorySourceConflictDetailRequest = typeof InventorySourceConflictDetailRequestSchema.Type; +export const InventorySourceConflictDetailResponseSchema = Schema.Struct({ + conflict: InventorySourceConflictSchema, +}); +export type InventorySourceConflictDetailResponse = typeof InventorySourceConflictDetailResponseSchema.Type; + +export const InventorySourceConflictDetailAuthenticationProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailAuthenticationProblem', + 401, +); +export const InventorySourceConflictDetailInvalidProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailInvalidProblem', + 400, +); +export const InventorySourceConflictDetailUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'InventorySourceConflictDetailUnavailableProblem', + 503, +); +export const InventorySourceConflictDetailForbiddenProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailForbiddenProblem', + 403, +); +export const InventorySourceConflictDetailNotFoundProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailNotFoundProblem', + 404, +); +export const InventorySourceConflictDetailPolicyProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailPolicyProblem', + 422, +); +export const InventorySourceConflictDetailPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailPolicyConflictProblem', + 409, +); +export const InventorySourceConflictDetailInternalProblemSchema = makeProblemDetailsSchema( + 'InventorySourceConflictDetailInternalProblem', + 500, +); + +export const InventorySourceConflictDetailApi = HttpApi.make('InventorySourceConflictDetailApi').add( + HttpApiGroup.make('inventorySourceConflictDetail').add( + HttpApiEndpoint.post('execute', '/reads/inventory-source-conflict-detail', { + error: [ + InventorySourceConflictDetailInvalidProblemSchema, + InventorySourceConflictDetailAuthenticationProblemSchema, + InventorySourceConflictDetailForbiddenProblemSchema, + InventorySourceConflictDetailNotFoundProblemSchema, + InventorySourceConflictDetailPolicyConflictProblemSchema, + InventorySourceConflictDetailPolicyProblemSchema, + InventorySourceConflictDetailDomainUnavailableProblemSchema, + InventorySourceConflictDetailUnavailableProblemSchema, + InventorySourceConflictDetailInternalProblemSchema, + ], + payload: InventorySourceConflictDetailRequestSchema, + success: InventorySourceConflictDetailResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/recover-inventory-effect-action.ts b/app/verticals/inventory/shared/apis/recover-inventory-effect-action.ts new file mode 100644 index 000000000..f7fe6b4ef --- /dev/null +++ b/app/verticals/inventory/shared/apis/recover-inventory-effect-action.ts @@ -0,0 +1,196 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug recover-inventory-effect +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + RecoverInventoryEffectPayloadSchema, + RecoverInventoryEffectResultSchema, +} from '../actions/recover-inventory-effect.ts'; + +export { RecoverInventoryEffectPayloadSchema } from '../actions/recover-inventory-effect.ts'; + +const RecoverInventoryEffectActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const RecoverInventoryEffectActionInvalidProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionInvalidProblem', + 400, +); +export const RecoverInventoryEffectActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionAuthenticationProblem', + 401, +); +export const RecoverInventoryEffectActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const RecoverInventoryEffectActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const RecoverInventoryEffectActionConflictProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'inventory_effect_ledger_conflict', + ]), + }, +); +export const RecoverInventoryEffectActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionIneligibleProblem', + 422, + { + code: Schema.Literals([ + 'action_policy_denied', + 'inventory_effect_ledger_rejected', + 'inventory_effect_recovery_rejected', + 'recover_inventory_effect_action_rejected', + ]), + }, +); +export const RecoverInventoryEffectActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionPreconditionProblem', + 428, +); +export const RecoverInventoryEffectActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'RecoverInventoryEffectActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_effect_ledger_unavailable', + ]), + }, +); +export const RecoverInventoryEffectActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const RecoverInventoryEffectActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const RecoverInventoryEffectActionInternalProblemSchema = makeProblemDetailsSchema( + 'RecoverInventoryEffectActionInternalProblem', + 500, +); + +export type RecoverInventoryEffectActionProblem = + | typeof RecoverInventoryEffectActionInvalidProblemSchema.Type + | typeof RecoverInventoryEffectActionAuthenticationProblemSchema.Type + | typeof RecoverInventoryEffectActionForbiddenProblemSchema.Type + | typeof RecoverInventoryEffectActionNotFoundProblemSchema.Type + | typeof RecoverInventoryEffectActionConflictProblemSchema.Type + | typeof RecoverInventoryEffectActionIneligibleProblemSchema.Type + | typeof RecoverInventoryEffectActionPreconditionProblemSchema.Type + | typeof RecoverInventoryEffectActionUnavailableProblemSchema.Type + | typeof RecoverInventoryEffectActionAlreadyCommittedProblemSchema.Type + | typeof RecoverInventoryEffectActionCommitIndeterminateProblemSchema.Type + | typeof RecoverInventoryEffectActionInternalProblemSchema.Type; + +export class RecoverInventoryEffectActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/RecoverInventoryEffectActionSchemaErrorMiddleware', + { error: RecoverInventoryEffectActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + RecoverInventoryEffectActionInvalidProblemSchema, + RecoverInventoryEffectActionAuthenticationProblemSchema, + RecoverInventoryEffectActionForbiddenProblemSchema, + RecoverInventoryEffectActionNotFoundProblemSchema, + RecoverInventoryEffectActionConflictProblemSchema, + RecoverInventoryEffectActionIneligibleProblemSchema, + RecoverInventoryEffectActionPreconditionProblemSchema, + RecoverInventoryEffectActionUnavailableProblemSchema, + RecoverInventoryEffectActionAlreadyCommittedProblemSchema, + RecoverInventoryEffectActionCommitIndeterminateProblemSchema, + RecoverInventoryEffectActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +type RecoverInventoryEffectActionEndpointContract = HttpApiEndpoint.HttpApiEndpoint< + 'execute', + 'POST', + '/inventory/actions/recover-inventory-effect', + never, + never, + Schema.toCodecJson>, + Schema.toCodecStringTree, + Schema.toCodecJson, + Schema.toCodecJson<(typeof actionErrors)[number]> +>; + +const recoverInventoryEffectActionEndpoint: RecoverInventoryEffectActionEndpointContract = HttpApiEndpoint.post( + 'execute', + '/inventory/actions/recover-inventory-effect', + { + error: actionErrors, + headers: RecoverInventoryEffectActionHeadersSchema, + payload: Schema.toEncoded(RecoverInventoryEffectPayloadSchema), + success: RecoverInventoryEffectResultSchema, + }, +); + +export type RecoverInventoryEffectActionGroupContract = HttpApiGroup.HttpApiGroup< + 'recoverInventoryEffectAction', + HttpApiEndpoint.AddMiddleware< + typeof recoverInventoryEffectActionEndpoint, + RecoverInventoryEffectActionSchemaErrorMiddleware + > +>; + +export const recoverInventoryEffectActionGroupDefinition: RecoverInventoryEffectActionGroupContract = HttpApiGroup.make( + 'recoverInventoryEffectAction', +) + .add(recoverInventoryEffectActionEndpoint) + .middleware(RecoverInventoryEffectActionSchemaErrorMiddleware); + +const RecoverInventoryEffectActionGroup: RecoverInventoryEffectActionGroupContract = + recoverInventoryEffectActionGroupDefinition; + +export const RecoverInventoryEffectActionApi = HttpApi.make('RecoverInventoryEffectActionApi').add( + RecoverInventoryEffectActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/release-inventory-reservation-action.ts b/app/verticals/inventory/shared/apis/release-inventory-reservation-action.ts new file mode 100644 index 000000000..3f142969e --- /dev/null +++ b/app/verticals/inventory/shared/apis/release-inventory-reservation-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug release-inventory-reservation +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + ReleaseInventoryReservationPayloadSchema, + ReleaseInventoryReservationResultSchema, +} from '../actions/release-inventory-reservation.ts'; + +export { ReleaseInventoryReservationPayloadSchema } from '../actions/release-inventory-reservation.ts'; + +const ReleaseInventoryReservationActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const ReleaseInventoryReservationActionInvalidProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionInvalidProblem', + 400, +); +export const ReleaseInventoryReservationActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionAuthenticationProblem', + 401, +); +export const ReleaseInventoryReservationActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const ReleaseInventoryReservationActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const ReleaseInventoryReservationActionConflictProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const ReleaseInventoryReservationActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'inventory_reservation_release_rejected']) }, +); +export const ReleaseInventoryReservationActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionPreconditionProblem', + 428, +); +export const ReleaseInventoryReservationActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'ReleaseInventoryReservationActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_reservation_release_unavailable', + ]), + }, +); +export const ReleaseInventoryReservationActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const ReleaseInventoryReservationActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const ReleaseInventoryReservationActionInternalProblemSchema = makeProblemDetailsSchema( + 'ReleaseInventoryReservationActionInternalProblem', + 500, +); + +export type ReleaseInventoryReservationActionProblem = + | typeof ReleaseInventoryReservationActionInvalidProblemSchema.Type + | typeof ReleaseInventoryReservationActionAuthenticationProblemSchema.Type + | typeof ReleaseInventoryReservationActionForbiddenProblemSchema.Type + | typeof ReleaseInventoryReservationActionNotFoundProblemSchema.Type + | typeof ReleaseInventoryReservationActionConflictProblemSchema.Type + | typeof ReleaseInventoryReservationActionIneligibleProblemSchema.Type + | typeof ReleaseInventoryReservationActionPreconditionProblemSchema.Type + | typeof ReleaseInventoryReservationActionUnavailableProblemSchema.Type + | typeof ReleaseInventoryReservationActionAlreadyCommittedProblemSchema.Type + | typeof ReleaseInventoryReservationActionCommitIndeterminateProblemSchema.Type + | typeof ReleaseInventoryReservationActionInternalProblemSchema.Type; + +export class ReleaseInventoryReservationActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/ReleaseInventoryReservationActionSchemaErrorMiddleware', + { error: ReleaseInventoryReservationActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + ReleaseInventoryReservationActionInvalidProblemSchema, + ReleaseInventoryReservationActionAuthenticationProblemSchema, + ReleaseInventoryReservationActionForbiddenProblemSchema, + ReleaseInventoryReservationActionNotFoundProblemSchema, + ReleaseInventoryReservationActionConflictProblemSchema, + ReleaseInventoryReservationActionIneligibleProblemSchema, + ReleaseInventoryReservationActionPreconditionProblemSchema, + ReleaseInventoryReservationActionUnavailableProblemSchema, + ReleaseInventoryReservationActionAlreadyCommittedProblemSchema, + ReleaseInventoryReservationActionCommitIndeterminateProblemSchema, + ReleaseInventoryReservationActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const releaseInventoryReservationActionGroupDefinition = HttpApiGroup.make('releaseInventoryReservationAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/release-inventory-reservation', { + error: actionErrors, + headers: ReleaseInventoryReservationActionHeadersSchema, + payload: Schema.toEncoded(ReleaseInventoryReservationPayloadSchema), + success: ReleaseInventoryReservationResultSchema, + }), + ) + .middleware(ReleaseInventoryReservationActionSchemaErrorMiddleware); + +export type ReleaseInventoryReservationActionGroupContract = HttpApiGroup.HttpApiGroup< + 'releaseInventoryReservationAction', + HttpApiGroup.Endpoints +>; + +const ReleaseInventoryReservationActionGroup: ReleaseInventoryReservationActionGroupContract = + releaseInventoryReservationActionGroupDefinition; + +export const ReleaseInventoryReservationActionApi = HttpApi.make('ReleaseInventoryReservationActionApi').add( + ReleaseInventoryReservationActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-conflict-problem.ts b/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-conflict-problem.ts new file mode 100644 index 000000000..aa7ff50cd --- /dev/null +++ b/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-conflict-problem.ts @@ -0,0 +1,11 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; + +import { ReservationConfirmationRejected } from '../domain/reservation-confirmation.ts'; + +export const ReservationConfirmationVerificationDomainConflictProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationDomainConflictProblem', + 409, + { reasonCode: ReservationConfirmationRejected.fields.reason }, +); +export type ReservationConfirmationVerificationDomainConflictProblem = + typeof ReservationConfirmationVerificationDomainConflictProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-policy-problem.ts b/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-policy-problem.ts new file mode 100644 index 000000000..900282278 --- /dev/null +++ b/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-policy-problem.ts @@ -0,0 +1,11 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; + +import { ReservationConfirmationRejected } from '../domain/reservation-confirmation.ts'; + +export const ReservationConfirmationVerificationDomainPolicyProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationDomainPolicyProblem', + 422, + { reasonCode: ReservationConfirmationRejected.fields.reason }, +); +export type ReservationConfirmationVerificationDomainPolicyProblem = + typeof ReservationConfirmationVerificationDomainPolicyProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-unavailable-problem.ts new file mode 100644 index 000000000..e5ebe98cb --- /dev/null +++ b/app/verticals/inventory/shared/apis/reservation-confirmation-verification-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const ReservationConfirmationVerificationDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'ReservationConfirmationVerificationDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('reservation_confirmation_unavailable') }, +); +export type ReservationConfirmationVerificationDomainUnavailableProblem = + typeof ReservationConfirmationVerificationDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/reservation-confirmation-verification.ts b/app/verticals/inventory/shared/apis/reservation-confirmation-verification.ts new file mode 100644 index 000000000..db7694812 --- /dev/null +++ b/app/verticals/inventory/shared/apis/reservation-confirmation-verification.ts @@ -0,0 +1,119 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { + ReservationConfirmationHealthSchema, + ReservationConfirmationHealthStateSchema, + ReservationConfirmationSchema, +} from '../domain/reservation-confirmation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; +import { ReservationConfirmationVerificationDomainConflictProblemSchema } from './reservation-confirmation-verification-domain-conflict-problem.ts'; +import { ReservationConfirmationVerificationDomainPolicyProblemSchema } from './reservation-confirmation-verification-domain-policy-problem.ts'; +import { ReservationConfirmationVerificationDomainUnavailableProblemSchema } from './reservation-confirmation-verification-domain-unavailable-problem.ts'; + +export { + type ReservationConfirmationVerificationDomainConflictProblem, + ReservationConfirmationVerificationDomainConflictProblemSchema, +} from './reservation-confirmation-verification-domain-conflict-problem.ts'; +export { + type ReservationConfirmationVerificationDomainPolicyProblem, + ReservationConfirmationVerificationDomainPolicyProblemSchema, +} from './reservation-confirmation-verification-domain-policy-problem.ts'; +export { + type ReservationConfirmationVerificationDomainUnavailableProblem, + ReservationConfirmationVerificationDomainUnavailableProblemSchema, +} from './reservation-confirmation-verification-domain-unavailable-problem.ts'; + +const verificationInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const ReservationConfirmationVerificationRequestSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + confirmationRef: ReservationConfirmationRefSchema, + evaluatedAt: verificationInstant, + reservationRef: InventoryReservationRefSchema, +}).check( + Schema.makeFilter(({ confirmationRef, reservationRef }) => + confirmationRef.tenantId === reservationRef.tenantId + ? undefined + : 'Reservation Confirmation and Reservation must belong to one Tenant', + ), +); +export type ReservationConfirmationVerificationRequest = typeof ReservationConfirmationVerificationRequestSchema.Type; + +export const ReservationConfirmationVerificationEvaluationSchema = Schema.Union([ + Schema.Struct({ outcome: Schema.Literal('READY_TO_ESTABLISH_PROTECTION') }), + Schema.Struct({ + outcome: Schema.Literal('TERMINAL_READINESS_LOSS'), + replacement: Schema.Literal('BLOCKED_UNTIL_PREDECESSOR_RESOLVED'), + }), + Schema.Struct({ + health: ReservationConfirmationHealthStateSchema, + outcome: Schema.Literal('NOT_READY'), + }), +]); + +export const ReservationConfirmationVerificationResponseSchema = Schema.Struct({ + current: ReservationConfirmationSchema, + evaluation: ReservationConfirmationVerificationEvaluationSchema, + health: ReservationConfirmationHealthSchema, + history: Schema.Array(ReservationConfirmationSchema).check(Schema.isMinLength(1)), +}); +export type ReservationConfirmationVerificationResponse = typeof ReservationConfirmationVerificationResponseSchema.Type; + +export const ReservationConfirmationVerificationAuthenticationProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationAuthenticationProblem', + 401, +); +export const ReservationConfirmationVerificationInvalidProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationInvalidProblem', + 400, +); +export const ReservationConfirmationVerificationUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'ReservationConfirmationVerificationUnavailableProblem', + 503, +); +export const ReservationConfirmationVerificationForbiddenProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationForbiddenProblem', + 403, +); +export const ReservationConfirmationVerificationNotFoundProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationNotFoundProblem', + 404, +); +export const ReservationConfirmationVerificationPolicyProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationPolicyProblem', + 422, +); +export const ReservationConfirmationVerificationPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationPolicyConflictProblem', + 409, +); +export const ReservationConfirmationVerificationInternalProblemSchema = makeProblemDetailsSchema( + 'ReservationConfirmationVerificationInternalProblem', + 500, +); + +export const ReservationConfirmationVerificationApi = HttpApi.make('ReservationConfirmationVerificationApi').add( + HttpApiGroup.make('reservationConfirmationVerification').add( + HttpApiEndpoint.post('execute', '/reads/reservation-confirmation-verification', { + error: [ + ReservationConfirmationVerificationInvalidProblemSchema, + ReservationConfirmationVerificationAuthenticationProblemSchema, + ReservationConfirmationVerificationForbiddenProblemSchema, + ReservationConfirmationVerificationNotFoundProblemSchema, + ReservationConfirmationVerificationPolicyConflictProblemSchema, + ReservationConfirmationVerificationPolicyProblemSchema, + ReservationConfirmationVerificationDomainConflictProblemSchema, + ReservationConfirmationVerificationDomainPolicyProblemSchema, + ReservationConfirmationVerificationDomainUnavailableProblemSchema, + ReservationConfirmationVerificationUnavailableProblemSchema, + ReservationConfirmationVerificationInternalProblemSchema, + ], + payload: ReservationConfirmationVerificationRequestSchema, + success: ReservationConfirmationVerificationResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/apis/resolve-inventory-source-conflict-action.ts b/app/verticals/inventory/shared/apis/resolve-inventory-source-conflict-action.ts new file mode 100644 index 000000000..d64b3d47e --- /dev/null +++ b/app/verticals/inventory/shared/apis/resolve-inventory-source-conflict-action.ts @@ -0,0 +1,170 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug resolve-inventory-source-conflict +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + ResolveInventorySourceConflictPayloadSchema, + ResolveInventorySourceConflictResultSchema, +} from '../actions/resolve-inventory-source-conflict.ts'; + +export { ResolveInventorySourceConflictPayloadSchema } from '../actions/resolve-inventory-source-conflict.ts'; + +const ResolveInventorySourceConflictActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const ResolveInventorySourceConflictActionInvalidProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionInvalidProblem', + 400, +); +export const ResolveInventorySourceConflictActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionAuthenticationProblem', + 401, +); +export const ResolveInventorySourceConflictActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const ResolveInventorySourceConflictActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionNotFoundProblem', + 404, + { code: Schema.Literals(['action_invocation_not_found', 'inventory_source_conflict_not_found']) }, +); +export const ResolveInventorySourceConflictActionConflictProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'inventory_source_conflict_rejected', + ]), + }, +); +export const ResolveInventorySourceConflictActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionIneligibleProblem', + 422, + { code: Schema.Literal('action_policy_denied') }, +); +export const ResolveInventorySourceConflictActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionPreconditionProblem', + 428, +); +export const ResolveInventorySourceConflictActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'ResolveInventorySourceConflictActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_source_conflict_unavailable', + ]), + }, +); +export const ResolveInventorySourceConflictActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const ResolveInventorySourceConflictActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const ResolveInventorySourceConflictActionInternalProblemSchema = makeProblemDetailsSchema( + 'ResolveInventorySourceConflictActionInternalProblem', + 500, +); + +export type ResolveInventorySourceConflictActionProblem = + | typeof ResolveInventorySourceConflictActionInvalidProblemSchema.Type + | typeof ResolveInventorySourceConflictActionAuthenticationProblemSchema.Type + | typeof ResolveInventorySourceConflictActionForbiddenProblemSchema.Type + | typeof ResolveInventorySourceConflictActionNotFoundProblemSchema.Type + | typeof ResolveInventorySourceConflictActionConflictProblemSchema.Type + | typeof ResolveInventorySourceConflictActionIneligibleProblemSchema.Type + | typeof ResolveInventorySourceConflictActionPreconditionProblemSchema.Type + | typeof ResolveInventorySourceConflictActionUnavailableProblemSchema.Type + | typeof ResolveInventorySourceConflictActionAlreadyCommittedProblemSchema.Type + | typeof ResolveInventorySourceConflictActionCommitIndeterminateProblemSchema.Type + | typeof ResolveInventorySourceConflictActionInternalProblemSchema.Type; + +export class ResolveInventorySourceConflictActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/ResolveInventorySourceConflictActionSchemaErrorMiddleware', + { error: ResolveInventorySourceConflictActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + ResolveInventorySourceConflictActionInvalidProblemSchema, + ResolveInventorySourceConflictActionAuthenticationProblemSchema, + ResolveInventorySourceConflictActionForbiddenProblemSchema, + ResolveInventorySourceConflictActionNotFoundProblemSchema, + ResolveInventorySourceConflictActionConflictProblemSchema, + ResolveInventorySourceConflictActionIneligibleProblemSchema, + ResolveInventorySourceConflictActionPreconditionProblemSchema, + ResolveInventorySourceConflictActionUnavailableProblemSchema, + ResolveInventorySourceConflictActionAlreadyCommittedProblemSchema, + ResolveInventorySourceConflictActionCommitIndeterminateProblemSchema, + ResolveInventorySourceConflictActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const resolveInventorySourceConflictActionGroupDefinition = HttpApiGroup.make( + 'resolveInventorySourceConflictAction', +) + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/resolve-inventory-source-conflict', { + error: actionErrors, + headers: ResolveInventorySourceConflictActionHeadersSchema, + payload: Schema.toEncoded(ResolveInventorySourceConflictPayloadSchema), + success: ResolveInventorySourceConflictResultSchema, + }), + ) + .middleware(ResolveInventorySourceConflictActionSchemaErrorMiddleware); + +export type ResolveInventorySourceConflictActionGroupContract = HttpApiGroup.HttpApiGroup< + 'resolveInventorySourceConflictAction', + HttpApiGroup.Endpoints +>; + +const ResolveInventorySourceConflictActionGroup: ResolveInventorySourceConflictActionGroupContract = + resolveInventorySourceConflictActionGroupDefinition; + +export const ResolveInventorySourceConflictActionApi = HttpApi.make('ResolveInventorySourceConflictActionApi').add( + ResolveInventorySourceConflictActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/select-inventory-backend-action.ts b/app/verticals/inventory/shared/apis/select-inventory-backend-action.ts new file mode 100644 index 000000000..f4089e665 --- /dev/null +++ b/app/verticals/inventory/shared/apis/select-inventory-backend-action.ts @@ -0,0 +1,162 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug select-inventory-backend +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { + SelectInventoryBackendPayloadSchema, + SelectInventoryBackendResultSchema, +} from '../actions/select-inventory-backend.ts'; + +export { SelectInventoryBackendPayloadSchema } from '../actions/select-inventory-backend.ts'; + +const SelectInventoryBackendActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const SelectInventoryBackendActionInvalidProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionInvalidProblem', + 400, +); +export const SelectInventoryBackendActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionAuthenticationProblem', + 401, +); +export const SelectInventoryBackendActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const SelectInventoryBackendActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const SelectInventoryBackendActionConflictProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionConflictProblem', + 409, + { code: Schema.Literals(['action_request_hash_conflict', 'action_invocation_state_invalid']) }, +); +export const SelectInventoryBackendActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'inventory_backend_selection_rejected']) }, +); +export const SelectInventoryBackendActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionPreconditionProblem', + 428, +); +export const SelectInventoryBackendActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'SelectInventoryBackendActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'inventory_backend_configuration_persistence_unavailable', + ]), + }, +); +export const SelectInventoryBackendActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const SelectInventoryBackendActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const SelectInventoryBackendActionInternalProblemSchema = makeProblemDetailsSchema( + 'SelectInventoryBackendActionInternalProblem', + 500, +); + +export type SelectInventoryBackendActionProblem = + | typeof SelectInventoryBackendActionInvalidProblemSchema.Type + | typeof SelectInventoryBackendActionAuthenticationProblemSchema.Type + | typeof SelectInventoryBackendActionForbiddenProblemSchema.Type + | typeof SelectInventoryBackendActionNotFoundProblemSchema.Type + | typeof SelectInventoryBackendActionConflictProblemSchema.Type + | typeof SelectInventoryBackendActionIneligibleProblemSchema.Type + | typeof SelectInventoryBackendActionPreconditionProblemSchema.Type + | typeof SelectInventoryBackendActionUnavailableProblemSchema.Type + | typeof SelectInventoryBackendActionAlreadyCommittedProblemSchema.Type + | typeof SelectInventoryBackendActionCommitIndeterminateProblemSchema.Type + | typeof SelectInventoryBackendActionInternalProblemSchema.Type; + +export class SelectInventoryBackendActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/SelectInventoryBackendActionSchemaErrorMiddleware', + { error: SelectInventoryBackendActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + SelectInventoryBackendActionInvalidProblemSchema, + SelectInventoryBackendActionAuthenticationProblemSchema, + SelectInventoryBackendActionForbiddenProblemSchema, + SelectInventoryBackendActionNotFoundProblemSchema, + SelectInventoryBackendActionConflictProblemSchema, + SelectInventoryBackendActionIneligibleProblemSchema, + SelectInventoryBackendActionPreconditionProblemSchema, + SelectInventoryBackendActionUnavailableProblemSchema, + SelectInventoryBackendActionAlreadyCommittedProblemSchema, + SelectInventoryBackendActionCommitIndeterminateProblemSchema, + SelectInventoryBackendActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const selectInventoryBackendActionGroupDefinition = HttpApiGroup.make('selectInventoryBackendAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/select-inventory-backend', { + error: actionErrors, + headers: SelectInventoryBackendActionHeadersSchema, + payload: Schema.toEncoded(SelectInventoryBackendPayloadSchema), + success: SelectInventoryBackendResultSchema, + }), + ) + .middleware(SelectInventoryBackendActionSchemaErrorMiddleware); + +export type SelectInventoryBackendActionGroupContract = HttpApiGroup.HttpApiGroup< + 'selectInventoryBackendAction', + HttpApiGroup.Endpoints +>; + +const SelectInventoryBackendActionGroup: SelectInventoryBackendActionGroupContract = + selectInventoryBackendActionGroupDefinition; + +export const SelectInventoryBackendActionApi = HttpApi.make('SelectInventoryBackendActionApi').add( + SelectInventoryBackendActionGroup, +); diff --git a/app/verticals/inventory/shared/apis/stock-issue-action.ts b/app/verticals/inventory/shared/apis/stock-issue-action.ts new file mode 100644 index 000000000..ef453ea39 --- /dev/null +++ b/app/verticals/inventory/shared/apis/stock-issue-action.ts @@ -0,0 +1,151 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-issue +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { StockIssuePayloadSchema, StockIssueResultSchema } from '../actions/stock-issue.ts'; + +export { StockIssuePayloadSchema } from '../actions/stock-issue.ts'; + +const StockIssueActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const StockIssueActionInvalidProblemSchema = makeProblemDetailsSchema('StockIssueActionInvalidProblem', 400); +export const StockIssueActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'StockIssueActionAuthenticationProblem', + 401, +); +export const StockIssueActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'StockIssueActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const StockIssueActionNotFoundProblemSchema = makeProblemDetailsSchema('StockIssueActionNotFoundProblem', 404, { + code: Schema.Literal('action_invocation_not_found'), +}); +export const StockIssueActionConflictProblemSchema = makeProblemDetailsSchema('StockIssueActionConflictProblem', 409, { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'physical_stock_effect_conflict', + ]), +}); +export const StockIssueActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'StockIssueActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'physical_stock_effect_rejected']) }, +); +export const StockIssueActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'StockIssueActionPreconditionProblem', + 428, +); +export const StockIssueActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'StockIssueActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'physical_stock_effect_indeterminate', + 'physical_stock_effect_unavailable', + ]), + }, +); +export const StockIssueActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'StockIssueActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const StockIssueActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'StockIssueActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const StockIssueActionInternalProblemSchema = makeProblemDetailsSchema('StockIssueActionInternalProblem', 500); + +export type StockIssueActionProblem = + | typeof StockIssueActionInvalidProblemSchema.Type + | typeof StockIssueActionAuthenticationProblemSchema.Type + | typeof StockIssueActionForbiddenProblemSchema.Type + | typeof StockIssueActionNotFoundProblemSchema.Type + | typeof StockIssueActionConflictProblemSchema.Type + | typeof StockIssueActionIneligibleProblemSchema.Type + | typeof StockIssueActionPreconditionProblemSchema.Type + | typeof StockIssueActionUnavailableProblemSchema.Type + | typeof StockIssueActionAlreadyCommittedProblemSchema.Type + | typeof StockIssueActionCommitIndeterminateProblemSchema.Type + | typeof StockIssueActionInternalProblemSchema.Type; + +export class StockIssueActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/StockIssueActionSchemaErrorMiddleware', + { error: StockIssueActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + StockIssueActionInvalidProblemSchema, + StockIssueActionAuthenticationProblemSchema, + StockIssueActionForbiddenProblemSchema, + StockIssueActionNotFoundProblemSchema, + StockIssueActionConflictProblemSchema, + StockIssueActionIneligibleProblemSchema, + StockIssueActionPreconditionProblemSchema, + StockIssueActionUnavailableProblemSchema, + StockIssueActionAlreadyCommittedProblemSchema, + StockIssueActionCommitIndeterminateProblemSchema, + StockIssueActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const stockIssueActionGroupDefinition = HttpApiGroup.make('stockIssueAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/stock-issue', { + error: actionErrors, + headers: StockIssueActionHeadersSchema, + payload: Schema.toEncoded(StockIssuePayloadSchema), + success: StockIssueResultSchema, + }), + ) + .middleware(StockIssueActionSchemaErrorMiddleware); + +export type StockIssueActionGroupContract = HttpApiGroup.HttpApiGroup< + 'stockIssueAction', + HttpApiGroup.Endpoints +>; + +const StockIssueActionGroup: StockIssueActionGroupContract = stockIssueActionGroupDefinition; + +export const StockIssueActionApi = HttpApi.make('StockIssueActionApi').add(StockIssueActionGroup); diff --git a/app/verticals/inventory/shared/apis/stock-receipt-action.ts b/app/verticals/inventory/shared/apis/stock-receipt-action.ts new file mode 100644 index 000000000..f41148462 --- /dev/null +++ b/app/verticals/inventory/shared/apis/stock-receipt-action.ts @@ -0,0 +1,160 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-receipt +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup, Schema } from '@modern-js/bff-effect/effect-client'; +import { HttpApiMiddleware } from 'effect/unstable/httpapi'; +import { StockReceiptPayloadSchema, StockReceiptResultSchema } from '../actions/stock-receipt.ts'; + +export { StockReceiptPayloadSchema } from '../actions/stock-receipt.ts'; + +const StockReceiptActionHeadersSchema = Schema.Struct({ + 'idempotency-key': Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))), +}); + +export const StockReceiptActionInvalidProblemSchema = makeProblemDetailsSchema('StockReceiptActionInvalidProblem', 400); +export const StockReceiptActionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionAuthenticationProblem', + 401, +); +export const StockReceiptActionForbiddenProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionForbiddenProblem', + 403, + { + code: Schema.Literals([ + 'action_permission_denied', + 'module_state_denied', + 'operation_context_denied', + 'operation_context_invalid', + ]), + }, +); +export const StockReceiptActionNotFoundProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionNotFoundProblem', + 404, + { code: Schema.Literal('action_invocation_not_found') }, +); +export const StockReceiptActionConflictProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionConflictProblem', + 409, + { + code: Schema.Literals([ + 'action_request_hash_conflict', + 'action_invocation_state_invalid', + 'physical_stock_effect_conflict', + ]), + }, +); +export const StockReceiptActionIneligibleProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionIneligibleProblem', + 422, + { code: Schema.Literals(['action_policy_denied', 'physical_stock_effect_rejected']) }, +); +export const StockReceiptActionPreconditionProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionPreconditionProblem', + 428, +); +export const StockReceiptActionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'StockReceiptActionUnavailableProblem', + 503, + { + code: Schema.Literals([ + 'action_invocation_persistence_failed', + 'action_permission_check_failed', + 'action_policy_evaluation_failed', + 'action_transaction_failed', + 'module_state_check_unavailable', + 'operation_context_unavailable', + 'physical_stock_effect_indeterminate', + 'physical_stock_effect_unavailable', + ]), + }, +); +export const StockReceiptActionAlreadyCommittedProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionAlreadyCommittedProblem', + 409, + { + code: Schema.Literal('action_already_committed'), + invocationId: Schema.String, + resolution: Schema.Literal('REFRESH_GOVERNED_READS'), + retryCommand: Schema.Literal(false), + }, +); +export const StockReceiptActionCommitIndeterminateProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionCommitIndeterminateProblem', + 503, + { + invocationId: Schema.String, + resolution: Schema.Literal('RESOLVE_COMMIT'), + retryCommand: Schema.Literal(false), + }, +); +export const StockReceiptActionInternalProblemSchema = makeProblemDetailsSchema( + 'StockReceiptActionInternalProblem', + 500, +); + +export type StockReceiptActionProblem = + | typeof StockReceiptActionInvalidProblemSchema.Type + | typeof StockReceiptActionAuthenticationProblemSchema.Type + | typeof StockReceiptActionForbiddenProblemSchema.Type + | typeof StockReceiptActionNotFoundProblemSchema.Type + | typeof StockReceiptActionConflictProblemSchema.Type + | typeof StockReceiptActionIneligibleProblemSchema.Type + | typeof StockReceiptActionPreconditionProblemSchema.Type + | typeof StockReceiptActionUnavailableProblemSchema.Type + | typeof StockReceiptActionAlreadyCommittedProblemSchema.Type + | typeof StockReceiptActionCommitIndeterminateProblemSchema.Type + | typeof StockReceiptActionInternalProblemSchema.Type; + +export class StockReceiptActionSchemaErrorMiddleware extends HttpApiMiddleware.Service()( + 'inventory/StockReceiptActionSchemaErrorMiddleware', + { error: StockReceiptActionInvalidProblemSchema }, +) {} + +const actionErrors = [ + StockReceiptActionInvalidProblemSchema, + StockReceiptActionAuthenticationProblemSchema, + StockReceiptActionForbiddenProblemSchema, + StockReceiptActionNotFoundProblemSchema, + StockReceiptActionConflictProblemSchema, + StockReceiptActionIneligibleProblemSchema, + StockReceiptActionPreconditionProblemSchema, + StockReceiptActionUnavailableProblemSchema, + StockReceiptActionAlreadyCommittedProblemSchema, + StockReceiptActionCommitIndeterminateProblemSchema, + StockReceiptActionInternalProblemSchema, +] as const; + +/** + * The endpoint chain stays a `const`. The MicroVertical API boundary checker walks a root API's + * operands through const bindings only, so a class declaration hides the composed endpoints from + * it. The exported group is annotated with a named type alias so its type still has a name: the + * vertical's `shared/api.ts` merges every group type into one `HttpApi` and declaration emit + * serializes that union verbatim, so an anonymous group type pushes the composed contract past + * the compiler's serialization limit (TS7056). + * + * Exported only so the named contract type can reference it; the merged vertical HttpApi prints + * this group by name (declaration-emit size). + * + * @public + */ +export const stockReceiptActionGroupDefinition = HttpApiGroup.make('stockReceiptAction') + .add( + HttpApiEndpoint.post('execute', '/inventory/actions/stock-receipt', { + error: actionErrors, + headers: StockReceiptActionHeadersSchema, + payload: Schema.toEncoded(StockReceiptPayloadSchema), + success: StockReceiptResultSchema, + }), + ) + .middleware(StockReceiptActionSchemaErrorMiddleware); + +export type StockReceiptActionGroupContract = HttpApiGroup.HttpApiGroup< + 'stockReceiptAction', + HttpApiGroup.Endpoints +>; + +const StockReceiptActionGroup: StockReceiptActionGroupContract = stockReceiptActionGroupDefinition; + +export const StockReceiptActionApi = HttpApi.make('StockReceiptActionApi').add(StockReceiptActionGroup); diff --git a/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution-domain-policy-problem.ts b/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution-domain-policy-problem.ts new file mode 100644 index 000000000..2c70ccb0f --- /dev/null +++ b/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution-domain-policy-problem.ts @@ -0,0 +1,11 @@ +import { makeProblemDetailsSchema } from '@app/shared-contracts/problem-details'; + +import { StockSharingEligibilityRejected } from '../domain/stock-sharing-eligibility.ts'; + +export const StockSharingEligibilityResolutionDomainPolicyProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionDomainPolicyProblem', + 422, + { reasonCode: StockSharingEligibilityRejected.fields.reason }, +); +export type StockSharingEligibilityResolutionDomainPolicyProblem = + typeof StockSharingEligibilityResolutionDomainPolicyProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution-domain-unavailable-problem.ts b/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution-domain-unavailable-problem.ts new file mode 100644 index 000000000..6a82a1b10 --- /dev/null +++ b/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution-domain-unavailable-problem.ts @@ -0,0 +1,10 @@ +import { makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; + +export const StockSharingEligibilityResolutionDomainUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'StockSharingEligibilityResolutionDomainUnavailableProblem', + 503, + { reasonCode: Schema.Literal('stock_sharing_eligibility_unavailable') }, +); +export type StockSharingEligibilityResolutionDomainUnavailableProblem = + typeof StockSharingEligibilityResolutionDomainUnavailableProblemSchema.Type; diff --git a/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution.ts b/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution.ts new file mode 100644 index 000000000..dbd477fa2 --- /dev/null +++ b/app/verticals/inventory/shared/apis/stock-sharing-eligibility-resolution.ts @@ -0,0 +1,85 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeProblemDetailsSchema, makeRetryableProblemDetailsSchema } from '@app/shared-contracts/problem-details'; +import { Schema } from 'effect'; +import { HttpApi, HttpApiEndpoint, HttpApiGroup } from 'effect/unstable/httpapi'; +import { + StockSharingCommerceContextEvidenceSchema, + StockSharingEligibilityDecisionSchema, + StockSharingEligibilityScopeSchema, +} from '../domain/stock-sharing-eligibility.ts'; +import { StockSharingEligibilityResolutionDomainPolicyProblemSchema } from './stock-sharing-eligibility-resolution-domain-policy-problem.ts'; +import { StockSharingEligibilityResolutionDomainUnavailableProblemSchema } from './stock-sharing-eligibility-resolution-domain-unavailable-problem.ts'; + +export { + type StockSharingEligibilityResolutionDomainPolicyProblem, + StockSharingEligibilityResolutionDomainPolicyProblemSchema, +} from './stock-sharing-eligibility-resolution-domain-policy-problem.ts'; +export { + type StockSharingEligibilityResolutionDomainUnavailableProblem, + StockSharingEligibilityResolutionDomainUnavailableProblemSchema, +} from './stock-sharing-eligibility-resolution-domain-unavailable-problem.ts'; + +export const StockSharingEligibilityResolutionRequestSchema = Schema.Struct({ + /** Commerce-owner evidence, not caller-authenticated truth established by this Read. */ + commerceContextEvidence: StockSharingCommerceContextEvidenceSchema, + scope: StockSharingEligibilityScopeSchema, +}); +export type StockSharingEligibilityResolutionRequest = typeof StockSharingEligibilityResolutionRequestSchema.Type; +export const StockSharingEligibilityResolutionResponseSchema = Schema.Struct({ + decision: StockSharingEligibilityDecisionSchema, +}); +export type StockSharingEligibilityResolutionResponse = typeof StockSharingEligibilityResolutionResponseSchema.Type; + +export const StockSharingEligibilityResolutionAuthenticationProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionAuthenticationProblem', + 401, +); +export const StockSharingEligibilityResolutionInvalidProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionInvalidProblem', + 400, +); +export const StockSharingEligibilityResolutionUnavailableProblemSchema = makeRetryableProblemDetailsSchema( + 'StockSharingEligibilityResolutionUnavailableProblem', + 503, +); +export const StockSharingEligibilityResolutionForbiddenProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionForbiddenProblem', + 403, +); +export const StockSharingEligibilityResolutionNotFoundProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionNotFoundProblem', + 404, +); +export const StockSharingEligibilityResolutionPolicyProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionPolicyProblem', + 422, +); +export const StockSharingEligibilityResolutionPolicyConflictProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionPolicyConflictProblem', + 409, +); +export const StockSharingEligibilityResolutionInternalProblemSchema = makeProblemDetailsSchema( + 'StockSharingEligibilityResolutionInternalProblem', + 500, +); + +export const StockSharingEligibilityResolutionApi = HttpApi.make('StockSharingEligibilityResolutionApi').add( + HttpApiGroup.make('stockSharingEligibilityResolution').add( + HttpApiEndpoint.post('execute', '/reads/stock-sharing-eligibility-resolution', { + error: [ + StockSharingEligibilityResolutionInvalidProblemSchema, + StockSharingEligibilityResolutionAuthenticationProblemSchema, + StockSharingEligibilityResolutionForbiddenProblemSchema, + StockSharingEligibilityResolutionNotFoundProblemSchema, + StockSharingEligibilityResolutionPolicyConflictProblemSchema, + StockSharingEligibilityResolutionPolicyProblemSchema, + StockSharingEligibilityResolutionDomainPolicyProblemSchema, + StockSharingEligibilityResolutionDomainUnavailableProblemSchema, + StockSharingEligibilityResolutionUnavailableProblemSchema, + StockSharingEligibilityResolutionInternalProblemSchema, + ], + payload: StockSharingEligibilityResolutionRequestSchema, + success: StockSharingEligibilityResolutionResponseSchema, + }), + ), +); diff --git a/app/verticals/inventory/shared/domain/catalog-binding-correction-rejected.ts b/app/verticals/inventory/shared/domain/catalog-binding-correction-rejected.ts new file mode 100644 index 000000000..b90a252d0 --- /dev/null +++ b/app/verticals/inventory/shared/domain/catalog-binding-correction-rejected.ts @@ -0,0 +1,16 @@ +import { Schema } from 'effect'; + +export class CatalogBindingCorrectionRejected extends Schema.TaggedError()( + 'CatalogBindingCorrectionRejected', + { + code: Schema.Literal('catalog_binding_correction_rejected'), + reason: Schema.Literals([ + 'INVALID_CORRECTION_TRANSITION', + 'AFFECTED_ALLOCATION_NOT_FOUND', + 'AFFECTED_ALLOCATION_LINEAGE_MISMATCH', + 'CONFIRMATION_SCOPE_MISMATCH', + 'PROTECTION_SCOPE_MISMATCH', + 'COMMITTED_SCOPE_MISMATCH', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/catalog-to-stock-binding-resolution.ts b/app/verticals/inventory/shared/domain/catalog-to-stock-binding-resolution.ts new file mode 100644 index 000000000..e0ac15141 --- /dev/null +++ b/app/verticals/inventory/shared/domain/catalog-to-stock-binding-resolution.ts @@ -0,0 +1,330 @@ +import { Effect, Match, Schema } from 'effect'; + +import { + CatalogToStockBindingLifecycleEvidenceSchema, + CatalogToStockBindingSchema, +} from './catalog-to-stock-binding.ts'; +import type { + CatalogToStockBinding, + CatalogToStockBindingHistoryEntrySchema, + CatalogToStockBindingRejected, +} from './catalog-to-stock-binding.ts'; +import { CatalogBindingCorrectionRejected } from './catalog-binding-correction-rejected.ts'; +import { CommittedInventoryObligationSchema } from './inventory-authority.ts'; +import { + AuthoritativeReservationEvidenceSchema, + ReservationAuthorityAllocationSchema, + ReservationAuthorityExactScopeSchema, +} from './reservation-authority.ts'; +import type { AuthoritativeReservationEvidence, ReservationAuthorityExactScope } from './reservation-authority.ts'; + +const resolutionFailureReasons = [ + 'MISSING_BINDING', + 'MULTIPLE_CURRENT_BINDINGS', + 'INTRINSIC_MEANING_MISMATCH', + 'STOCK_ITEM_NOT_FOUND', + 'STOCK_ITEM_NOT_CURRENT', + 'STOCK_UNIT_MISMATCH', +] as const; + +export class CatalogToStockBindingResolutionFailure extends Schema.TaggedError()( + 'CatalogToStockBindingResolutionFailure', + { + bindingRef: Schema.optionalKey(CatalogToStockBindingSchema.fields.bindingRef), + code: Schema.Literal('catalog_to_stock_binding_resolution_failure'), + outcome: Schema.Literals(['MISSING', 'CONFLICTING', 'INCOMPATIBLE']), + reason: Schema.Literals(resolutionFailureReasons), + stockItemRef: Schema.optionalKey(CatalogToStockBindingSchema.fields.stockItemRef), + }, +) {} + +const resolutionOutcomeFor = ( + reason: (typeof resolutionFailureReasons)[number], +): CatalogToStockBindingResolutionFailure['outcome'] => { + if (reason === 'MULTIPLE_CURRENT_BINDINGS') { + return 'CONFLICTING'; + } + if (reason === 'INTRINSIC_MEANING_MISMATCH' || reason === 'STOCK_UNIT_MISMATCH') { + return 'INCOMPATIBLE'; + } + return 'MISSING'; +}; + +const failResolution = (failure: CatalogToStockBindingRejected, reason: (typeof resolutionFailureReasons)[number]) => { + const fields = { + code: 'catalog_to_stock_binding_resolution_failure' as const, + outcome: resolutionOutcomeFor(reason), + reason, + }; + if (failure.bindingRef !== undefined && failure.stockItemRef !== undefined) { + return Effect.fail( + new CatalogToStockBindingResolutionFailure({ + ...fields, + bindingRef: failure.bindingRef, + stockItemRef: failure.stockItemRef, + }), + ); + } + if (failure.bindingRef !== undefined) { + return Effect.fail(new CatalogToStockBindingResolutionFailure({ ...fields, bindingRef: failure.bindingRef })); + } + if (failure.stockItemRef !== undefined) { + return Effect.fail(new CatalogToStockBindingResolutionFailure({ ...fields, stockItemRef: failure.stockItemRef })); + } + return Effect.fail(new CatalogToStockBindingResolutionFailure(fields)); +}; + +/** + * Presents #827's closed binding-resolution vocabulary while retaining #822's + * exact diagnostic reason. A non-success stays in Effect's failure channel and + * can never be mistaken for resolved stock demand or Stock Evidence state. + */ +export const failCatalogToStockBindingResolution = (failure: CatalogToStockBindingRejected) => + Match.value(failure.reason).pipe( + Match.whenOr( + 'INTRINSIC_MEANING_MISMATCH', + 'MISSING_BINDING', + 'MULTIPLE_CURRENT_BINDINGS', + 'STOCK_ITEM_NOT_CURRENT', + 'STOCK_ITEM_NOT_FOUND', + 'STOCK_UNIT_MISMATCH', + (reason) => failResolution(failure, reason), + ), + Match.whenOr( + 'BINDING_ID_CONFLICT', + 'REPLACEMENT_MATCHES_CURRENT_TARGET', + 'REVISION_CONFLICT', + 'SELECTION_MEANING_ALREADY_BOUND', + 'STOCK_ITEM_ALREADY_BOUND', + 'TRANSITION_TIME_NOT_AFTER_CURRENT', + () => Effect.die(failure), + ), + Match.exhaustive, + ); + +const affectedAllocationIdsSchema = Schema.Array(ReservationAuthorityAllocationSchema.fields.allocationId).check( + Schema.isMinLength(1), + Schema.makeFilter((identifiers) => + new Set(identifiers).size === identifiers.length ? undefined : 'Affected Allocation identities must be unique', + ), +); + +const correctionObligationBase = { + affectedAllocationIds: affectedAllocationIdsSchema, + reservation: ReservationAuthorityExactScopeSchema, +} as const; + +export const CatalogBindingAffectedObligationSchema = Schema.Union([ + Schema.Struct({ + ...correctionObligationBase, + confirmation: AuthoritativeReservationEvidenceSchema, + stage: Schema.Literal('BEFORE_PROTECTION'), + }), + Schema.Struct({ + ...correctionObligationBase, + confirmation: AuthoritativeReservationEvidenceSchema, + protection: AuthoritativeReservationEvidenceSchema, + stage: Schema.Literal('PROTECTED'), + }), + Schema.Struct({ + ...correctionObligationBase, + committedObligation: CommittedInventoryObligationSchema, + protection: AuthoritativeReservationEvidenceSchema, + stage: Schema.Literal('COMMITTED'), + }), +]); +export type CatalogBindingAffectedObligation = typeof CatalogBindingAffectedObligationSchema.Type; + +export const CatalogBindingCorrectionInputSchema = Schema.Struct({ + correctedBinding: CatalogToStockBindingSchema, + correctionEvidence: CatalogToStockBindingLifecycleEvidenceSchema, + obligations: Schema.Array(CatalogBindingAffectedObligationSchema), + previousBinding: CatalogToStockBindingSchema, +}); +export type CatalogBindingCorrectionInput = typeof CatalogBindingCorrectionInputSchema.Type; + +const rejectedCorrection = (reason: CatalogBindingCorrectionRejected['reason']) => + new CatalogBindingCorrectionRejected({ code: 'catalog_binding_correction_rejected', reason }); + +interface ResourceIdentity { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; +} + +const sameResource = (left: ResourceIdentity, right: ResourceIdentity): boolean => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameMeaning = (left: CatalogToStockBinding, right: CatalogToStockBinding): boolean => + left.exactSelectionMeaning.id === right.exactSelectionMeaning.id && + left.exactSelectionMeaning.kind === right.exactSelectionMeaning.kind; + +type ReservationAllocation = ReservationAuthorityExactScope['allocations'][number]; + +const sameAllocation = (left: ReservationAllocation, right: ReservationAllocation): boolean => + left.allocationId === right.allocationId && + left.quantity.amount === right.quantity.amount && + sameResource(left.quantity.unitRef, right.quantity.unitRef) && + sameResource(left.stockItemRef, right.stockItemRef) && + sameResource(left.stockPositionRef, right.stockPositionRef); + +const sameAllocations = ( + left: ReservationAuthorityExactScope['allocations'], + right: ReservationAuthorityExactScope['allocations'], +): boolean => { + if (left.length !== right.length) { + return false; + } + const rightById = new Map(right.map((allocation) => [allocation.allocationId, allocation] as const)); + return left.every((allocation) => { + const candidate = rightById.get(allocation.allocationId); + return candidate !== undefined && sameAllocation(allocation, candidate); + }); +}; + +const sameProofScope = ( + evidence: AuthoritativeReservationEvidence, + reservation: ReservationAuthorityExactScope, +): boolean => + evidence.evidence.tenantId === reservation.tenantId && + evidence.evidence.attemptId === reservation.attemptId && + evidence.evidence.reservationId === reservation.reservationId && + sameAllocations(evidence.evidence.allocations, reservation.allocations); + +const validateCorrectionTransition = ({ + correctedBinding, + previousBinding, +}: CatalogBindingCorrectionInput): Effect.Effect => + sameResource(previousBinding.bindingRef, correctedBinding.bindingRef) && + sameMeaning(previousBinding, correctedBinding) && + sameResource(previousBinding.unitRef, correctedBinding.unitRef) && + correctedBinding.revision === previousBinding.revision + 1 && + !sameResource(previousBinding.stockItemRef, correctedBinding.stockItemRef) + ? Effect.void + : Effect.fail(rejectedCorrection('INVALID_CORRECTION_TRANSITION')); + +const validateObligation = ( + previousBinding: CatalogToStockBinding, + obligation: CatalogBindingAffectedObligation, +): Effect.Effect => { + const allocationsById = new Map( + obligation.reservation.allocations.map((allocation) => [allocation.allocationId, allocation] as const), + ); + for (const allocationId of obligation.affectedAllocationIds) { + const allocation = allocationsById.get(allocationId); + if (allocation === undefined) { + return Effect.fail(rejectedCorrection('AFFECTED_ALLOCATION_NOT_FOUND')); + } + if (!sameResource(allocation.stockItemRef, previousBinding.stockItemRef)) { + return Effect.fail(rejectedCorrection('AFFECTED_ALLOCATION_LINEAGE_MISMATCH')); + } + } + + if ( + obligation.stage !== 'COMMITTED' && + (obligation.confirmation.operation !== 'RESERVATION_CONFIRMATION' || + !sameProofScope(obligation.confirmation, obligation.reservation)) + ) { + return Effect.fail(rejectedCorrection('CONFIRMATION_SCOPE_MISMATCH')); + } + if ( + obligation.stage !== 'BEFORE_PROTECTION' && + (obligation.protection.operation !== 'COMMITMENT_PROTECTION' || + !sameProofScope(obligation.protection, obligation.reservation)) + ) { + return Effect.fail(rejectedCorrection('PROTECTION_SCOPE_MISMATCH')); + } + if ( + obligation.stage === 'COMMITTED' && + (obligation.committedObligation.attemptId !== obligation.reservation.attemptId || + obligation.committedObligation.reservationObligationId !== obligation.reservation.reservationId) + ) { + return Effect.fail(rejectedCorrection('COMMITTED_SCOPE_MISMATCH')); + } + return Effect.void; +}; + +const consequenceFor = (obligation: CatalogBindingAffectedObligation) => { + const preserved = { + affectedAllocationIds: obligation.affectedAllocationIds, + confirmationState: 'AT_RISK' as const, + orderRolledBack: false as const, + preservedReservation: obligation.reservation, + reconciliation: 'REQUIRED' as const, + reservationReleased: false as const, + reservationRevoked: false as const, + retargeted: false as const, + stage: obligation.stage, + }; + if (obligation.stage === 'BEFORE_PROTECTION') { + return { + ...preserved, + confirmation: obligation.confirmation, + newProtectionAllowed: false as const, + }; + } + if (obligation.stage === 'PROTECTED') { + return { + ...preserved, + confirmation: obligation.confirmation, + preservedProtection: obligation.protection, + }; + } + return { + ...preserved, + committedObligation: obligation.committedObligation, + exception: 'POST_COMMIT_BINDING_MISMATCH' as const, + preservedProtection: obligation.protection, + }; +}; + +/** + * Derives correction consequences without mutating a Reservation, Protection, + * Accepted Order, or their exact Stock Item lineage. Applying the relation + * correction changes future resolution only; every existing obligation stays + * fenced to the Stock Item actually used when it was established. + */ +export const assessCatalogBindingCorrection = ( + input: CatalogBindingCorrectionInput, +): Effect.Effect< + { + readonly consequences: readonly ReturnType[]; + readonly futureResolution: { + readonly bindingRef: CatalogToStockBinding['bindingRef']; + readonly revision: CatalogToStockBinding['revision']; + readonly stockItemRef: CatalogToStockBinding['stockItemRef']; + }; + readonly historyEntry: typeof CatalogToStockBindingHistoryEntrySchema.Type; + }, + CatalogBindingCorrectionRejected +> => + validateCorrectionTransition(input).pipe( + Effect.flatMap(() => + Effect.forEach( + input.obligations, + (obligation) => + validateObligation(input.previousBinding, obligation).pipe(Effect.as(consequenceFor(obligation))), + { concurrency: 1 }, + ), + ), + Effect.map((consequences) => ({ + consequences, + futureResolution: { + bindingRef: input.correctedBinding.bindingRef, + revision: input.correctedBinding.revision, + stockItemRef: input.correctedBinding.stockItemRef, + }, + historyEntry: { + binding: input.previousBinding, + endedAt: input.correctedBinding.effectiveFrom, + ownerEvidenceRef: input.correctionEvidence.ownerEvidenceRef, + transition: 'CORRECTED', + }, + })), + ); + +export { CatalogBindingCorrectionRejected } from './catalog-binding-correction-rejected.ts'; diff --git a/app/verticals/inventory/shared/domain/catalog-to-stock-binding-unavailable.ts b/app/verticals/inventory/shared/domain/catalog-to-stock-binding-unavailable.ts new file mode 100644 index 000000000..54de43472 --- /dev/null +++ b/app/verticals/inventory/shared/domain/catalog-to-stock-binding-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class CatalogToStockBindingUnavailable extends Schema.TaggedError()( + 'CatalogToStockBindingUnavailable', + { + code: Schema.Literal('catalog_to_stock_binding_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/catalog-to-stock-binding.ts b/app/verticals/inventory/shared/domain/catalog-to-stock-binding.ts new file mode 100644 index 000000000..65d9b5abe --- /dev/null +++ b/app/verticals/inventory/shared/domain/catalog-to-stock-binding.ts @@ -0,0 +1,433 @@ +import { CatalogSelectionSchema } from '@app/catalog/domain/catalog-selection-evidence'; +import { ProductUnitRefSchema } from '@app/catalog/resources/product-unit'; +import type { Effect as EffectType } from 'effect'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import type { CatalogToStockBindingUnavailable } from './catalog-to-stock-binding-unavailable.ts'; +import { ExactCatalogSelectionMeaningSchema, StockItemSchema } from './stock-item.ts'; +import type { ExactCatalogSelectionMeaning, StockItem } from './stock-item.ts'; +import { CatalogToStockBindingRefSchema } from '../resources/catalog-to-stock-binding.ts'; +import type { CatalogToStockBindingRef } from '../resources/catalog-to-stock-binding.ts'; + +const boundedIdentifier = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(300), Schema.isTrimmed()); +const QuantitySchema = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\d*)(?:\.\d+)?$/u), Schema.isMaxLength(80)); + +export const PurchaseDemandOccurrenceIdSchema = boundedIdentifier.pipe( + Schema.brand('InventoryPurchaseDemandOccurrenceId'), +); + +export const CatalogToStockBindingRevisionSchema = Schema.Int.check( + Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 }), +); +export const CatalogToStockBindingInstantSchema = Schema.toEncoded(Schema.DateTimeUtcFromString); +export const CatalogToStockBindingLifecycleEvidenceSchema = Schema.Struct({ + authority: Schema.Literal('INVENTORY_BINDING_OWNER'), + ownerEvidenceRef: boundedIdentifier.pipe(Schema.brand('CatalogToStockBindingOwnerEvidenceRef')), +}); +export type CatalogToStockBindingLifecycleEvidence = typeof CatalogToStockBindingLifecycleEvidenceSchema.Type; + +export const CatalogToStockBindingSchema = Schema.Struct({ + bindingRef: CatalogToStockBindingRefSchema, + catalogSelection: CatalogSelectionSchema, + effectiveFrom: CatalogToStockBindingInstantSchema, + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + revision: CatalogToStockBindingRevisionSchema, + stockItemRef: StockItemSchema.fields.stockItemRef, + unitRef: ProductUnitRefSchema, +}).check( + Schema.makeFilter((binding) => { + const { bindingRef, catalogSelection, stockItemRef, unitRef } = binding; + const { tenantId } = catalogSelection.productRef; + return [bindingRef.tenantId, stockItemRef.tenantId, unitRef.tenantId].every((candidate) => candidate === tenantId) + ? undefined + : 'Catalog Selection, binding, Stock Item, and Unit must share one Tenant'; + }), +); +export type CatalogToStockBinding = typeof CatalogToStockBindingSchema.Type; + +export const CatalogToStockBindingHistoryEntrySchema = Schema.Struct({ + binding: CatalogToStockBindingSchema, + endedAt: CatalogToStockBindingInstantSchema, + ownerEvidenceRef: CatalogToStockBindingLifecycleEvidenceSchema.fields.ownerEvidenceRef, + transition: Schema.Literals(['CORRECTED', 'ENDED', 'SUPERSEDED']), +}); +export type CatalogToStockBindingHistoryEntry = typeof CatalogToStockBindingHistoryEntrySchema.Type; + +export const CatalogToStockBindingEndInputSchema = Schema.Struct({ + bindingRef: CatalogToStockBindingRefSchema, + disposition: Schema.Literals(['ENDED', 'SUPERSEDED']), + evidence: CatalogToStockBindingLifecycleEvidenceSchema, + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, +}); +export type CatalogToStockBindingEndInput = typeof CatalogToStockBindingEndInputSchema.Type; + +export const CatalogToStockBindingEndResultSchema = Schema.Struct({ + disposition: CatalogToStockBindingEndInputSchema.fields.disposition, + historyEntry: CatalogToStockBindingHistoryEntrySchema, +}); + +export const CatalogToStockBindingCandidateSchema = Schema.Struct({ + catalogSelection: CatalogSelectionSchema, + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + stockItem: StockItemSchema, +}).check( + Schema.makeFilter(({ catalogSelection, stockItem }) => + catalogSelection.productRef.tenantId === stockItem.stockItemRef.tenantId + ? undefined + : 'Catalog Selection and Stock Item must share one Tenant', + ), +); +export type CatalogToStockBindingCandidate = typeof CatalogToStockBindingCandidateSchema.Type; + +export const CatalogToStockBindingCorrectionInputSchema = Schema.Struct({ + candidate: CatalogToStockBindingCandidateSchema, + evidence: CatalogToStockBindingLifecycleEvidenceSchema, +}); +export type CatalogToStockBindingCorrectionInput = typeof CatalogToStockBindingCorrectionInputSchema.Type; + +export const CatalogStockDemandSchema = Schema.Struct({ + catalogSelection: CatalogSelectionSchema, + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + purchaseDemandOccurrenceId: PurchaseDemandOccurrenceIdSchema, + quantity: QuantitySchema, + unitRef: ProductUnitRefSchema, +}).check( + Schema.makeFilter(({ catalogSelection, unitRef }) => + catalogSelection.productRef.tenantId === unitRef.tenantId + ? undefined + : 'Catalog Selection and requested Unit must share one Tenant', + ), +); +export type CatalogStockDemand = typeof CatalogStockDemandSchema.Type; + +export const ResolvedCatalogStockDemandSchema = Schema.Struct({ + bindingRef: CatalogToStockBindingRefSchema, + catalogSelection: CatalogSelectionSchema, + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + purchaseDemandOccurrenceId: PurchaseDemandOccurrenceIdSchema, + quantity: QuantitySchema, + stockItem: StockItemSchema, + unitRef: ProductUnitRefSchema, +}); +export type ResolvedCatalogStockDemand = typeof ResolvedCatalogStockDemandSchema.Type; + +export class CatalogToStockBindingRejected extends Schema.TaggedError()( + 'CatalogToStockBindingRejected', + { + bindingRef: Schema.optionalKey(CatalogToStockBindingRefSchema), + code: Schema.Literal('catalog_to_stock_binding_rejected'), + reason: Schema.Literals([ + 'MISSING_BINDING', + 'MULTIPLE_CURRENT_BINDINGS', + 'INTRINSIC_MEANING_MISMATCH', + 'STOCK_ITEM_NOT_FOUND', + 'STOCK_ITEM_NOT_CURRENT', + 'STOCK_UNIT_MISMATCH', + 'SELECTION_MEANING_ALREADY_BOUND', + 'STOCK_ITEM_ALREADY_BOUND', + 'BINDING_ID_CONFLICT', + 'REVISION_CONFLICT', + 'REPLACEMENT_MATCHES_CURRENT_TARGET', + 'TRANSITION_TIME_NOT_AFTER_CURRENT', + ]), + stockItemRef: Schema.optionalKey(StockItemSchema.fields.stockItemRef), + }, +) {} + +export interface CatalogToStockBindingReader { + readonly findCurrentByExactSelectionMeaning: ( + tenantId: string, + exactSelectionMeaning: ExactCatalogSelectionMeaning, + ) => EffectType.Effect; +} + +export interface CatalogToStockBindingPersistence extends CatalogToStockBindingReader { + readonly endCurrent: (input: { + readonly current: CatalogToStockBinding; + readonly historyEntry: CatalogToStockBindingHistoryEntry; + }) => EffectType.Effect< + CatalogToStockBindingHistoryEntry, + CatalogToStockBindingRejected | CatalogToStockBindingUnavailable + >; + readonly findCurrentByStockItem: ( + stockItemRef: StockItem['stockItemRef'], + ) => EffectType.Effect, CatalogToStockBindingUnavailable>; + readonly insertCurrent: ( + binding: CatalogToStockBinding, + ) => EffectType.Effect; + readonly readHistory: ( + bindingRef: CatalogToStockBindingRef, + ) => EffectType.Effect; + readonly replaceCurrent: (input: { + readonly current: CatalogToStockBinding; + readonly historyEntry: CatalogToStockBindingHistoryEntry; + readonly next: CatalogToStockBinding; + }) => EffectType.Effect; +} + +export interface CatalogToStockBindingStockItemReader { + readonly findById: ( + tenantId: string, + stockItemId: string, + ) => EffectType.Effect, CatalogToStockBindingUnavailable>; +} + +const sameMeaning = (left: ExactCatalogSelectionMeaning, right: ExactCatalogSelectionMeaning) => + left.id === right.id && left.kind === right.kind; +const sameUnit = (left: StockItem['unitRef'], right: StockItem['unitRef']) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const rejected = ( + reason: CatalogToStockBindingRejected['reason'], + bindingRef?: CatalogToStockBindingRef, + stockItemRef?: StockItem['stockItemRef'], +) => { + if (bindingRef !== undefined && stockItemRef !== undefined) { + return new CatalogToStockBindingRejected({ + bindingRef, + code: 'catalog_to_stock_binding_rejected', + reason, + stockItemRef, + }); + } + if (bindingRef !== undefined) { + return new CatalogToStockBindingRejected({ bindingRef, code: 'catalog_to_stock_binding_rejected', reason }); + } + if (stockItemRef !== undefined) { + return new CatalogToStockBindingRejected({ code: 'catalog_to_stock_binding_rejected', reason, stockItemRef }); + } + return new CatalogToStockBindingRejected({ code: 'catalog_to_stock_binding_rejected', reason }); +}; + +export const makeCatalogToStockBindingResolver = ( + bindings: CatalogToStockBindingReader, + stockItems: CatalogToStockBindingStockItemReader, +) => ({ + resolve: (demand: CatalogStockDemand) => + bindings + .findCurrentByExactSelectionMeaning(demand.catalogSelection.productRef.tenantId, demand.exactSelectionMeaning) + .pipe( + Effect.flatMap((current) => { + const [binding] = current; + if (binding === undefined) { + return Effect.fail(rejected('MISSING_BINDING')); + } + if (current.length !== 1) { + return Effect.fail(rejected('MULTIPLE_CURRENT_BINDINGS')); + } + return stockItems.findById(binding.stockItemRef.tenantId, binding.stockItemRef.resourceId).pipe( + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(rejected('STOCK_ITEM_NOT_FOUND', binding.bindingRef, binding.stockItemRef)), + onSome: (stockItem) => { + if ( + !sameMeaning(binding.exactSelectionMeaning, demand.exactSelectionMeaning) || + !sameMeaning(stockItem.exactSelectionMeaning, demand.exactSelectionMeaning) + ) { + return Effect.fail( + rejected('INTRINSIC_MEANING_MISMATCH', binding.bindingRef, stockItem.stockItemRef), + ); + } + if (stockItem.lifecycle !== 'CURRENT') { + return Effect.fail(rejected('STOCK_ITEM_NOT_CURRENT', binding.bindingRef, stockItem.stockItemRef)); + } + if (!sameUnit(binding.unitRef, demand.unitRef) || !sameUnit(stockItem.unitRef, demand.unitRef)) { + return Effect.fail(rejected('STOCK_UNIT_MISMATCH', binding.bindingRef, stockItem.stockItemRef)); + } + return Effect.succeed({ + bindingRef: binding.bindingRef, + catalogSelection: demand.catalogSelection, + exactSelectionMeaning: demand.exactSelectionMeaning, + purchaseDemandOccurrenceId: demand.purchaseDemandOccurrenceId, + quantity: demand.quantity, + stockItem, + unitRef: demand.unitRef, + } satisfies ResolvedCatalogStockDemand); + }, + }), + ), + ); + }), + ), +}); + +const requireSingleCurrent = ( + current: readonly CatalogToStockBinding[], +): EffectType.Effect => { + const [binding] = current; + if (binding === undefined) { + return Effect.fail(rejected('MISSING_BINDING')); + } + return current.length === 1 ? Effect.succeed(binding) : Effect.fail(rejected('MULTIPLE_CURRENT_BINDINGS')); +}; + +const requireLaterTransition = ( + current: CatalogToStockBinding, + transitionAt: CatalogToStockBinding['effectiveFrom'], +): EffectType.Effect => + DateTime.toEpochMillis(DateTime.makeUnsafe(transitionAt)) > + DateTime.toEpochMillis(DateTime.makeUnsafe(current.effectiveFrom)) + ? Effect.succeed(transitionAt) + : Effect.fail(rejected('TRANSITION_TIME_NOT_AFTER_CURRENT', current.bindingRef, current.stockItemRef)); + +const validateCandidate = ( + candidate: CatalogToStockBindingCandidate, +): EffectType.Effect => { + if (!sameMeaning(candidate.stockItem.exactSelectionMeaning, candidate.exactSelectionMeaning)) { + return Effect.fail(rejected('INTRINSIC_MEANING_MISMATCH', undefined, candidate.stockItem.stockItemRef)); + } + if (candidate.stockItem.lifecycle !== 'CURRENT') { + return Effect.fail(rejected('STOCK_ITEM_NOT_CURRENT', undefined, candidate.stockItem.stockItemRef)); + } + return Effect.succeed(candidate); +}; + +const replaceBindingTarget = ( + persistence: CatalogToStockBindingPersistence, + current: CatalogToStockBinding, + candidate: CatalogToStockBindingCandidate, + evidence: CatalogToStockBindingLifecycleEvidence, + correctedAt: CatalogToStockBinding['effectiveFrom'], +) => + Schema.decodeEffect(CatalogToStockBindingSchema)({ + ...current, + effectiveFrom: correctedAt, + exactSelectionMeaning: candidate.exactSelectionMeaning, + revision: current.revision + 1, + stockItemRef: candidate.stockItem.stockItemRef, + unitRef: candidate.stockItem.unitRef, + }).pipe( + Effect.orDie, + Effect.flatMap((next) => + persistence.replaceCurrent({ + current, + historyEntry: { + binding: current, + endedAt: correctedAt, + ownerEvidenceRef: evidence.ownerEvidenceRef, + transition: 'CORRECTED', + }, + next, + }), + ), + ); + +export const makeCatalogToStockBindingLifecycle = ( + persistence: CatalogToStockBindingPersistence, + options: { + readonly makeBindingId: () => string; + readonly now: EffectType.Effect; + }, +) => + /* oxlint-disable perfectionist/sort-objects -- Canonical public lifecycle order is establish, correct, end; issue #827 owns this exact exception; expires: 2027-03-31. */ + ({ + establish: (candidate: CatalogToStockBindingCandidate) => + validateCandidate(candidate).pipe( + Effect.flatMap(() => + persistence.findCurrentByExactSelectionMeaning( + candidate.catalogSelection.productRef.tenantId, + candidate.exactSelectionMeaning, + ), + ), + Effect.flatMap((existing) => + existing.length === 0 + ? Effect.void + : Effect.fail( + rejected(existing.length === 1 ? 'SELECTION_MEANING_ALREADY_BOUND' : 'MULTIPLE_CURRENT_BINDINGS'), + ), + ), + Effect.flatMap(() => persistence.findCurrentByStockItem(candidate.stockItem.stockItemRef)), + Effect.flatMap( + Option.match({ + onNone: () => options.now, + onSome: (existing) => + Effect.fail(rejected('STOCK_ITEM_ALREADY_BOUND', existing.bindingRef, existing.stockItemRef)), + }), + ), + Effect.flatMap((effectiveFrom) => + Schema.decodeEffect(CatalogToStockBindingSchema)({ + bindingRef: { + moduleId: 'commerce.inventory', + resourceId: options.makeBindingId(), + resourceType: 'commerce.inventory.catalog-to-stock-binding', + tenantId: candidate.catalogSelection.productRef.tenantId, + }, + catalogSelection: candidate.catalogSelection, + effectiveFrom, + exactSelectionMeaning: candidate.exactSelectionMeaning, + revision: 1, + stockItemRef: candidate.stockItem.stockItemRef, + unitRef: candidate.stockItem.unitRef, + }).pipe(Effect.orDie), + ), + Effect.flatMap(persistence.insertCurrent), + ), + correct: ({ candidate, evidence }: CatalogToStockBindingCorrectionInput) => + validateCandidate(candidate).pipe( + Effect.flatMap(() => + persistence.findCurrentByExactSelectionMeaning( + candidate.catalogSelection.productRef.tenantId, + candidate.exactSelectionMeaning, + ), + ), + Effect.flatMap(requireSingleCurrent), + Effect.flatMap((current) => { + if (!sameMeaning(current.exactSelectionMeaning, candidate.exactSelectionMeaning)) { + return Effect.fail( + rejected('INTRINSIC_MEANING_MISMATCH', current.bindingRef, candidate.stockItem.stockItemRef), + ); + } + if (!sameUnit(current.unitRef, candidate.stockItem.unitRef)) { + return Effect.fail(rejected('STOCK_UNIT_MISMATCH', current.bindingRef, candidate.stockItem.stockItemRef)); + } + if (current.stockItemRef.resourceId === candidate.stockItem.stockItemRef.resourceId) { + return Effect.fail( + rejected('REPLACEMENT_MATCHES_CURRENT_TARGET', current.bindingRef, current.stockItemRef), + ); + } + return persistence.findCurrentByStockItem(candidate.stockItem.stockItemRef).pipe( + Effect.flatMap( + Option.match({ + onNone: () => options.now, + onSome: (existing) => + Effect.fail(rejected('STOCK_ITEM_ALREADY_BOUND', existing.bindingRef, existing.stockItemRef)), + }), + ), + Effect.flatMap((correctedAt) => requireLaterTransition(current, correctedAt)), + Effect.flatMap((correctedAt) => + replaceBindingTarget(persistence, current, candidate, evidence, correctedAt), + ), + ); + }), + ), + end: (input: CatalogToStockBindingEndInput) => + persistence.findCurrentByExactSelectionMeaning(input.bindingRef.tenantId, input.exactSelectionMeaning).pipe( + Effect.flatMap(requireSingleCurrent), + Effect.flatMap((current) => + current.bindingRef.moduleId === input.bindingRef.moduleId && + current.bindingRef.resourceId === input.bindingRef.resourceId && + current.bindingRef.resourceType === input.bindingRef.resourceType && + current.bindingRef.tenantId === input.bindingRef.tenantId + ? options.now.pipe( + Effect.flatMap((endedAt) => requireLaterTransition(current, endedAt)), + Effect.flatMap((endedAt) => + persistence.endCurrent({ + current, + historyEntry: { + binding: current, + endedAt, + ownerEvidenceRef: input.evidence.ownerEvidenceRef, + transition: input.disposition, + }, + }), + ), + Effect.map((historyEntry) => ({ disposition: input.disposition, historyEntry })), + ) + : Effect.fail(rejected('BINDING_ID_CONFLICT', current.bindingRef, current.stockItemRef)), + ), + ), + }); +/* oxlint-enable perfectionist/sort-objects */ diff --git a/app/verticals/inventory/shared/domain/commitment-protection-conflict.ts b/app/verticals/inventory/shared/domain/commitment-protection-conflict.ts new file mode 100644 index 000000000..acfd87d15 --- /dev/null +++ b/app/verticals/inventory/shared/domain/commitment-protection-conflict.ts @@ -0,0 +1,12 @@ +import { Schema } from 'effect'; + +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +export class CommitmentProtectionConflict extends Schema.TaggedError()( + 'CommitmentProtectionConflict', + { + code: Schema.Literal('commitment_protection_conflict'), + effectId: ReservationAuthorityEffectIdSchema, + reason: Schema.Literal('MATERIAL_INTENT_CONFLICT'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/commitment-protection-rejected.ts b/app/verticals/inventory/shared/domain/commitment-protection-rejected.ts new file mode 100644 index 000000000..1bdfa9bf4 --- /dev/null +++ b/app/verticals/inventory/shared/domain/commitment-protection-rejected.ts @@ -0,0 +1,21 @@ +import { Schema } from 'effect'; + +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +export class CommitmentProtectionRejected extends Schema.TaggedError()( + 'CommitmentProtectionRejected', + { + code: Schema.Literal('commitment_protection_rejected'), + effectId: ReservationAuthorityEffectIdSchema, + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'CONFIRMATION_SCOPE_MISMATCH', + 'PROTECTION_IDENTITY_CONFLICT', + 'SIBLING_PROTECTION_FORBIDDEN', + 'AUTHORITY_SCOPE_MISMATCH', + 'PROOF_SCOPE_MISMATCH', + 'INVALID_PROTECTION', + 'REVISION_CONFLICT', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/commitment-protection-unavailable.ts b/app/verticals/inventory/shared/domain/commitment-protection-unavailable.ts new file mode 100644 index 000000000..2b0cefb8c --- /dev/null +++ b/app/verticals/inventory/shared/domain/commitment-protection-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +export class CommitmentProtectionUnavailable extends Schema.TaggedError()( + 'CommitmentProtectionUnavailable', + { + code: Schema.Literal('commitment_protection_unavailable'), + effectId: ReservationAuthorityEffectIdSchema, + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/commitment-protection.ts b/app/verticals/inventory/shared/domain/commitment-protection.ts new file mode 100644 index 000000000..d419902ba --- /dev/null +++ b/app/verticals/inventory/shared/domain/commitment-protection.ts @@ -0,0 +1,276 @@ +import type { Effect as EffectType, Option } from 'effect'; +import { Effect, Result, Schema } from 'effect'; + +import { ReservationConfirmationSchema } from './reservation-confirmation.ts'; +import { CommitmentProtectionConflict } from './commitment-protection-conflict.ts'; +import { CommitmentProtectionRejected } from './commitment-protection-rejected.ts'; +import { CommitmentProtectionUnavailable } from './commitment-protection-unavailable.ts'; +import { ActionInvocationIdSchema, LegalEntityIdSchema } from './physical-stock-effect.ts'; +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; +import { AuthoritativeReservationEvidenceSchema } from './reservation-authority.ts'; +import { CommitmentProtectionRefSchema } from '../resources/commitment-protection.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; + +const protectionInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const boundedEvidenceRef = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +export const CommitmentProtectionMutationIdSchema = Schema.String.check(Schema.isTrimmed(), Schema.isUUID()).pipe( + Schema.brand('CommitmentProtectionMutationId'), +); + +export const EstablishCommitmentProtectionPayloadSchema = Schema.Struct({ + confirmationRef: ReservationConfirmationRefSchema, + effectId: ReservationAuthorityEffectIdSchema, + protectionRef: CommitmentProtectionRefSchema, +}); +export type EstablishCommitmentProtectionPayload = typeof EstablishCommitmentProtectionPayloadSchema.Type; + +const CommitmentProtectionEstablishedObservationSchema = Schema.TaggedStruct('ESTABLISHED', { + effectiveAt: protectionInstant, + ownerEvidenceRef: boundedEvidenceRef, +}); +export const CommitmentProtectionHealthObservationSchema = Schema.Union([ + CommitmentProtectionEstablishedObservationSchema, + Schema.TaggedStruct('BINDING_CORRECTION', { + correctionEvidenceRef: boundedEvidenceRef, + effectiveAt: protectionInstant, + }), + Schema.TaggedStruct('MATERIAL_IMPAIRMENT', { + effectiveAt: protectionInstant, + ownerEvidenceRef: boundedEvidenceRef, + }), +]); + +export const CommitmentProtectionSchema = Schema.Struct({ + authorityEvidence: AuthoritativeReservationEvidenceSchema, + confirmation: ReservationConfirmationSchema, + establishedAt: protectionInstant, + health: Schema.Struct({ + observation: CommitmentProtectionHealthObservationSchema, + reconciliationRequired: Schema.Boolean, + state: Schema.Literals(['PROTECTED', 'AT_RISK']), + }), + ref: CommitmentProtectionRefSchema, + revision: Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })), +}).check( + Schema.makeFilter(({ authorityEvidence, confirmation, establishedAt, health, ref, revision }) => { + const initial = Schema.is(CommitmentProtectionEstablishedObservationSchema)(health.observation); + if ( + String(ref.tenantId) !== String(confirmation.ref.tenantId) || + authorityEvidence.operation !== 'COMMITMENT_PROTECTION' || + String(authorityEvidence.evidence.tenantId) !== String(confirmation.ref.tenantId) || + authorityEvidence.evidence.reservationId !== confirmation.reservation.ref.resourceId || + authorityEvidence.evidence.attemptId !== confirmation.reservation.origin.attemptId || + establishedAt !== authorityEvidence.evidence.validFrom + ) { + return 'Commitment Protection must preserve its exact Confirmation, Reservation, Attempt, and authority proof'; + } + if ((revision === 1) !== initial) { + return 'Only the first Commitment Protection revision may carry establishment evidence'; + } + if ( + (health.state === 'PROTECTED' && (!initial || health.reconciliationRequired)) || + (health.state === 'AT_RISK' && (initial || !health.reconciliationRequired)) + ) { + return 'Commitment Protection health must preserve its monotonic fence meaning'; + } + return true; + }), +); +export type CommitmentProtection = typeof CommitmentProtectionSchema.Type; + +export const CommitmentProtectionEffectRequestSchema = Schema.Struct({ + confirmation: ReservationConfirmationSchema, + effectId: ReservationAuthorityEffectIdSchema, + legalEntityId: LegalEntityIdSchema, + mutationId: CommitmentProtectionMutationIdSchema, + protectionRef: CommitmentProtectionRefSchema, + requestedAt: protectionInstant, + sourceActionInvocationId: ActionInvocationIdSchema, +}); +export type CommitmentProtectionEffectRequest = typeof CommitmentProtectionEffectRequestSchema.Type; + +export const CommitmentProtectionNotProtectableReasonSchema = Schema.Literals([ + 'CONFIRMATION_NOT_FOUND', + 'CONFIRMATION_NOT_VALID', + 'CONFIRMATION_EXPIRED', + 'CONFIRMATION_REVOKED', + 'AUTHORITY_REJECTED', + 'AUTHORITY_UNSUPPORTED', + 'ESTABLISHMENT_AFTER_EXPIRY', +]); + +export const CommitmentProtectionEffectSchema = Schema.Union([ + Schema.TaggedStruct('PROTECTED', { + protection: CommitmentProtectionSchema, + request: CommitmentProtectionEffectRequestSchema, + }), + Schema.TaggedStruct('NOT_PROTECTABLE', { + reason: CommitmentProtectionNotProtectableReasonSchema, + request: CommitmentProtectionEffectRequestSchema, + }), +]); +export type CommitmentProtectionEffect = typeof CommitmentProtectionEffectSchema.Type; + +export const CommitmentProtectionProtectedResultSchema = Schema.TaggedStruct('PROTECTED', { + protection: CommitmentProtectionSchema, + replayed: Schema.Boolean, +}); +export const CommitmentProtectionAtRiskResultSchema = Schema.TaggedStruct('AT_RISK', { + protection: CommitmentProtectionSchema, + reconciliationRequired: Schema.Literal(true), + replayed: Schema.Boolean, +}); +export const CommitmentProtectionPendingResultSchema = Schema.TaggedStruct('PENDING', { + effectId: ReservationAuthorityEffectIdSchema, + fence: Schema.Literal('BLOCKED_PENDING_RECOVERY'), + recovery: Schema.Literal('RECOVER_ORIGINAL_EFFECT'), + replayed: Schema.Boolean, +}); +export const CommitmentProtectionIndeterminateResultSchema = Schema.TaggedStruct('INDETERMINATE', { + effectId: ReservationAuthorityEffectIdSchema, + fence: Schema.Literal('BLOCKED_PENDING_RECOVERY'), + recovery: Schema.Literal('RECOVER_ORIGINAL_EFFECT'), + replayed: Schema.Boolean, +}); +export const CommitmentProtectionNotProtectableResultSchema = Schema.TaggedStruct('NOT_PROTECTABLE', { + effectId: ReservationAuthorityEffectIdSchema, + reason: CommitmentProtectionNotProtectableReasonSchema, + replayed: Schema.Boolean, +}); +export const EstablishCommitmentProtectionResultSchema = Schema.Union([ + CommitmentProtectionProtectedResultSchema, + CommitmentProtectionAtRiskResultSchema, + CommitmentProtectionPendingResultSchema, + CommitmentProtectionIndeterminateResultSchema, + CommitmentProtectionNotProtectableResultSchema, +]); +export type EstablishCommitmentProtectionResult = typeof EstablishCommitmentProtectionResultSchema.Type; + +export const EstablishCommitmentProtectionErrorSchema = Schema.Union([ + CommitmentProtectionRejected, + CommitmentProtectionConflict, + CommitmentProtectionUnavailable, +]); +export type EstablishCommitmentProtectionError = typeof EstablishCommitmentProtectionErrorSchema.Type; + +export { CommitmentProtectionConflict } from './commitment-protection-conflict.ts'; +export { CommitmentProtectionRejected } from './commitment-protection-rejected.ts'; +export { CommitmentProtectionUnavailable } from './commitment-protection-unavailable.ts'; + +export interface CommitmentProtectionPersistence { + readonly createOrRead: ( + candidate: CommitmentProtection, + ) => EffectType.Effect< + { readonly outcome: 'INSERTED' | 'EXISTING'; readonly protection: CommitmentProtection }, + EstablishCommitmentProtectionError + >; + readonly findByRef: ( + ref: typeof CommitmentProtectionRefSchema.Type, + ) => EffectType.Effect, CommitmentProtectionUnavailable>; + readonly findByReservationAttempt: ( + reservationId: string, + attemptId: string, + ) => EffectType.Effect, CommitmentProtectionUnavailable>; + readonly readHistory: ( + ref: typeof CommitmentProtectionRefSchema.Type, + ) => EffectType.Effect; + readonly saveRevision: (input: { + readonly current: CommitmentProtection; + readonly next: CommitmentProtection; + }) => EffectType.Effect; +} + +const canonicalRequestSchema = Schema.fromJsonString(CommitmentProtectionEffectRequestSchema); +export const canonicalCommitmentProtectionRequest = (request: CommitmentProtectionEffectRequest): string => + Result.getOrThrow(Schema.encodeResult(canonicalRequestSchema)(request)); + +export const sameCommitmentProtectionRequest = ( + left: CommitmentProtectionEffectRequest, + right: CommitmentProtectionEffectRequest, +): boolean => canonicalCommitmentProtectionRequest(left) === canonicalCommitmentProtectionRequest(right); + +const rejected = ( + effectId: typeof ReservationAuthorityEffectIdSchema.Type, + reason: CommitmentProtectionRejected['reason'], +) => new CommitmentProtectionRejected({ code: 'commitment_protection_rejected', effectId, reason }); + +const sameReference = ( + left: { readonly resourceId: string; readonly tenantId: string }, + right: { readonly resourceId: string; readonly tenantId: string }, +) => left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +export const establishCommitmentProtection = Effect.fn('CommitmentProtection.establish')(function* establish(input: { + readonly authorityEvidence: typeof AuthoritativeReservationEvidenceSchema.Type; + readonly confirmation: typeof ReservationConfirmationSchema.Type; + readonly protectionRef: typeof CommitmentProtectionRefSchema.Type; +}) { + const { authorityEvidence, confirmation, protectionRef } = input; + if (String(protectionRef.tenantId) !== String(confirmation.ref.tenantId)) { + return yield* rejected(authorityEvidence.effectId, 'TENANT_SCOPE_MISMATCH'); + } + if ( + authorityEvidence.operation !== 'COMMITMENT_PROTECTION' || + authorityEvidence.issuer.backend !== confirmation.authorityEvidence.issuer.backend || + authorityEvidence.issuer.backendId !== confirmation.authorityEvidence.issuer.backendId || + authorityEvidence.issuer.origin !== confirmation.authorityEvidence.issuer.origin + ) { + return yield* rejected(authorityEvidence.effectId, 'AUTHORITY_SCOPE_MISMATCH'); + } + const expectedAllocations = confirmation.reservation.requirements.flatMap(({ allocations }) => allocations); + const actualAllocations = authorityEvidence.evidence.allocations; + const proofMatches = + String(authorityEvidence.evidence.tenantId) === String(confirmation.ref.tenantId) && + authorityEvidence.evidence.reservationId === confirmation.reservation.ref.resourceId && + authorityEvidence.evidence.attemptId === confirmation.reservation.origin.attemptId && + authorityEvidence.evidence.customerConfigurationId === confirmation.reservation.authority.customerConfigurationId && + expectedAllocations.length === actualAllocations.length && + expectedAllocations.every((expected) => + actualAllocations.some( + (actual) => + String(expected.allocationId) === String(actual.allocationId) && + expected.quantity.amount === actual.quantity.amount && + sameReference(expected.quantity.unitRef, actual.quantity.unitRef) && + sameReference(expected.stockItemRef, actual.stockItemRef) && + sameReference(expected.positionRef, actual.stockPositionRef), + ), + ); + if (!proofMatches) { + return yield* rejected(authorityEvidence.effectId, 'PROOF_SCOPE_MISMATCH'); + } + return yield* Schema.decodeEffect(CommitmentProtectionSchema)({ + authorityEvidence, + confirmation, + establishedAt: authorityEvidence.evidence.validFrom, + health: { + observation: { + _tag: 'ESTABLISHED', + effectiveAt: authorityEvidence.evidence.validFrom, + ownerEvidenceRef: authorityEvidence.evidence.ownerEvidenceRef, + }, + reconciliationRequired: false, + state: 'PROTECTED', + }, + ref: protectionRef, + revision: 1, + }).pipe( + Effect.mapError((cause) => Object.assign(rejected(authorityEvidence.effectId, 'INVALID_PROTECTION'), { cause })), + ); +}); + +export const markCommitmentProtectionAtRisk = Effect.fn('CommitmentProtection.markAtRisk')(function* markAtRisk( + current: CommitmentProtection, + observation: Exclude, +) { + if (observation.effectiveAt < current.establishedAt) { + return yield* rejected(current.authorityEvidence.effectId, 'INVALID_PROTECTION'); + } + return yield* Schema.decodeEffect(CommitmentProtectionSchema)({ + ...current, + health: { observation, reconciliationRequired: true, state: 'AT_RISK' }, + revision: current.revision + 1, + }).pipe( + Effect.mapError((cause) => + Object.assign(rejected(current.authorityEvidence.effectId, 'INVALID_PROTECTION'), { cause }), + ), + ); +}); diff --git a/app/verticals/inventory/shared/domain/configuration-stock-item-binding.ts b/app/verticals/inventory/shared/domain/configuration-stock-item-binding.ts new file mode 100644 index 000000000..f765f8edd --- /dev/null +++ b/app/verticals/inventory/shared/domain/configuration-stock-item-binding.ts @@ -0,0 +1,122 @@ +import { Effect, Schema } from 'effect'; + +import type { + CatalogStockDemand, + CatalogToStockBinding, + ResolvedCatalogStockDemand, +} from './catalog-to-stock-binding.ts'; + +type ProductConfiguration = Exclude; + +export type ConfigurationStockDemand = Omit & { + readonly catalogSelection: CatalogStockDemand['catalogSelection'] & { + readonly configuration: ProductConfiguration; + }; +}; + +export type ResolvedConfigurationStockDemand = Omit & { + readonly catalogSelection: ConfigurationStockDemand['catalogSelection']; +}; + +export class ConfigurationStockItemBindingRejected extends Schema.TaggedError()( + 'ConfigurationStockItemBindingRejected', + { + code: Schema.Literal('configuration_stock_item_binding_rejected'), + reason: Schema.Literals([ + 'BINDING_PROVENANCE_MISMATCH', + 'CONFIGURATION_MEANING_MISMATCH', + 'DEMAND_PROVENANCE_MISMATCH', + ]), + }, +) {} + +interface ResourceIdentity { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; +} + +const sameResource = (left: ResourceIdentity, right: ResourceIdentity): boolean => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameOptionalRevisionResource = ( + left: { readonly resourceRef: ResourceIdentity } | undefined, + right: { readonly resourceRef: ResourceIdentity } | undefined, +): boolean => + left === undefined ? right === undefined : right !== undefined && sameResource(left.resourceRef, right.resourceRef); + +const sameConfigurationMeaning = (left: ProductConfiguration, right: ProductConfiguration): boolean => + sameResource(left.productRef, right.productRef) && + sameResource(left.variantRef, right.variantRef) && + sameResource(left.definition.resourceRef, right.definition.resourceRef) && + left.choices.length === right.choices.length && + left.choices.every((leftChoice) => { + const rightChoice = right.choices.find((candidate) => candidate.choiceKey === leftChoice.choiceKey); + return ( + rightChoice !== undefined && + leftChoice.value === rightChoice.value && + sameOptionalRevisionResource(leftChoice.attributeDefinition, rightChoice.attributeDefinition) && + sameOptionalRevisionResource(leftChoice.unit, rightChoice.unit) + ); + }); + +const sameExactMeaning = ( + left: CatalogStockDemand['exactSelectionMeaning'], + right: CatalogStockDemand['exactSelectionMeaning'], +): boolean => left.id === right.id && left.kind === right.kind; + +const rejected = (reason: ConfigurationStockItemBindingRejected['reason']) => + new ConfigurationStockItemBindingRejected({ code: 'configuration_stock_item_binding_rejected', reason }); + +/** + * Validates configured demand against the exact binding that canonical resolution selected. + * Catalog revision numbers are evidence only; target, choice values, and referenced configuration Resources are meaning. + */ +export const preserveConfigurationStockDemand = ( + demand: ConfigurationStockDemand, + resolved: ResolvedCatalogStockDemand, + binding: CatalogToStockBinding, +): Effect.Effect => { + if ( + !sameResource(resolved.bindingRef, binding.bindingRef) || + !sameResource(resolved.stockItem.stockItemRef, binding.stockItemRef) || + !sameExactMeaning(resolved.exactSelectionMeaning, binding.exactSelectionMeaning) || + !sameExactMeaning(demand.exactSelectionMeaning, binding.exactSelectionMeaning) + ) { + return Effect.fail(rejected('BINDING_PROVENANCE_MISMATCH')); + } + + const boundConfiguration = binding.catalogSelection.configuration; + if ( + boundConfiguration === undefined || + !sameResource(demand.catalogSelection.productRef, binding.catalogSelection.productRef) || + !sameResource(demand.catalogSelection.variantRef, binding.catalogSelection.variantRef) || + !sameConfigurationMeaning(demand.catalogSelection.configuration, boundConfiguration) + ) { + return Effect.fail(rejected('CONFIGURATION_MEANING_MISMATCH')); + } + + const resolvedConfiguration = resolved.catalogSelection.configuration; + if ( + resolvedConfiguration === undefined || + !sameResource(resolved.catalogSelection.productRef, demand.catalogSelection.productRef) || + !sameResource(resolved.catalogSelection.variantRef, demand.catalogSelection.variantRef) || + !sameConfigurationMeaning(resolvedConfiguration, demand.catalogSelection.configuration) || + resolved.purchaseDemandOccurrenceId !== demand.purchaseDemandOccurrenceId || + resolved.quantity !== demand.quantity || + !sameResource(resolved.unitRef, demand.unitRef) || + !sameResource(binding.unitRef, demand.unitRef) || + !sameResource(resolved.stockItem.unitRef, demand.unitRef) + ) { + return Effect.fail(rejected('DEMAND_PROVENANCE_MISMATCH')); + } + + return Effect.succeed({ + ...resolved, + catalogSelection: demand.catalogSelection, + }); +}; diff --git a/app/verticals/inventory/shared/domain/current-stock-evidence-for-availability-unavailable.ts b/app/verticals/inventory/shared/domain/current-stock-evidence-for-availability-unavailable.ts new file mode 100644 index 000000000..104a43599 --- /dev/null +++ b/app/verticals/inventory/shared/domain/current-stock-evidence-for-availability-unavailable.ts @@ -0,0 +1,10 @@ +import { Schema } from 'effect'; + +export class CurrentStockEvidenceForAvailabilityUnavailable extends Schema.TaggedError()( + 'CurrentStockEvidenceForAvailabilityUnavailable', + { + code: Schema.Literal('current_stock_evidence_for_availability_unavailable'), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/current-stock-evidence-for-availability.ts b/app/verticals/inventory/shared/domain/current-stock-evidence-for-availability.ts new file mode 100644 index 000000000..d94127353 --- /dev/null +++ b/app/verticals/inventory/shared/domain/current-stock-evidence-for-availability.ts @@ -0,0 +1,126 @@ +import { Schema } from 'effect'; + +import { CatalogToStockBindingSchema } from './catalog-to-stock-binding.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { + ImportedCommittedObligationSchema, + RuntimeCommittedInventoryObligationSchema, +} from './inventory-obligation.ts'; +import { + IndeterminateReservationCreateEffectSchema, + InventoryReservationCreateRequestSchema, + ReconciliationRequiredReservationCreateEffectSchema, + ReservationCreateAllocationSchema, +} from './inventory-reservation-create.ts'; +import type { RequestedReservationCreateEffectSchema } from './inventory-reservation-create.ts'; +import { InventorySourceAssertionEvaluationSchema } from './inventory-source-assertion.ts'; +import { PhysicalStockEffectRecordSchema } from './physical-stock-effect.ts'; +import { + StockPositionOnHandEvidenceSchema, + StockPositionReservedEvidenceSchema, + StockPositionSchema, +} from './stock-position.ts'; +import { StockItemSchema } from './stock-item.ts'; +import { StockLocationSchema } from './stock-location.ts'; + +const constraintCommon = { + attemptId: InventoryReservationCreateRequestSchema.fields.reservation.fields.origin.fields.attemptId, + authority: InventoryBackendConfigurationSchema, + countsTowardReserved: Schema.Literal(false), + effectId: InventoryReservationCreateRequestSchema.fields.effectId, + meaning: Schema.Literal('UNRESOLVED_RESERVATION_EFFECT_CONSTRAINT'), + mutationId: InventoryReservationCreateRequestSchema.fields.mutationId, + provesReusableOnHand: Schema.Literal(false), + requestedAt: InventoryReservationCreateRequestSchema.fields.requestedAt, + sourceActionInvocationId: InventoryReservationCreateRequestSchema.fields.sourceActionInvocationId, +} as const; + +export const ExactUnresolvedReservationEffectConstraintSchema = Schema.TaggedStruct('EXACT', { + ...constraintCommon, + constrainedAllocations: ReconciliationRequiredReservationCreateEffectSchema.fields.constrainedAllocations, + observedAt: ReconciliationRequiredReservationCreateEffectSchema.fields.observedAt, + ownerEvidenceRef: ReconciliationRequiredReservationCreateEffectSchema.fields.ownerEvidenceRef, +}); + +export const IndeterminateUnresolvedReservationEffectConstraintSchema = Schema.TaggedStruct('INDETERMINATE', { + ...constraintCommon, + observedAt: Schema.optionalKey(IndeterminateReservationCreateEffectSchema.fields.observedAt), + possibleAllocations: Schema.Array(ReservationCreateAllocationSchema).check(Schema.isMinLength(1)), + reason: Schema.Union([IndeterminateReservationCreateEffectSchema.fields.reason, Schema.Literal('DISPATCH_PENDING')]), +}); + +export const UnresolvedReservationEffectConstraintSchema = Schema.Union([ + ExactUnresolvedReservationEffectConstraintSchema, + IndeterminateUnresolvedReservationEffectConstraintSchema, +]); +export type UnresolvedReservationEffectConstraint = typeof UnresolvedReservationEffectConstraintSchema.Type; + +const sourceCommon = { + onHand: StockPositionOnHandEvidenceSchema, + ownerConfiguration: InventoryBackendConfigurationSchema, + physicalOnHandReusableProof: Schema.Literal('NOT_PROVIDED'), +} as const; + +export const OwnerManagedStockSourceEvidenceSchema = Schema.TaggedStruct('OWNER_MANAGED', { + ...sourceCommon, +}); + +export const ExternalStockSourceAssertionEvidenceSchema = Schema.TaggedStruct('EXTERNAL_SOURCE_ASSERTION', { + ...sourceCommon, + evaluation: InventorySourceAssertionEvaluationSchema, + materialEffects: Schema.Array(PhysicalStockEffectRecordSchema), +}); + +export const MissingExternalStockSourceEvidenceSchema = Schema.TaggedStruct('MISSING', { + ...sourceCommon, + meaning: Schema.Literal('EXTERNAL_SOURCE_ASSERTION'), +}); + +export const StockSourceEvidenceForAvailabilitySchema = Schema.Union([ + OwnerManagedStockSourceEvidenceSchema, + ExternalStockSourceAssertionEvidenceSchema, + MissingExternalStockSourceEvidenceSchema, +]); +export type StockSourceEvidenceForAvailability = typeof StockSourceEvidenceForAvailabilitySchema.Type; + +export const InventoryStockEvidenceForAvailabilitySchema = Schema.Struct({ + binding: CatalogToStockBindingSchema, + committedObligations: Schema.Array( + Schema.Union([RuntimeCommittedInventoryObligationSchema, ImportedCommittedObligationSchema]), + ), + customerFacingAvailabilityPublished: Schema.Literal(false), + position: StockPositionSchema, + provisionalReserved: StockPositionReservedEvidenceSchema, + purpose: Schema.Literal('STOCK_EVIDENCE_ONLY'), + sourceEvidence: StockSourceEvidenceForAvailabilitySchema, + stockItem: StockItemSchema, + stockLocation: StockLocationSchema, + unresolvedReservationEffectConstraints: Schema.Array(UnresolvedReservationEffectConstraintSchema), +}); +export type InventoryStockEvidenceForAvailability = typeof InventoryStockEvidenceForAvailabilitySchema.Type; + +export class CurrentStockEvidenceForAvailabilityRejected extends Schema.TaggedError()( + 'CurrentStockEvidenceForAvailabilityRejected', + { + code: Schema.Literal('current_stock_evidence_for_availability_rejected'), + reason: Schema.Literals([ + 'AUTHORITY_NOT_FOUND', + 'BINDING_NOT_FOUND', + 'EVIDENCE_SCOPE_MISMATCH', + 'INVALID_EVIDENCE', + 'POSITION_NOT_CURRENT', + 'POSITION_NOT_FOUND', + 'STOCK_ITEM_NOT_CURRENT', + 'STOCK_ITEM_NOT_FOUND', + 'STOCK_LOCATION_NOT_ACTIVE', + 'STOCK_LOCATION_NOT_FOUND', + ]), + }, +) {} + +export type ReservationCreateEffectForAvailability = + | typeof RequestedReservationCreateEffectSchema.Type + | typeof ReconciliationRequiredReservationCreateEffectSchema.Type + | typeof IndeterminateReservationCreateEffectSchema.Type; + +export { CurrentStockEvidenceForAvailabilityUnavailable } from './current-stock-evidence-for-availability-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/external-stock-correlation-persistence-unavailable.ts b/app/verticals/inventory/shared/domain/external-stock-correlation-persistence-unavailable.ts new file mode 100644 index 000000000..2afc16f8f --- /dev/null +++ b/app/verticals/inventory/shared/domain/external-stock-correlation-persistence-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class ExternalStockCorrelationPersistenceUnavailable extends Schema.TaggedError()( + 'ExternalStockCorrelationPersistenceUnavailable', + { + code: Schema.Literal('external_stock_correlation_persistence_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/external-stock-correlation-rejected.ts b/app/verticals/inventory/shared/domain/external-stock-correlation-rejected.ts new file mode 100644 index 000000000..da6abf3ec --- /dev/null +++ b/app/verticals/inventory/shared/domain/external-stock-correlation-rejected.ts @@ -0,0 +1,23 @@ +import { Schema } from 'effect'; + +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; + +export class ExternalStockCorrelationRejected extends Schema.TaggedError()( + 'ExternalStockCorrelationRejected', + { + code: Schema.Literal('external_stock_correlation_rejected'), + correlationRef: Schema.optionalKey(ExternalStockCorrelationRefSchema), + reason: Schema.Literals([ + 'AMBIGUOUS_EFFECTIVE_CORRELATION', + 'CORRELATION_IDENTITY_CONFLICT', + 'CORRELATION_NOT_CURRENT', + 'CORRELATION_NOT_FOUND', + 'CORRELATION_REVISION_CONFLICT', + 'INVALID_CORRELATION', + 'OVERLAPPING_EFFECTIVE_PERIOD', + 'TARGET_NOT_FOUND', + 'TARGET_UNCHANGED', + 'TENANT_SCOPE_MISMATCH', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/external-stock-correlation.ts b/app/verticals/inventory/shared/domain/external-stock-correlation.ts new file mode 100644 index 000000000..ead057918 --- /dev/null +++ b/app/verticals/inventory/shared/domain/external-stock-correlation.ts @@ -0,0 +1,374 @@ +import type { Effect as EffectType } from 'effect'; +import { Effect, Option, Schema } from 'effect'; + +import type { ExternalStockCorrelationPersistenceUnavailable } from './external-stock-correlation-persistence-unavailable.ts'; +import { ExternalStockCorrelationRejected } from './external-stock-correlation-rejected.ts'; +import { + InventoryBackendConfigurationSchema, + InventoryBackendSelectionSchema, +} from './inventory-backend-configuration.ts'; +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockLocationRefSchema } from '../resources/stock-location.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +export const ExternalStockCorrelationInstantSchema = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const InventoryBackendOriginSchema = Schema.Struct({ + backendId: InventoryBackendSelectionSchema.fields.backendId, + backendKind: InventoryBackendSelectionSchema.fields.backend, +}); +export type InventoryBackendOrigin = typeof InventoryBackendOriginSchema.Type; + +export const ExternalStockIdentifierKindSchema = Schema.Literals(['ITEM', 'LOCATION']); + +/** + * Literal external identifiers are meaningful only inside this complete qualification. The + * selected backend is deliberately absent: cutover never re-qualifies evidence from its issuer. + */ +export const ExternalStockKeySchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + externalScope: boundedText, + externalValue: boundedText, + identifierKind: ExternalStockIdentifierKindSchema, + issuer: InventoryBackendOriginSchema, + namespace: boundedText, + tenantId: ExternalStockCorrelationRefSchema.fields.tenantId, +}); +export type ExternalStockKey = typeof ExternalStockKeySchema.Type; + +export const ExternalStockItemTargetSchema = Schema.TaggedStruct('STOCK_ITEM', { ref: StockItemRefSchema }); +export const ExternalStockLocationTargetSchema = Schema.TaggedStruct('STOCK_LOCATION', { ref: StockLocationRefSchema }); +export const ExternalStockTargetSchema = Schema.Union([ + ExternalStockItemTargetSchema, + ExternalStockLocationTargetSchema, +]); +export type ExternalStockTarget = typeof ExternalStockTargetSchema.Type; + +export const ExternalStockCorrelationEffectivePeriodSchema = Schema.Struct({ + from: ExternalStockCorrelationInstantSchema, + to: Schema.toEncoded(Schema.OptionFromNullOr(ExternalStockCorrelationInstantSchema)), +}).check( + Schema.makeFilter(({ from, to }) => + to === null || from < to ? undefined : 'Effective Period must be non-empty and half-open', + ), +); + +export const ExternalStockCorrelationSchema = Schema.Struct({ + confirmedAt: ExternalStockCorrelationInstantSchema, + correlationRef: ExternalStockCorrelationRefSchema, + effectivePeriod: ExternalStockCorrelationEffectivePeriodSchema, + externalKey: ExternalStockKeySchema, + lifecycle: Schema.Literals(['CURRENT', 'ENDED']), + ownerEvidenceRef: boundedText, + revision: Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })), + target: ExternalStockTargetSchema, +}).check( + Schema.makeFilter((correlation) => { + if ( + correlation.correlationRef.tenantId !== correlation.externalKey.tenantId || + correlation.correlationRef.tenantId !== correlation.target.ref.tenantId + ) { + return 'Correlation key, identity, and target must share one Tenant'; + } + const itemTarget = Schema.is(ExternalStockItemTargetSchema)(correlation.target); + const locationTarget = Schema.is(ExternalStockLocationTargetSchema)(correlation.target); + if ( + (correlation.externalKey.identifierKind === 'ITEM' && !itemTarget) || + (correlation.externalKey.identifierKind === 'LOCATION' && !locationTarget) + ) { + return 'External identifier kind must match the Inventory target kind'; + } + return (correlation.lifecycle === 'CURRENT' && correlation.effectivePeriod.to === null) || + (correlation.lifecycle === 'ENDED' && correlation.effectivePeriod.to !== null) + ? undefined + : 'Correlation lifecycle must match its Effective Period'; + }), +); +export type ExternalStockCorrelation = typeof ExternalStockCorrelationSchema.Type; + +export interface ExternalStockCorrelationReader { + readonly findEffective: ( + externalKey: ExternalStockKey, + asOf: ExternalStockCorrelation['effectivePeriod']['from'], + ) => EffectType.Effect; +} + +export const ResolvedExternalStockCorrelationSchema = Schema.TaggedStruct('RESOLVED', { + correlationRef: ExternalStockCorrelationRefSchema, + effectivePeriod: ExternalStockCorrelationEffectivePeriodSchema, + externalKey: ExternalStockKeySchema, + selectedBackendOriginMatch: Schema.Literals(['MATCHES_SELECTED_BACKEND', 'OUTSIDE_SELECTED_BACKEND']), + target: ExternalStockTargetSchema, +}); +export const UnresolvedExternalStockCorrelationSchema = Schema.TaggedStruct('UNRESOLVED', { + asOf: ExternalStockCorrelationInstantSchema, + externalKey: ExternalStockKeySchema, +}); +export const AmbiguousExternalStockCorrelationSchema = Schema.TaggedStruct('AMBIGUOUS', { + asOf: ExternalStockCorrelationInstantSchema, + candidateCorrelationRefs: Schema.Array(ExternalStockCorrelationRefSchema).check(Schema.isMinLength(2)), + externalKey: ExternalStockKeySchema, +}); +export const ExternalStockCorrelationResolutionSchema = Schema.Union([ + ResolvedExternalStockCorrelationSchema, + UnresolvedExternalStockCorrelationSchema, + AmbiguousExternalStockCorrelationSchema, +]); +export type ExternalStockCorrelationResolution = typeof ExternalStockCorrelationResolutionSchema.Type; + +export const ExternalStockCorrelationResolutionInputSchema = Schema.Struct({ + asOf: ExternalStockCorrelationInstantSchema, + externalKey: ExternalStockKeySchema, + selectedConfiguration: InventoryBackendConfigurationSchema, +}); +export type ExternalStockCorrelationResolutionInput = typeof ExternalStockCorrelationResolutionInputSchema.Type; + +export type ExternalStockCorrelationPersistenceError = + | ExternalStockCorrelationPersistenceUnavailable + | ExternalStockCorrelationRejected; + +export interface ExternalStockCorrelationPersistence extends ExternalStockCorrelationReader { + readonly endCurrent: (input: { + readonly current: ExternalStockCorrelation; + readonly endedAt: ExternalStockCorrelation['effectivePeriod']['from']; + }) => EffectType.Effect; + readonly findByRef: ( + correlationRef: ExternalStockCorrelation['correlationRef'], + ) => EffectType.Effect, ExternalStockCorrelationPersistenceError>; + readonly insertCurrent: ( + correlation: ExternalStockCorrelation, + ) => EffectType.Effect; + readonly replaceCurrent: (input: { + readonly current: ExternalStockCorrelation; + readonly endedAt: ExternalStockCorrelation['effectivePeriod']['from']; + readonly replacement: ExternalStockCorrelation; + }) => EffectType.Effect; + readonly saveConfirmation: (input: { + readonly expectedRevision: number; + readonly next: ExternalStockCorrelation; + }) => EffectType.Effect; +} + +const sameBackendOrigin = (left: InventoryBackendOrigin, right: InventoryBackendOrigin): boolean => + left.backendKind === right.backendKind && left.backendId === right.backendId; + +const selectedConfigurationAuthorizes = (input: ExternalStockCorrelationResolutionInput): boolean => + String(input.selectedConfiguration.tenantId) === String(input.externalKey.tenantId) && + input.selectedConfiguration.customerConfigurationId === input.externalKey.customerConfigurationId && + sameBackendOrigin( + { + backendId: input.selectedConfiguration.selection.backendId, + backendKind: input.selectedConfiguration.selection.backend, + }, + input.externalKey.issuer, + ); + +/** Resolution is exact only. Missing and conflicting owner records remain explicit outcomes. */ +export const makeExternalStockCorrelationResolver = (reader: ExternalStockCorrelationReader) => ({ + resolve: ( + input: ExternalStockCorrelationResolutionInput, + ): EffectType.Effect => + reader.findEffective(input.externalKey, input.asOf).pipe( + Effect.map((correlations) => { + const [correlation] = correlations; + if (correlation === undefined) { + return { _tag: 'UNRESOLVED' as const, asOf: input.asOf, externalKey: input.externalKey }; + } + if (correlations.length !== 1) { + return { + _tag: 'AMBIGUOUS' as const, + asOf: input.asOf, + candidateCorrelationRefs: correlations.map((candidate) => candidate.correlationRef), + externalKey: input.externalKey, + }; + } + return { + _tag: 'RESOLVED' as const, + correlationRef: correlation.correlationRef, + effectivePeriod: correlation.effectivePeriod, + externalKey: input.externalKey, + selectedBackendOriginMatch: selectedConfigurationAuthorizes(input) + ? ('MATCHES_SELECTED_BACKEND' as const) + : ('OUTSIDE_SELECTED_BACKEND' as const), + target: correlation.target, + }; + }), + ), +}); + +export const EstablishExternalStockCorrelationInputSchema = Schema.Struct({ + effectiveFrom: ExternalStockCorrelationInstantSchema, + externalKey: ExternalStockKeySchema, + ownerEvidenceRef: boundedText, + target: ExternalStockTargetSchema, +}); +export type EstablishExternalStockCorrelationInput = typeof EstablishExternalStockCorrelationInputSchema.Type; + +export const CorrectExternalStockCorrelationInputSchema = Schema.Struct({ + correctedAt: ExternalStockCorrelationInstantSchema, + externalKey: ExternalStockKeySchema, + ownerEvidenceRef: boundedText, + target: ExternalStockTargetSchema, +}); +export type CorrectExternalStockCorrelationInput = typeof CorrectExternalStockCorrelationInputSchema.Type; + +export const EndExternalStockCorrelationInputSchema = Schema.Struct({ + endedAt: ExternalStockCorrelationInstantSchema, + externalKey: ExternalStockKeySchema, +}); +export type EndExternalStockCorrelationInput = typeof EndExternalStockCorrelationInputSchema.Type; + +export const ConfirmExternalStockCorrelationInputSchema = Schema.Struct({ + confirmedAt: ExternalStockCorrelationInstantSchema, + correlationRef: ExternalStockCorrelationRefSchema, + ownerEvidenceRef: boundedText, +}); +export type ConfirmExternalStockCorrelationInput = typeof ConfirmExternalStockCorrelationInputSchema.Type; + +const rejected = ( + reason: ExternalStockCorrelationRejected['reason'], + correlationRef?: ExternalStockCorrelation['correlationRef'], +) => + correlationRef === undefined + ? new ExternalStockCorrelationRejected({ code: 'external_stock_correlation_rejected', reason }) + : new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef, + reason, + }); + +const rejectedFromCause = ( + cause: unknown, + reason: ExternalStockCorrelationRejected['reason'], + correlationRef?: ExternalStockCorrelation['correlationRef'], +) => { + const failure = rejected(reason, correlationRef); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +const sameTarget = (left: ExternalStockTarget, right: ExternalStockTarget): boolean => { + if (Schema.is(ExternalStockItemTargetSchema)(left) && Schema.is(ExternalStockItemTargetSchema)(right)) { + return left.ref.tenantId === right.ref.tenantId && left.ref.resourceId === right.ref.resourceId; + } + if (Schema.is(ExternalStockLocationTargetSchema)(left) && Schema.is(ExternalStockLocationTargetSchema)(right)) { + return left.ref.tenantId === right.ref.tenantId && left.ref.resourceId === right.ref.resourceId; + } + return false; +}; + +const makeCandidate = ( + makeCorrelationId: () => string, + input: { + readonly effectiveFrom: ExternalStockCorrelation['effectivePeriod']['from']; + readonly externalKey: ExternalStockKey; + readonly ownerEvidenceRef: string; + readonly target: ExternalStockTarget; + }, +) => + Schema.decodeEffect(ExternalStockCorrelationSchema)({ + confirmedAt: input.effectiveFrom, + correlationRef: { + moduleId: 'commerce.inventory', + resourceId: makeCorrelationId(), + resourceType: 'commerce.inventory.external-stock-correlation', + tenantId: input.externalKey.tenantId, + }, + effectivePeriod: { + from: input.effectiveFrom, + to: null, + }, + externalKey: input.externalKey, + lifecycle: 'CURRENT', + ownerEvidenceRef: input.ownerEvidenceRef, + revision: 1, + target: input.target, + }).pipe(Effect.mapError((cause) => rejectedFromCause(cause, 'INVALID_CORRELATION'))); + +const requireOneCurrent = ( + candidates: readonly ExternalStockCorrelation[], +): EffectType.Effect => { + const [candidate] = candidates; + if (candidate === undefined) { + return Effect.fail(rejected('CORRELATION_NOT_FOUND')); + } + if (candidates.length !== 1) { + return Effect.fail(rejected('AMBIGUOUS_EFFECTIVE_CORRELATION')); + } + return candidate.lifecycle === 'CURRENT' + ? Effect.succeed(candidate) + : Effect.fail(rejected('CORRELATION_NOT_CURRENT', candidate.correlationRef)); +}; + +/** + * Owner-governed lifecycle. Correction closes the old half-open period and creates a different + * correlation identity; it never rewrites the old target or its historical meaning. + */ +export const makeExternalStockCorrelationLifecycle = ( + persistence: ExternalStockCorrelationPersistence, + options: { readonly makeCorrelationId: () => string }, +) => ({ + confirm: (input: ConfirmExternalStockCorrelationInput) => + persistence.findByRef(input.correlationRef).pipe( + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(rejected('CORRELATION_NOT_FOUND', input.correlationRef)), + onSome: (current) => + current.lifecycle === 'CURRENT' + ? Schema.decodeEffect(ExternalStockCorrelationSchema)({ + ...current, + confirmedAt: input.confirmedAt, + ownerEvidenceRef: input.ownerEvidenceRef, + revision: current.revision + 1, + }).pipe( + Effect.mapError((cause) => rejectedFromCause(cause, 'INVALID_CORRELATION', current.correlationRef)), + Effect.flatMap((next) => persistence.saveConfirmation({ expectedRevision: current.revision, next })), + ) + : Effect.fail(rejected('CORRELATION_NOT_CURRENT', current.correlationRef)), + }), + ), + ), + correct: (input: CorrectExternalStockCorrelationInput) => + persistence.findEffective(input.externalKey, input.correctedAt).pipe( + Effect.flatMap(requireOneCurrent), + Effect.flatMap((current) => { + if (current.effectivePeriod.from >= input.correctedAt) { + return Effect.fail(rejected('INVALID_CORRELATION', current.correlationRef)); + } + if (sameTarget(current.target, input.target)) { + return Effect.fail(rejected('TARGET_UNCHANGED', current.correlationRef)); + } + return makeCandidate(options.makeCorrelationId, { + effectiveFrom: input.correctedAt, + externalKey: input.externalKey, + ownerEvidenceRef: input.ownerEvidenceRef, + target: input.target, + }).pipe( + Effect.flatMap((replacement) => + persistence.replaceCurrent({ current, endedAt: input.correctedAt, replacement }), + ), + ); + }), + ), + end: (input: EndExternalStockCorrelationInput) => + persistence.findEffective(input.externalKey, input.endedAt).pipe( + Effect.flatMap(requireOneCurrent), + Effect.flatMap((current) => + current.effectivePeriod.from < input.endedAt + ? persistence.endCurrent({ current, endedAt: input.endedAt }) + : Effect.fail(rejected('INVALID_CORRELATION', current.correlationRef)), + ), + ), + establish: (input: EstablishExternalStockCorrelationInput) => + persistence + .findEffective(input.externalKey, input.effectiveFrom) + .pipe( + Effect.flatMap((existing) => + existing.length === 0 + ? makeCandidate(options.makeCorrelationId, input).pipe(Effect.flatMap(persistence.insertCurrent)) + : Effect.fail(rejected('OVERLAPPING_EFFECTIVE_PERIOD')), + ), + ), +}); diff --git a/app/verticals/inventory/shared/domain/fixed-set-stock-item-binding.ts b/app/verticals/inventory/shared/domain/fixed-set-stock-item-binding.ts new file mode 100644 index 000000000..167f85b4d --- /dev/null +++ b/app/verticals/inventory/shared/domain/fixed-set-stock-item-binding.ts @@ -0,0 +1,55 @@ +import { SetCompositionSelectionRevisionSchema } from '@app/catalog/domain/catalog-selection-evidence'; +import type { Effect as EffectType } from 'effect'; +import { Effect, Schema } from 'effect'; + +import { ResolvedCatalogStockDemandSchema } from './catalog-to-stock-binding.ts'; +import type { ResolvedCatalogStockDemand } from './catalog-to-stock-binding.ts'; + +export const FixedSetStockRequirementSchema = Schema.Struct({ + ...ResolvedCatalogStockDemandSchema.fields, + componentDecomposition: Schema.Literal('PROHIBITED'), + setCompositionRevision: SetCompositionSelectionRevisionSchema, + stockRepresentation: Schema.Literal('ONE_EXACT_SET_STOCK_ITEM'), +}); +export type FixedSetStockRequirement = typeof FixedSetStockRequirementSchema.Type; + +export class FixedSetStockItemBindingRejected extends Schema.TaggedError()( + 'FixedSetStockItemBindingRejected', + { + code: Schema.Literal('fixed_set_stock_item_binding_rejected'), + exactSelectionMeaningId: ResolvedCatalogStockDemandSchema.fields.exactSelectionMeaning.fields.id, + reason: Schema.Literals(['EXACT_SELECTION_IS_NOT_A_SET', 'SET_COMPOSITION_REVISION_MISSING']), + }, +) {} + +const rejected = ( + demand: ResolvedCatalogStockDemand, + reason: FixedSetStockItemBindingRejected['reason'], +): FixedSetStockItemBindingRejected => + new FixedSetStockItemBindingRejected({ + code: 'fixed_set_stock_item_binding_rejected', + exactSelectionMeaningId: demand.exactSelectionMeaning.id, + reason, + }); + +/** + * Specializes the exact Catalog-to-Stock binding for a Set without inspecting, + * multiplying, substituting, or allocating any component stock. + */ +export const resolveFixedSetStockRequirement = ( + resolved: ResolvedCatalogStockDemand, +): EffectType.Effect => { + if (resolved.exactSelectionMeaning.kind !== 'SET_VARIANT') { + return Effect.fail(rejected(resolved, 'EXACT_SELECTION_IS_NOT_A_SET')); + } + const setCompositionRevision = resolved.catalogSelection.setComposition; + if (setCompositionRevision === undefined) { + return Effect.fail(rejected(resolved, 'SET_COMPOSITION_REVISION_MISSING')); + } + return Effect.succeed({ + ...resolved, + componentDecomposition: 'PROHIBITED', + setCompositionRevision, + stockRepresentation: 'ONE_EXACT_SET_STOCK_ITEM', + }); +}; diff --git a/app/verticals/inventory/shared/domain/imported-order-commit-proof-rejected.ts b/app/verticals/inventory/shared/domain/imported-order-commit-proof-rejected.ts new file mode 100644 index 000000000..047f6ad7d --- /dev/null +++ b/app/verticals/inventory/shared/domain/imported-order-commit-proof-rejected.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class ImportedOrderCommitProofRejected extends Schema.TaggedError()( + 'ImportedOrderCommitProofRejected', + { + code: Schema.Literal('imported_order_commit_proof_rejected'), + reason: Schema.Literals(['ORDER_NOT_PROVEN_COMMITTED', 'SOURCE_LINEAGE_INVALID']), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/imported-order-commit-proof-unavailable.ts b/app/verticals/inventory/shared/domain/imported-order-commit-proof-unavailable.ts new file mode 100644 index 000000000..ebcb72052 --- /dev/null +++ b/app/verticals/inventory/shared/domain/imported-order-commit-proof-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class ImportedOrderCommitProofUnavailable extends Schema.TaggedError()( + 'ImportedOrderCommitProofUnavailable', + { + code: Schema.Literal('imported_order_commit_proof_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-attempt-replacement-lineage.ts b/app/verticals/inventory/shared/domain/inventory-attempt-replacement-lineage.ts new file mode 100644 index 000000000..e6258e3d9 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-attempt-replacement-lineage.ts @@ -0,0 +1,324 @@ +import { Effect, Result, Schema } from 'effect'; + +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { ProvisionalInventoryReservationSchema } from './inventory-obligation.ts'; +import type { ProvisionalInventoryReservation } from './inventory-obligation.ts'; +import { + EstablishedReservationCreateEffectSchema, + ReservationCreateEffectSchema, + ResolvedNoReservationCreateEffectSchema, +} from './inventory-reservation-create.ts'; +import type { ReservationCreateEffect } from './inventory-reservation-create.ts'; +import { + ReleasedReservationEffectSchema, + ReservationReleaseCommittedTruthSchema, + ReservationReleaseEffectSchema, + ReservationReleaseEffectIdSchema, + ReservationReleaseNotCommittedClosedTruthSchema, + ReservationReleaseNotCommittedOpenTruthSchema, + ReservationReleaseOrderIndeterminateTruthSchema, + ReservationReleaseOrderTruthSchema, +} from './inventory-reservation-release.ts'; +import type { ReservationReleaseOrderTruth } from './inventory-reservation-release.ts'; +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const InventoryAttemptReplacementCauseSchema = Schema.Literals([ + 'FAILED', + 'ABANDONED', + 'CONFIRMATION_EXPIRED', + 'CONFIRMATION_REVOKED', +]); + +export const InventoryReplacementAttemptSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + authority: InventoryBackendConfigurationSchema, + createEffectId: ReservationAuthorityEffectIdSchema, + reservationRef: InventoryReservationRefSchema, +}); +export type InventoryReplacementAttempt = typeof InventoryReplacementAttemptSchema.Type; + +export const InventoryAttemptReplacementEvaluationSchema = Schema.Struct({ + evaluatedAt: instant, + orderTruth: ReservationReleaseOrderTruthSchema, + predecessorCreateEffect: ReservationCreateEffectSchema, + predecessorReleaseEffect: Schema.optionalKey(ReservationReleaseEffectSchema), + replacement: InventoryReplacementAttemptSchema, + replacementCause: InventoryAttemptReplacementCauseSchema, +}); +export type InventoryAttemptReplacementEvaluation = typeof InventoryAttemptReplacementEvaluationSchema.Type; + +const predecessorIdentityFields = { + attemptId: OrderCommitmentAttemptIdSchema, + authority: InventoryBackendConfigurationSchema, + createEffectId: ReservationAuthorityEffectIdSchema, + reservationRef: InventoryReservationRefSchema, +} as const; + +export const InventoryAttemptReplacementLineageSchema = Schema.Struct({ + closureProof: ReservationReleaseNotCommittedClosedTruthSchema, + establishedAt: instant, + predecessor: Schema.Struct(predecessorIdentityFields), + predecessorResolution: Schema.Union([ + Schema.TaggedStruct('NO_RESERVATION_PROVEN', { + effectAbsenceProven: Schema.Literal(true), + observedAt: instant, + }), + Schema.TaggedStruct('RESERVATION_RELEASED', { + ownerEvidenceRef: boundedText, + releasedAt: instant, + releaseEffectId: ReservationReleaseEffectIdSchema, + }), + ]), + replacement: Schema.Struct(predecessorIdentityFields), + replacementCause: InventoryAttemptReplacementCauseSchema, +}); +export type InventoryAttemptReplacementLineage = typeof InventoryAttemptReplacementLineageSchema.Type; + +export const InventoryAttemptReplacementBlockedSchema = Schema.TaggedStruct('BLOCKED', { + debtAttemptId: OrderCommitmentAttemptIdSchema, + evaluatedAt: instant, + reason: Schema.Literals([ + 'PREDECESSOR_COMMITTED', + 'PREDECESSOR_NOT_CLOSED', + 'PREDECESSOR_TRUTH_INDETERMINATE', + 'PREDECESSOR_CREATE_EFFECT_UNRESOLVED', + 'PREDECESSOR_RESERVATION_UNRESOLVED', + ]), + replacementAllowed: Schema.Literal(false), +}); + +export const InventoryAttemptReplacementEligibleSchema = Schema.TaggedStruct('ELIGIBLE', { + lineage: InventoryAttemptReplacementLineageSchema, + replacementAllowed: Schema.Literal(true), +}); + +export const InventoryAttemptReplacementDecisionSchema = Schema.Union([ + InventoryAttemptReplacementBlockedSchema, + InventoryAttemptReplacementEligibleSchema, +]); +export type InventoryAttemptReplacementDecision = typeof InventoryAttemptReplacementDecisionSchema.Type; + +export class InventoryAttemptReplacementRejected extends Schema.TaggedError()( + 'InventoryAttemptReplacementRejected', + { + code: Schema.Literal('inventory_attempt_replacement_rejected'), + reason: Schema.Literals([ + 'ATTEMPT_IDENTITY_REUSED', + 'RESERVATION_IDENTITY_REUSED', + 'CREATE_EFFECT_IDENTITY_REUSED', + 'TENANT_SCOPE_MISMATCH', + 'BACKEND_SWITCH_REQUIRES_CUTOVER', + 'PREDECESSOR_RESOLUTION_SCOPE_MISMATCH', + ]), + }, +) {} + +const sameRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameAuthority = ( + left: typeof InventoryBackendConfigurationSchema.Type, + right: typeof InventoryBackendConfigurationSchema.Type, +) => + left.configurationId === right.configurationId && + left.customerConfigurationId === right.customerConfigurationId && + left.revision === right.revision && + left.selectedAt === right.selectedAt && + left.tenantId === right.tenantId && + left.selection.backend === right.selection.backend && + left.selection.backendId === right.selection.backendId && + left.selection.exactReservationCapability === right.selection.exactReservationCapability && + left.selection.stockCorrectionCapability === right.selection.stockCorrectionCapability; + +const reject = (reason: InventoryAttemptReplacementRejected['reason']) => + Effect.fail(new InventoryAttemptReplacementRejected({ code: 'inventory_attempt_replacement_rejected', reason })); + +const blocked = ( + attemptId: typeof OrderCommitmentAttemptIdSchema.Type, + evaluatedAt: string, + reason: (typeof InventoryAttemptReplacementBlockedSchema.Type)['reason'], +): InventoryAttemptReplacementDecision => ({ + _tag: 'BLOCKED', + debtAttemptId: attemptId, + evaluatedAt, + reason, + replacementAllowed: false, +}); + +const requireDistinctReplacementIdentity = ( + predecessor: ReservationCreateEffect, + replacement: InventoryReplacementAttempt, +) => { + const { request } = predecessor; + if (request.reservation.origin.attemptId === replacement.attemptId) { + return reject('ATTEMPT_IDENTITY_REUSED'); + } + if (sameRef(request.reservation.ref, replacement.reservationRef)) { + return reject('RESERVATION_IDENTITY_REUSED'); + } + if (request.effectId === replacement.createEffectId) { + return reject('CREATE_EFFECT_IDENTITY_REUSED'); + } + if ( + request.reservation.ref.tenantId !== replacement.reservationRef.tenantId || + request.authority.tenantId !== replacement.authority.tenantId + ) { + return reject('TENANT_SCOPE_MISMATCH'); + } + if (!sameAuthority(request.authority, replacement.authority)) { + return reject('BACKEND_SWITCH_REQUIRES_CUTOVER'); + } + return Effect.void; +}; + +const canonicalReservationSchema = Schema.fromJsonString(ProvisionalInventoryReservationSchema); +const canonicalReservation = (reservation: ProvisionalInventoryReservation) => + Result.getOrThrow(Schema.encodeResult(canonicalReservationSchema)(reservation)); + +const issuerMatchesAuthority = ( + authority: typeof InventoryBackendConfigurationSchema.Type, + issuer: (typeof ReleasedReservationEffectSchema.Type)['authorityIssuer'], +) => + issuer.backend === authority.selection.backend && + issuer.backendId === authority.selection.backendId && + issuer.origin === + (authority.selection.backend === 'external_business_system' ? 'EXTERNAL_BUSINESS_SYSTEM' : 'ONTOS_WMS'); + +const releaseMatchesPredecessor = ( + createEffect: typeof EstablishedReservationCreateEffectSchema.Type, + releaseEffect: typeof ReleasedReservationEffectSchema.Type, + closureProof: typeof ReservationReleaseNotCommittedClosedTruthSchema.Type, +) => + releaseEffect.safelyReusable && + releaseEffect.request.legalEntityId === createEffect.request.legalEntityId && + canonicalReservation(releaseEffect.request.reservation) === canonicalReservation(createEffect.reservation) && + issuerMatchesAuthority(createEffect.request.authority, releaseEffect.authorityIssuer) && + releaseEffect.safeReleaseProof.order.closureEvidenceRef === closureProof.closureEvidenceRef && + releaseEffect.safeReleaseProof.order.nonCommitEvidenceRef === closureProof.nonCommitEvidenceRef && + releaseEffect.safeReleaseProof.order.observedAt === closureProof.observedAt; + +export const evaluateInventoryAttemptReplacement = Effect.fn('InventoryAttemptReplacement.evaluate')( + function* evaluateInventoryAttemptReplacement( + input: InventoryAttemptReplacementEvaluation, + ): Effect.fn.Return { + const { predecessorCreateEffect: predecessor, replacement } = input; + yield* requireDistinctReplacementIdentity(predecessor, input.replacement); + const { request } = predecessor; + const { attemptId } = request.reservation.origin; + + if (Schema.is(ReservationReleaseCommittedTruthSchema)(input.orderTruth)) { + return blocked(attemptId, input.evaluatedAt, 'PREDECESSOR_COMMITTED'); + } + if (Schema.is(ReservationReleaseNotCommittedOpenTruthSchema)(input.orderTruth)) { + return blocked(attemptId, input.evaluatedAt, 'PREDECESSOR_NOT_CLOSED'); + } + if (Schema.is(ReservationReleaseOrderIndeterminateTruthSchema)(input.orderTruth)) { + return blocked(attemptId, input.evaluatedAt, 'PREDECESSOR_TRUTH_INDETERMINATE'); + } + const closureProof = input.orderTruth; + + let predecessorResolution: (typeof InventoryAttemptReplacementLineageSchema.Type)['predecessorResolution']; + if (Schema.is(ResolvedNoReservationCreateEffectSchema)(predecessor)) { + predecessorResolution = { + _tag: 'NO_RESERVATION_PROVEN', + effectAbsenceProven: predecessor.effectAbsenceProven, + observedAt: predecessor.observedAt, + }; + } else if (Schema.is(EstablishedReservationCreateEffectSchema)(predecessor)) { + const release = input.predecessorReleaseEffect; + if (release === undefined || !Schema.is(ReleasedReservationEffectSchema)(release)) { + return blocked(attemptId, input.evaluatedAt, 'PREDECESSOR_RESERVATION_UNRESOLVED'); + } + if (!releaseMatchesPredecessor(predecessor, release, closureProof)) { + return yield* reject('PREDECESSOR_RESOLUTION_SCOPE_MISMATCH'); + } + predecessorResolution = { + _tag: 'RESERVATION_RELEASED', + ownerEvidenceRef: release.ownerEvidenceRef, + releasedAt: release.releasedAt, + releaseEffectId: release.request.effectId, + }; + } else { + return blocked(attemptId, input.evaluatedAt, 'PREDECESSOR_CREATE_EFFECT_UNRESOLVED'); + } + + return { + _tag: 'ELIGIBLE', + lineage: { + closureProof, + establishedAt: input.evaluatedAt, + predecessor: { + attemptId, + authority: request.authority, + createEffectId: request.effectId, + reservationRef: request.reservation.ref, + }, + predecessorResolution, + replacement, + replacementCause: input.replacementCause, + }, + replacementAllowed: true, + }; + }, +); + +export const InventoryLatePredecessorEffectSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + effectId: ReservationAuthorityEffectIdSchema, + observedAt: instant, + ownerEvidenceRef: boundedText, + reservationRef: InventoryReservationRefSchema, +}); + +export const InventoryLatePredecessorEffectDecisionSchema = Schema.Struct({ + attributedAttemptId: OrderCommitmentAttemptIdSchema, + committedOrderPreserved: Schema.Boolean, + mayEvidenceReplacement: Schema.Literal(false), + mayReopenPredecessor: Schema.Literal(false), + outcome: Schema.Literals(['PREDECESSOR_RECONCILIATION_DEBT', 'REPLACEMENT_CONFLICT_DEBT']), + replacementAttemptId: OrderCommitmentAttemptIdSchema, +}); +export type InventoryLatePredecessorEffectDecision = typeof InventoryLatePredecessorEffectDecisionSchema.Type; + +export const classifyLatePredecessorEffect = ( + lineage: InventoryAttemptReplacementLineage, + effect: typeof InventoryLatePredecessorEffectSchema.Type, + orderTruth: ReservationReleaseOrderTruth, +): Effect.Effect => { + if ( + effect.attemptId !== lineage.predecessor.attemptId || + !sameRef(effect.reservationRef, lineage.predecessor.reservationRef) + ) { + return reject('PREDECESSOR_RESOLUTION_SCOPE_MISMATCH'); + } + const committed = Schema.is(ReservationReleaseCommittedTruthSchema)(orderTruth); + return Effect.succeed({ + attributedAttemptId: lineage.predecessor.attemptId, + committedOrderPreserved: committed, + mayEvidenceReplacement: false, + mayReopenPredecessor: false, + outcome: committed ? 'REPLACEMENT_CONFLICT_DEBT' : 'PREDECESSOR_RECONCILIATION_DEBT', + replacementAttemptId: lineage.replacement.attemptId, + }); +}; diff --git a/app/verticals/inventory/shared/domain/inventory-audit-and-historical-evidence.ts b/app/verticals/inventory/shared/domain/inventory-audit-and-historical-evidence.ts new file mode 100644 index 000000000..c684d2ad2 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-audit-and-historical-evidence.ts @@ -0,0 +1,828 @@ +import { DateTime, Effect, Match, Schema } from 'effect'; + +import { CatalogToStockBindingHistoryEntrySchema, CatalogToStockBindingSchema } from './catalog-to-stock-binding.ts'; +import { CommitmentProtectionSchema } from './commitment-protection.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import type { InventoryEffectLedgerResolutionSchema } from './inventory-effect-ledger.ts'; +import { InventoryEffectLedgerRecordSchema } from './inventory-effect-ledger.ts'; +import { + ImportedCommittedObligationSchema, + InventoryObligationRequirementSchema, + InventoryStockAllocationSchema, + ProvisionalInventoryReservationSchema, + RuntimeCommittedInventoryObligationSchema, +} from './inventory-obligation.ts'; +import { InventorySourceAssertionSchema } from './inventory-source-assertion.ts'; +import { ReservationReleaseEffectSchema } from './inventory-reservation-release.ts'; +import { PhysicalStockEffectRecordSchema } from './physical-stock-effect.ts'; +import { ReservationConfirmationSchema, advanceReservationConfirmationHealth } from './reservation-confirmation.ts'; +import { + ReservationShortageImpactEvaluationSchema, + ReservationShortageImpactInputSchema, + evaluateReservationShortageImpact, +} from './reservation-shortage-impact.ts'; +import { StockCorrectionRecordSchema } from './stock-correction.ts'; + +const boundedAuditReference = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const auditInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const HistoricalIssuedObservationSchema = Schema.TaggedStruct('ISSUED', { + effectiveAt: auditInstant, + ownerEvidenceRef: boundedAuditReference, +}); +const InventoryAuditActorIdSchema = boundedAuditReference.pipe(Schema.brand('InventoryAuditActorId')); +const InventoryAuditPrincipalIdSchema = boundedAuditReference.pipe(Schema.brand('InventoryAuditPrincipalId')); +const InventoryAuditEffectCorrelationIdSchema = boundedAuditReference.pipe( + Schema.brand('InventoryAuditEffectCorrelationId'), +); + +export const InventoryAuditActorContextSchema = Schema.Struct({ + actorId: InventoryAuditActorIdSchema, + authorizationEvidenceRef: boundedAuditReference, + permission: boundedAuditReference, + policyEvidenceRef: Schema.optionalKey(boundedAuditReference), + principalId: InventoryAuditPrincipalIdSchema, +}); + +export const InventoryHistoricalRequirementEvidenceSchema = Schema.Struct({ + acceptedBinding: CatalogToStockBindingSchema, + allocations: Schema.Array(InventoryStockAllocationSchema).check(Schema.isMinLength(1)), + currentCorrection: Schema.optionalKey( + Schema.Struct({ + currentBinding: CatalogToStockBindingSchema, + historyEntry: CatalogToStockBindingHistoryEntrySchema, + }), + ), + purchaseDemandOccurrenceId: InventoryObligationRequirementSchema.fields.purchaseDemandOccurrenceId, + quantity: InventoryObligationRequirementSchema.fields.quantity, + unitRef: InventoryObligationRequirementSchema.fields.unitRef, +}); +export type InventoryHistoricalRequirementEvidence = typeof InventoryHistoricalRequirementEvidenceSchema.Type; + +export const InventoryHistoricalShortageDecisionSchema = Schema.Struct({ + decidedAt: auditInstant, + evaluation: ReservationShortageImpactEvaluationSchema, + input: ReservationShortageImpactInputSchema, +}); + +export const InventoryHistoricalBackendTransitionSchema = Schema.Struct({ + effectiveBoundary: auditInstant, + ownerEvidenceRef: boundedAuditReference, + postCutoverConfiguration: InventoryBackendConfigurationSchema, + preCutoverConfiguration: InventoryBackendConfigurationSchema, + purpose: Schema.Literal('PLANNED_BACKEND_REPLACEMENT_NOT_OUTAGE_RECOVERY'), +}); + +export const InventoryHistoricalEvidenceCorrelationSchema = Schema.Struct({ + allocationIds: Schema.Array(InventoryStockAllocationSchema.fields.allocationId).check(Schema.isMinLength(1)), + attemptId: ProvisionalInventoryReservationSchema.fields.origin.fields.attemptId, + authority: InventoryBackendConfigurationSchema, + effectId: InventoryAuditEffectCorrelationIdSchema, + positionRefs: Schema.Array(InventoryStockAllocationSchema.fields.positionRef).check(Schema.isMinLength(1)), + reservationRef: ProvisionalInventoryReservationSchema.fields.ref, +}); + +const relatedEvidence = (tag: Tag, value: Value) => + Schema.TaggedStruct(tag, { correlation: InventoryHistoricalEvidenceCorrelationSchema, value }); + +const InventoryHistoricalEffectLedgerEvidenceSchema = relatedEvidence( + 'EFFECT_LEDGER', + InventoryEffectLedgerRecordSchema, +); + +export const InventoryHistoricalRelatedEvidenceSchema = Schema.Union([ + relatedEvidence('COMMITMENT_PROTECTION', CommitmentProtectionSchema), + InventoryHistoricalEffectLedgerEvidenceSchema, + relatedEvidence('PHYSICAL_STOCK_EFFECT', PhysicalStockEffectRecordSchema), + relatedEvidence('RESERVATION_RELEASE', ReservationReleaseEffectSchema), + relatedEvidence('SOURCE_ASSERTION', InventorySourceAssertionSchema), + relatedEvidence('STOCK_CORRECTION', StockCorrectionRecordSchema), +]); +export type InventoryHistoricalRelatedEvidence = typeof InventoryHistoricalRelatedEvidenceSchema.Type; + +export const InventoryHistoricalCommittedLineageSchema = Schema.Union([ + Schema.TaggedStruct('RUNTIME_COMMITTED', { obligation: RuntimeCommittedInventoryObligationSchema }), + Schema.TaggedStruct('IMPORTED_COMMITTED', { obligation: ImportedCommittedObligationSchema }), +]); + +export const InventoryHistoricalReconciliationIntervalSchema = Schema.Struct({ + attemptId: ProvisionalInventoryReservationSchema.fields.origin.fields.attemptId, + effectId: InventoryEffectLedgerRecordSchema.fields.effectId, + // oxlint-disable-next-line effect-native/no-nullable-schema-field -- Historical reconciliation evidence explicitly distinguishes an open interval from a final authoritative resolution; expires: 2027-03-31. + finalResolution: Schema.NullOr( + Schema.Struct({ + ownerEvidenceRef: boundedAuditReference, + resolvedAt: auditInstant, + state: Schema.Literals(['SUCCEEDED', 'REJECTED']), + }), + ), + indeterminateFrom: auditInstant, + possiblePartialEffectIds: Schema.Array(InventoryEffectLedgerRecordSchema.fields.effectId), +}); + +export const CompileInventoryHistoricalEvidenceInputSchema = Schema.Struct({ + actorContext: Schema.optionalKey(InventoryAuditActorContextSchema), + assembledAt: auditInstant, + backendTransitions: Schema.Array(InventoryHistoricalBackendTransitionSchema), + committedLineage: Schema.Array(InventoryHistoricalCommittedLineageSchema), + confirmationHistory: Schema.Array(ReservationConfirmationSchema), + reconciliationIntervals: Schema.Array(InventoryHistoricalReconciliationIntervalSchema), + relatedEvidence: Schema.Array(InventoryHistoricalRelatedEvidenceSchema), + requirementEvidence: Schema.Array(InventoryHistoricalRequirementEvidenceSchema).check(Schema.isMinLength(1)), + reservation: ProvisionalInventoryReservationSchema, + shortageDecisions: Schema.Array(InventoryHistoricalShortageDecisionSchema), +}); +export type CompileInventoryHistoricalEvidenceInput = typeof CompileInventoryHistoricalEvidenceInputSchema.Type; + +const InventoryHistoricalEvidencePacketBaseSchema = Schema.TaggedStruct('InventoryHistoricalEvidencePacket', { + ...CompileInventoryHistoricalEvidenceInputSchema.fields, + authorityRewriteApplied: Schema.Literal(false), + currentAuthority: InventoryBackendConfigurationSchema, + historicalAllocationSubstitutionApplied: Schema.Literal(false), + historicalAuthority: InventoryBackendConfigurationSchema, + rawProviderPayloadRetained: Schema.Literal(false), +}); + +export const InventoryHistoricalEvidencePacketSchema = InventoryHistoricalEvidencePacketBaseSchema; +export type InventoryHistoricalEvidencePacket = typeof InventoryHistoricalEvidencePacketSchema.Type; + +export class InventoryHistoricalEvidenceRejected extends Schema.TaggedError()( + 'InventoryHistoricalEvidenceRejected', + { + code: Schema.Literal('inventory_historical_evidence_rejected'), + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'REQUIREMENT_EVIDENCE_MISSING', + 'REQUIREMENT_EVIDENCE_MISMATCH', + 'BINDING_CORRECTION_MISMATCH', + 'CONFIRMATION_LINEAGE_MISMATCH', + 'CONFIRMATION_IDENTITY_CONFLICT', + 'CONFIRMATION_RANK_REWRITTEN', + 'CONFIRMATION_HISTORY_INVALID', + 'SHORTAGE_RANK_MISMATCH', + 'BACKEND_LINEAGE_MISMATCH', + 'RELATED_EVIDENCE_SCOPE_MISMATCH', + 'COMMITTED_LINEAGE_MISMATCH', + 'RECONCILIATION_LINEAGE_MISMATCH', + 'INVALID_HISTORICAL_EVIDENCE', + ]), + }, +) {} + +const rejected = (reason: InventoryHistoricalEvidenceRejected['reason']) => + new InventoryHistoricalEvidenceRejected({ code: 'inventory_historical_evidence_rejected', reason }); + +const sameRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameMeaning = ( + left: { readonly id: string; readonly kind: string }, + right: { readonly id: string; readonly kind: string }, +) => left.id === right.id && left.kind === right.kind; + +const sameConfiguration = Schema.toEquivalence(InventoryBackendConfigurationSchema); +const sameRequirements = Schema.toEquivalence(ProvisionalInventoryReservationSchema.fields.requirements); +const sameRank = Schema.toEquivalence(ReservationConfirmationSchema.fields.issuanceRank); +const sameIssuer = Schema.toEquivalence(ReservationConfirmationSchema.fields.authorityEvidence.fields.issuer); +const sameAllocations = Schema.toEquivalence(Schema.Array(InventoryStockAllocationSchema)); +const sameBinding = Schema.toEquivalence(CatalogToStockBindingSchema); +const sameCatalogSelection = Schema.toEquivalence(CatalogToStockBindingSchema.fields.catalogSelection); +const sameConfirmation = Schema.toEquivalence(ReservationConfirmationSchema); +const sameShortageEvaluation = Schema.toEquivalence(ReservationShortageImpactEvaluationSchema); + +const correctionEvidenceMatches = ( + accepted: typeof CatalogToStockBindingSchema.Type, + correction: NonNullable, +) => { + const { currentBinding, historyEntry } = correction; + return ( + historyEntry.transition === 'CORRECTED' && + sameBinding(historyEntry.binding, accepted) && + historyEntry.endedAt === currentBinding.effectiveFrom && + sameRef(currentBinding.bindingRef, accepted.bindingRef) && + sameRef(currentBinding.unitRef, accepted.unitRef) && + sameCatalogSelection(currentBinding.catalogSelection, accepted.catalogSelection) && + sameMeaning(currentBinding.exactSelectionMeaning, accepted.exactSelectionMeaning) && + !sameRef(currentBinding.stockItemRef, accepted.stockItemRef) && + currentBinding.revision > accepted.revision + ); +}; + +const validateRequirementEvidence = ( + input: CompileInventoryHistoricalEvidenceInput, +): InventoryHistoricalEvidenceRejected['reason'] | undefined => { + const byOccurrence = new Map( + input.requirementEvidence.map((evidence) => [String(evidence.purchaseDemandOccurrenceId), evidence]), + ); + if ( + byOccurrence.size !== input.requirementEvidence.length || + byOccurrence.size !== input.reservation.requirements.length + ) { + return 'REQUIREMENT_EVIDENCE_MISSING'; + } + for (const requirement of input.reservation.requirements) { + const evidence = byOccurrence.get(String(requirement.purchaseDemandOccurrenceId)); + if (evidence === undefined) { + return 'REQUIREMENT_EVIDENCE_MISSING'; + } + const accepted = evidence.acceptedBinding; + if ( + evidence.quantity !== requirement.quantity || + !sameRef(evidence.unitRef, requirement.unitRef) || + !sameAllocations(evidence.allocations, requirement.allocations) || + !sameRef(accepted.bindingRef, requirement.bindingRef) || + !sameRef(accepted.stockItemRef, requirement.stockItem.stockItemRef) || + !sameRef(accepted.unitRef, requirement.unitRef) || + !sameCatalogSelection(accepted.catalogSelection, requirement.catalogSelection) || + !sameMeaning(accepted.exactSelectionMeaning, requirement.exactSelectionMeaning) + ) { + return 'REQUIREMENT_EVIDENCE_MISMATCH'; + } + const correction = evidence.currentCorrection; + if (correction !== undefined && !correctionEvidenceMatches(accepted, correction)) { + return 'BINDING_CORRECTION_MISMATCH'; + } + } + return undefined; +}; + +const confirmationGroupKey = (confirmation: typeof ReservationConfirmationSchema.Type) => + `${confirmation.ref.tenantId}:${confirmation.reservation.ref.resourceId}:${confirmation.reservation.origin.attemptId}`; + +const validateConfirmationHistory = ( + input: CompileInventoryHistoricalEvidenceInput, +): InventoryHistoricalEvidenceRejected['reason'] | undefined => { + const groups = new Map(); + for (const confirmation of input.confirmationHistory) { + if (confirmation.ref.tenantId !== input.reservation.ref.tenantId) { + return 'TENANT_SCOPE_MISMATCH'; + } + const key = confirmationGroupKey(confirmation); + groups.set(key, [...(groups.get(key) ?? []), confirmation]); + } + for (const history of groups.values()) { + const [first] = history.toSorted((left, right) => left.revision - right.revision); + if (first === undefined) { + continue; + } + const revisions = new Set(); + for (const confirmation of history) { + if ( + !sameRef(confirmation.ref, first.ref) || + !sameRef(confirmation.reservation.ref, first.reservation.ref) || + confirmation.reservation.origin.attemptId !== first.reservation.origin.attemptId + ) { + return 'CONFIRMATION_IDENTITY_CONFLICT'; + } + if (revisions.has(confirmation.revision)) { + return 'CONFIRMATION_IDENTITY_CONFLICT'; + } + revisions.add(confirmation.revision); + if ( + confirmation.issuedAt !== first.issuedAt || + confirmation.expiresAt !== first.expiresAt || + !sameRank(confirmation.issuanceRank, first.issuanceRank) || + !sameIssuer(confirmation.authorityEvidence.issuer, first.authorityEvidence.issuer) || + confirmation.authorityEvidence.effectId !== first.authorityEvidence.effectId + ) { + return 'CONFIRMATION_RANK_REWRITTEN'; + } + } + } + const subject = input.confirmationHistory.filter( + (confirmation) => + sameRef(confirmation.reservation.ref, input.reservation.ref) && + confirmation.reservation.origin.attemptId === input.reservation.origin.attemptId, + ); + return subject.some( + (confirmation) => + !sameRequirements(confirmation.reservation.requirements, input.reservation.requirements) || + !sameConfiguration(confirmation.reservation.authority, input.reservation.authority), + ) + ? 'CONFIRMATION_LINEAGE_MISMATCH' + : undefined; +}; + +const validateConfirmationTransitions = Effect.fn('InventoryHistoricalEvidence.validateConfirmationTransitions')( + function* validateTransitions(input: CompileInventoryHistoricalEvidenceInput) { + const groups = Map.groupBy(input.confirmationHistory, confirmationGroupKey); + yield* Effect.forEach( + groups.values(), + (history) => { + const ordered = history.toSorted((left, right) => left.revision - right.revision); + const [first, ...rest] = ordered; + if ( + first === undefined || + first.revision !== 1 || + !Schema.is(HistoricalIssuedObservationSchema)(first.health.observation) + ) { + return Effect.fail(rejected('CONFIRMATION_HISTORY_INVALID')); + } + return Effect.reduce( + rest, + () => first, + (previous, current) => { + if ( + current.revision !== previous.revision + 1 || + Schema.is(HistoricalIssuedObservationSchema)(current.health.observation) + ) { + return Effect.fail(rejected('CONFIRMATION_HISTORY_INVALID')); + } + return advanceReservationConfirmationHealth(previous, current.health.observation).pipe( + Effect.mapError((cause) => Object.assign(rejected('CONFIRMATION_HISTORY_INVALID'), { cause })), + Effect.flatMap((advanced) => + sameConfirmation(advanced, current) + ? Effect.succeed(current) + : Effect.fail(rejected('CONFIRMATION_HISTORY_INVALID')), + ), + ); + }, + ); + }, + { concurrency: 1, discard: true }, + ); + }, +); + +const validateShortageHistory = Effect.fn('InventoryHistoricalEvidence.validateShortageHistory')( + function* validateShortage(input: CompileInventoryHistoricalEvidenceInput) { + yield* Effect.forEach( + input.shortageDecisions, + (decision) => + evaluateReservationShortageImpact(decision.input).pipe( + Effect.mapError((cause) => Object.assign(rejected('SHORTAGE_RANK_MISMATCH'), { cause })), + Effect.flatMap((authoritative) => { + const decisionEpoch = DateTime.toEpochMillis(DateTime.makeUnsafe(decision.decidedAt)); + const futureEvidence = decision.input.candidates.some( + ({ confirmation }) => + DateTime.toEpochMillis(DateTime.makeUnsafe(confirmation.health.observation.effectiveAt)) > + decisionEpoch, + ); + return sameShortageEvaluation(authoritative, decision.evaluation) && !futureEvidence + ? Effect.void + : Effect.fail(rejected('SHORTAGE_RANK_MISMATCH')); + }), + ), + { concurrency: 1, discard: true }, + ); + }, +); + +const validateBackendLineage = ( + input: CompileInventoryHistoricalEvidenceInput, +): typeof InventoryBackendConfigurationSchema.Type | undefined => { + let current = input.reservation.authority; + const establishedAt = DateTime.toEpochMillis(DateTime.makeUnsafe(input.reservation.establishedAt)); + if ( + String(current.tenantId) !== String(input.reservation.ref.tenantId) || + DateTime.toEpochMillis(DateTime.makeUnsafe(current.selectedAt)) > establishedAt || + input.reservation.requirements.some( + (requirement) => + String(requirement.bindingRef.tenantId) !== String(current.tenantId) || + requirement.catalogSelection.productRef.tenantId !== current.tenantId || + String(requirement.stockItem.stockItemRef.tenantId) !== String(current.tenantId) || + requirement.unitRef.tenantId !== current.tenantId || + requirement.allocations.some( + (allocation) => + allocation.positionRef.tenantId !== current.tenantId || + String(allocation.stockItemRef.tenantId) !== String(current.tenantId) || + allocation.quantity.unitRef.tenantId !== current.tenantId, + ), + ) + ) { + return undefined; + } + let previousBoundary = establishedAt; + for (const transition of input.backendTransitions) { + const boundary = DateTime.toEpochMillis(DateTime.makeUnsafe(transition.effectiveBoundary)); + if ( + !sameConfiguration(transition.preCutoverConfiguration, current) || + String(transition.preCutoverConfiguration.tenantId) !== String(input.reservation.ref.tenantId) || + transition.preCutoverConfiguration.customerConfigurationId !== + input.reservation.authority.customerConfigurationId || + transition.preCutoverConfiguration.tenantId !== transition.postCutoverConfiguration.tenantId || + transition.preCutoverConfiguration.customerConfigurationId !== + transition.postCutoverConfiguration.customerConfigurationId || + transition.postCutoverConfiguration.selectedAt !== transition.effectiveBoundary || + DateTime.toEpochMillis(DateTime.makeUnsafe(transition.preCutoverConfiguration.selectedAt)) >= boundary || + boundary <= previousBoundary || + transition.preCutoverConfiguration.configurationId === transition.postCutoverConfiguration.configurationId || + transition.preCutoverConfiguration.selection.backendId === transition.postCutoverConfiguration.selection.backendId + ) { + return undefined; + } + current = transition.postCutoverConfiguration; + previousBoundary = boundary; + } + return current; +}; + +const sameReservation = Schema.toEquivalence(ProvisionalInventoryReservationSchema); + +const knownAuthorities = (input: CompileInventoryHistoricalEvidenceInput) => [ + input.reservation.authority, + ...input.backendTransitions.flatMap(({ postCutoverConfiguration, preCutoverConfiguration }) => [ + preCutoverConfiguration, + postCutoverConfiguration, + ]), +]; + +const allAllocations = (input: CompileInventoryHistoricalEvidenceInput) => + input.reservation.requirements.flatMap(({ allocations }) => allocations); + +const correlationAllocations = ( + input: CompileInventoryHistoricalEvidenceInput, + evidence: InventoryHistoricalRelatedEvidence, +) => { + const allocationIds = new Set(evidence.correlation.allocationIds.map(String)); + const positionKeys = new Set( + evidence.correlation.positionRefs.map(({ resourceId, tenantId }) => `${tenantId}:${resourceId}`), + ); + return allAllocations(input).filter( + ({ allocationId, positionRef }) => + allocationIds.has(String(allocationId)) && positionKeys.has(`${positionRef.tenantId}:${positionRef.resourceId}`), + ); +}; + +const authorityRefMatches = ( + authority: typeof InventoryBackendConfigurationSchema.Type, + ref: { readonly resourceId: string; readonly tenantId: string }, +) => authority.configurationId === ref.resourceId && authority.tenantId === ref.tenantId; + +const physicalRequestMatches = ( + request: Pick< + (typeof PhysicalStockEffectRecordSchema.Type)['request'], + | 'backend' + | 'backendConfigurationRef' + | 'backendId' + | 'customerConfigurationId' + | 'effectId' + | 'positionRef' + | 'quantity' + | 'stockItemRef' + >, + expectedEffectId: string, + authority: typeof InventoryBackendConfigurationSchema.Type, + allocations: readonly (typeof InventoryStockAllocationSchema.Type)[], +) => + String(request.effectId) === expectedEffectId && + authorityRefMatches(authority, request.backendConfigurationRef) && + request.customerConfigurationId === authority.customerConfigurationId && + request.backend === authority.selection.backend && + request.backendId === authority.selection.backendId && + allocations.length === 1 && + allocations.every( + (allocation) => + sameRef(allocation.positionRef, request.positionRef) && + sameRef(allocation.stockItemRef, request.stockItemRef) && + sameRef(allocation.quantity.unitRef, request.quantity.unitRef) && + allocation.quantity.amount === request.quantity.amount, + ); + +const effectLedgerMatches = ( + input: CompileInventoryHistoricalEvidenceInput, + evidence: Extract, + allocations: readonly (typeof InventoryStockAllocationSchema.Type)[], +) => { + const { authority, effectId } = evidence.correlation; + const fullReservationCoverage = allocations.length === allAllocations(input).length; + return ( + String(evidence.value.effectId) === effectId && + Match.value(evidence.value.intent).pipe( + Match.tag( + 'RESERVATION_CREATE', + ({ request }) => + String(request.effectId) === effectId && + fullReservationCoverage && + sameRef(request.reservation.ref, input.reservation.ref) && + request.reservation.origin.attemptId === input.reservation.origin.attemptId && + sameRequirements(request.reservation.requirements, input.reservation.requirements) && + sameConfiguration(request.authority, authority), + ), + Match.tag( + 'RESERVATION_RELEASE', + ({ request }) => + String(request.effectId) === effectId && + fullReservationCoverage && + sameReservation(request.reservation, input.reservation) && + sameConfiguration(authority, input.reservation.authority), + ), + Match.tag( + 'ESTABLISH_COMMITMENT_PROTECTION', + ({ request }) => + String(request.effectId) === effectId && + fullReservationCoverage && + sameReservation(request.confirmation.reservation, input.reservation) && + sameConfiguration(authority, input.reservation.authority), + ), + Match.tag('PHYSICAL_RECEIPT', ({ request }) => physicalRequestMatches(request, effectId, authority, allocations)), + Match.tag('PHYSICAL_ISSUE', ({ request }) => physicalRequestMatches(request, effectId, authority, allocations)), + Match.exhaustive, + ) + ); +}; + +const relatedVariantMatches = ( + input: CompileInventoryHistoricalEvidenceInput, + evidence: InventoryHistoricalRelatedEvidence, + allocations: readonly (typeof InventoryStockAllocationSchema.Type)[], +): boolean => + Match.value(evidence).pipe( + Match.tag( + 'COMMITMENT_PROTECTION', + ({ correlation, value }) => + String(value.authorityEvidence.effectId) === correlation.effectId && + allocations.length === allAllocations(input).length && + sameReservation(value.confirmation.reservation, input.reservation) && + sameConfiguration(correlation.authority, input.reservation.authority) && + sameIssuer(value.authorityEvidence.issuer, value.confirmation.authorityEvidence.issuer), + ), + Match.tag( + 'RESERVATION_RELEASE', + ({ correlation, value }) => + String(value.request.effectId) === correlation.effectId && + allocations.length === allAllocations(input).length && + sameReservation(value.request.reservation, input.reservation) && + sameConfiguration(correlation.authority, input.reservation.authority), + ), + Match.tag( + 'SOURCE_ASSERTION', + ({ correlation, value }) => + String(value.assertionId) === correlation.effectId && + sameConfiguration(value.authorityConfiguration, correlation.authority) && + value.customerConfigurationId === correlation.authority.customerConfigurationId && + correlation.positionRefs.length === 1 && + allocations.every( + (allocation) => + sameRef(allocation.positionRef, value.positionRef) && + sameRef(allocation.stockItemRef, value.stockItemRef) && + sameRef(allocation.quantity.unitRef, value.quantity.unitRef), + ), + ), + Match.tag( + 'STOCK_CORRECTION', + ({ correlation, value }) => + String(value.correctionId) === correlation.effectId && + authorityRefMatches(correlation.authority, value.authorityConfigurationRef) && + value.customerConfigurationId === correlation.authority.customerConfigurationId && + correlation.positionRefs.length === 1 && + allocations.every((allocation) => sameRef(allocation.positionRef, value.positionRef)), + ), + Match.tag( + 'PHYSICAL_STOCK_EFFECT', + ({ correlation, value }) => + String(value.request.effectId) === correlation.effectId && + physicalRequestMatches(value.request, correlation.effectId, correlation.authority, allocations), + ), + Match.tag('EFFECT_LEDGER', (ledger) => effectLedgerMatches(input, ledger, allocations)), + Match.exhaustive, + ); + +const validateRelatedEvidence = ( + input: CompileInventoryHistoricalEvidenceInput, +): InventoryHistoricalEvidenceRejected['reason'] | undefined => { + const authorities = knownAuthorities(input); + for (const evidence of input.relatedEvidence) { + const { correlation } = evidence; + const allocations = correlationAllocations(input, evidence); + if ( + !sameRef(correlation.reservationRef, input.reservation.ref) || + correlation.attemptId !== input.reservation.origin.attemptId || + !authorities.some((authority) => sameConfiguration(authority, correlation.authority)) || + allocations.length !== correlation.allocationIds.length || + new Set(allocations.map(({ positionRef }) => `${positionRef.tenantId}:${positionRef.resourceId}`)).size !== + correlation.positionRefs.length || + !relatedVariantMatches(input, evidence, allocations) + ) { + return 'RELATED_EVIDENCE_SCOPE_MISMATCH'; + } + } + return undefined; +}; + +const validateCommittedLineage = ( + input: CompileInventoryHistoricalEvidenceInput, +): InventoryHistoricalEvidenceRejected['reason'] | undefined => { + for (const lineage of input.committedLineage) { + const valid = Match.value(lineage).pipe( + Match.tag( + 'RUNTIME_COMMITTED', + ({ obligation }) => + sameRef(obligation.ref, input.reservation.ref) && + obligation.origin.attemptId === input.reservation.origin.attemptId && + sameRequirements(obligation.requirements, input.reservation.requirements) && + sameConfiguration(obligation.authority, input.reservation.authority), + ), + Match.tag( + 'IMPORTED_COMMITTED', + ({ obligation }) => + obligation.ref.tenantId === input.reservation.ref.tenantId && + obligation.authority.customerConfigurationId === input.reservation.authority.customerConfigurationId && + obligation.runtimeAttemptId === null && + obligation.origin.kind === 'IMPORTED_PROVEN_ORDER' && + obligation.orderProof.sourceOrderId === obligation.origin.sourceOrderId && + obligation.orderProof.sourceSystem === obligation.origin.sourceSystem, + ), + Match.exhaustive, + ); + if (!valid) { + return 'COMMITTED_LINEAGE_MISMATCH'; + } + } + return undefined; +}; + +interface TerminalResolutionEvidence { + readonly observedAt: typeof auditInstant.Type; + readonly ownerEvidenceRef: string; + readonly state: 'REJECTED' | 'SUCCEEDED'; +} + +const terminalPhysicalEvidence = ( + effect: Extract< + typeof PhysicalStockEffectRecordSchema.Type, + { readonly _tag: 'APPLIED' | 'INDETERMINATE' | 'REJECTED' | 'REQUESTED' } + >, + expectedEffectId: string, +): TerminalResolutionEvidence | null => + Match.value(effect).pipe( + Match.tag('APPLIED', ({ evidence, request }) => + String(request.effectId) === expectedEffectId && String(evidence.effectId) === expectedEffectId + ? { + observedAt: evidence.appliedAt, + ownerEvidenceRef: evidence.backendEvidenceRef, + state: 'SUCCEEDED' as const, + } + : null, + ), + Match.tag('INDETERMINATE', () => null), + Match.tag('REJECTED', () => null), + Match.tag('REQUESTED', () => null), + Match.exhaustive, + ); + +const terminalResolutionEvidence = ( + resolution: typeof InventoryEffectLedgerResolutionSchema.Type, + expectedEffectId: string, +): TerminalResolutionEvidence | null => + Match.value(resolution).pipe( + Match.tag('RESERVATION_CREATE', ({ effect }) => + String(effect.request.effectId) === expectedEffectId + ? Match.value(effect).pipe( + Match.tag('ESTABLISHED', ({ ownerEvidenceRef, reservation }) => ({ + observedAt: reservation.establishedAt, + ownerEvidenceRef, + state: 'SUCCEEDED' as const, + })), + Match.tag('RESOLVED_NO_RESERVATION', ({ preCommitCompensation }) => + preCommitCompensation === undefined + ? null + : { + observedAt: preCommitCompensation.cleanedAt, + ownerEvidenceRef: preCommitCompensation.cleanupEvidenceRef, + state: 'REJECTED' as const, + }, + ), + Match.tag('INDETERMINATE', () => null), + Match.tag('RECONCILIATION_REQUIRED', () => null), + Match.tag('REQUESTED', () => null), + Match.exhaustive, + ) + : null, + ), + Match.tag('RESERVATION_RELEASE', ({ effect }) => + String(effect.request.effectId) === expectedEffectId + ? Match.value(effect).pipe( + Match.tag('RELEASED', ({ ownerEvidenceRef, releasedAt }) => ({ + observedAt: releasedAt, + ownerEvidenceRef, + state: 'SUCCEEDED' as const, + })), + Match.tag('NOT_RELEASABLE', ({ evidenceRef, observedAt }) => ({ + observedAt, + ownerEvidenceRef: evidenceRef, + state: 'REJECTED' as const, + })), + Match.tag('INDETERMINATE', () => null), + Match.tag('REQUESTED', () => null), + Match.exhaustive, + ) + : null, + ), + Match.tag('ESTABLISH_COMMITMENT_PROTECTION', ({ effect }) => + String(effect.request.effectId) === expectedEffectId + ? Match.value(effect).pipe( + Match.tag('PROTECTED', ({ protection }) => ({ + observedAt: protection.establishedAt, + ownerEvidenceRef: protection.authorityEvidence.evidence.ownerEvidenceRef, + state: 'SUCCEEDED' as const, + })), + Match.tag('NOT_PROTECTABLE', () => null), + Match.exhaustive, + ) + : null, + ), + Match.tag('PHYSICAL_RECEIPT', ({ effect }) => terminalPhysicalEvidence(effect, expectedEffectId)), + Match.tag('PHYSICAL_ISSUE', ({ effect }) => terminalPhysicalEvidence(effect, expectedEffectId)), + Match.exhaustive, + ); + +const validateReconciliationLineage = ( + input: CompileInventoryHistoricalEvidenceInput, +): InventoryHistoricalEvidenceRejected['reason'] | undefined => { + const ledgers = input.relatedEvidence.filter( + (evidence): evidence is Extract => + Schema.is(InventoryHistoricalEffectLedgerEvidenceSchema)(evidence), + ); + for (const interval of input.reconciliationIntervals) { + const ledger = ledgers.find(({ value }) => String(value.effectId) === String(interval.effectId)); + const ledgerResolution = ledger?.value.resolution; + const resolution = interval.finalResolution; + const partialEffectsBound = interval.possiblePartialEffectIds.every((effectId) => + ledgers.some( + (candidate) => + String(candidate.value.effectId) === String(effectId) && + candidate.correlation.attemptId === interval.attemptId, + ), + ); + const terminalEvidence = + ledgerResolution === null || ledgerResolution === undefined + ? null + : terminalResolutionEvidence(ledgerResolution, String(interval.effectId)); + if ( + interval.attemptId !== input.reservation.origin.attemptId || + ledger === undefined || + !partialEffectsBound || + DateTime.toEpochMillis(DateTime.makeUnsafe(interval.indeterminateFrom)) < + DateTime.toEpochMillis(DateTime.makeUnsafe(ledger.value.requestedAt)) || + (resolution === null && ledger.value.currentState !== 'INDETERMINATE') || + (resolution !== null && + (ledger.value.currentState !== resolution.state || + ledgerResolution === null || + terminalEvidence === null || + terminalEvidence.state !== resolution.state || + terminalEvidence.ownerEvidenceRef !== resolution.ownerEvidenceRef || + terminalEvidence.observedAt !== resolution.resolvedAt || + DateTime.toEpochMillis(DateTime.makeUnsafe(resolution.resolvedAt)) < + DateTime.toEpochMillis(DateTime.makeUnsafe(interval.indeterminateFrom)))) + ) { + return 'RECONCILIATION_LINEAGE_MISMATCH'; + } + } + return undefined; +}; + +export const compileInventoryHistoricalEvidence = Effect.fn('InventoryHistoricalEvidence.compile')(function* compile( + input: CompileInventoryHistoricalEvidenceInput, +) { + const requirementFailure = validateRequirementEvidence(input); + if (requirementFailure !== undefined) { + return yield* rejected(requirementFailure); + } + const confirmationFailure = validateConfirmationHistory(input); + if (confirmationFailure !== undefined) { + return yield* rejected(confirmationFailure); + } + yield* validateConfirmationTransitions(input); + yield* validateShortageHistory(input); + const relatedEvidenceFailure = validateRelatedEvidence(input); + if (relatedEvidenceFailure !== undefined) { + return yield* rejected(relatedEvidenceFailure); + } + const committedFailure = validateCommittedLineage(input); + if (committedFailure !== undefined) { + return yield* rejected(committedFailure); + } + const reconciliationFailure = validateReconciliationLineage(input); + if (reconciliationFailure !== undefined) { + return yield* rejected(reconciliationFailure); + } + const lineage = validateBackendLineage(input); + if (lineage === undefined) { + return yield* rejected('BACKEND_LINEAGE_MISMATCH'); + } + return yield* Schema.decodeEffect(InventoryHistoricalEvidencePacketSchema)({ + _tag: 'InventoryHistoricalEvidencePacket', + ...input, + authorityRewriteApplied: false, + currentAuthority: lineage, + historicalAllocationSubstitutionApplied: false, + historicalAuthority: input.reservation.authority, + rawProviderPayloadRetained: false, + }).pipe(Effect.mapError((cause) => Object.assign(rejected('INVALID_HISTORICAL_EVIDENCE'), { cause }))); +}); diff --git a/app/verticals/inventory/shared/domain/inventory-authority.ts b/app/verticals/inventory/shared/domain/inventory-authority.ts new file mode 100644 index 000000000..4343c909b --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-authority.ts @@ -0,0 +1,448 @@ +import { Effect, Schema } from 'effect'; + +import type { InventoryBackendConfigurationInput, InventoryLaunchCutlineRejected } from '../inventory-launch-scope.ts'; +import { + InventoryBackendSchema, + OrderCommitmentAttemptIdSchema, + validateLaunchInventoryBackend, +} from '../inventory-launch-scope.ts'; +import { InventoryReservationIdSchema } from '../resources/inventory-reservation.ts'; + +const AuthorityIdentifierSchema = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(300)); +const AcceptedOrderIdSchema = AuthorityIdentifierSchema.pipe(Schema.brand('AcceptedOrderId')); +const CustomerConfigurationIdSchema = AuthorityIdentifierSchema.pipe(Schema.brand('CustomerConfigurationId')); +const InventoryStockPositionIdSchema = AuthorityIdentifierSchema.pipe(Schema.brand('InventoryStockPositionId')); +export type InventoryReservationId = typeof InventoryReservationIdSchema.Type; +export type OrderCommitmentAttemptId = typeof OrderCommitmentAttemptIdSchema.Type; + +const inventoryAuthorityAssignmentBase = { + authorityMode: Schema.Literal('SINGLE_CUSTOMER_CONFIGURATION_BACKEND'), + customerConfigurationId: CustomerConfigurationIdSchema, + cutoverMode: Schema.Literal('EXPLICIT_ONLY'), + fallbackBackend: Schema.Null, +} as const; + +export const InventoryAuthorityAssignmentSchema = Schema.Union([ + Schema.Struct({ + ...inventoryAuthorityAssignmentBase, + ownerAccess: Schema.Literal('DIRECT_EXTERNAL_OWNER_CONTRACT'), + physicalStockSystemOfRecord: Schema.Literal('external_business_system'), + reservationAuthority: Schema.Literal('external_business_system'), + selectedBackend: Schema.Literal('external_business_system'), + }), + Schema.Struct({ + ...inventoryAuthorityAssignmentBase, + ownerAccess: Schema.Literal('ONTOS_WMS_OWNER_CONTRACT'), + physicalStockSystemOfRecord: Schema.Literal('ontos_wms'), + reservationAuthority: Schema.Literal('ontos_wms'), + selectedBackend: Schema.Literal('ontos_wms'), + }), +]); +export type InventoryAuthorityAssignment = typeof InventoryAuthorityAssignmentSchema.Type; + +export const InventoryNonAuthorityBoundarySchema = Schema.Union([ + Schema.Struct({ + participant: Schema.Literal('INTEGRATION_ROUTE'), + role: Schema.Literal('TRANSPORT_ONLY'), + }), + Schema.Struct({ + participant: Schema.Literal('LOCAL_INVENTORY_BOOKKEEPING'), + role: Schema.Literal('EVIDENCE_ONLY'), + }), + Schema.Struct({ + participant: Schema.Literal('AVAILABILITY'), + role: Schema.Literal('READ_OWNER_EVIDENCE_ONLY'), + }), + Schema.Struct({ + participant: Schema.Literal('ORDER'), + role: Schema.Literal('OWNS_ACCEPTED_PURCHASE_ONLY'), + }), + Schema.Struct({ + participant: Schema.Literal('FULFILLMENT'), + role: Schema.Literal('EXECUTION_EVIDENCE_ONLY'), + }), +]); +export type InventoryNonAuthorityBoundary = typeof InventoryNonAuthorityBoundarySchema.Type; + +export const inventoryNonAuthorityBoundaries = [ + { participant: 'INTEGRATION_ROUTE', role: 'TRANSPORT_ONLY' }, + { participant: 'LOCAL_INVENTORY_BOOKKEEPING', role: 'EVIDENCE_ONLY' }, + { participant: 'AVAILABILITY', role: 'READ_OWNER_EVIDENCE_ONLY' }, + { participant: 'ORDER', role: 'OWNS_ACCEPTED_PURCHASE_ONLY' }, + { participant: 'FULFILLMENT', role: 'EXECUTION_EVIDENCE_ONLY' }, +] as const satisfies readonly InventoryNonAuthorityBoundary[]; + +const InventoryReservationAllocationAuthoritySchema = Schema.Struct({ + authorityBackend: InventoryBackendSchema, + stockPositionId: InventoryStockPositionIdSchema, +}); + +export const InventoryReservationAuthorityProposalSchema = Schema.Struct({ + allocations: Schema.Array(InventoryReservationAllocationAuthoritySchema).check(Schema.isMinLength(1)), + attemptId: OrderCommitmentAttemptIdSchema, + authority: InventoryAuthorityAssignmentSchema, + reservationIds: Schema.Array(InventoryReservationIdSchema), +}); +export type InventoryReservationAuthorityProposal = typeof InventoryReservationAuthorityProposalSchema.Type; + +export const InventoryReservationAuthorityDecisionSchema = Schema.Struct({ + allocationCount: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)), + attemptId: OrderCommitmentAttemptIdSchema, + coverage: Schema.Literal('ALL_ATTEMPT_STOCK_REQUIREMENTS'), + reservationAuthority: InventoryBackendSchema, + reservationId: InventoryReservationIdSchema, + reservationIdentityStatus: Schema.Literals(['ESTABLISHED', 'EXACT_RETRY']), +}); +export type InventoryReservationAuthorityDecision = typeof InventoryReservationAuthorityDecisionSchema.Type; + +export const InventoryAttemptReservationIdentityBindingInputSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + proposedReservationId: InventoryReservationIdSchema, +}); +export type InventoryAttemptReservationIdentityBindingInput = + typeof InventoryAttemptReservationIdentityBindingInputSchema.Type; + +export const InventoryAttemptReservationIdentityBindingSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + reservationId: InventoryReservationIdSchema, + status: Schema.Literals(['BOUND_NOW', 'ALREADY_BOUND']), +}); +export type InventoryAttemptReservationIdentityBinding = typeof InventoryAttemptReservationIdentityBindingSchema.Type; + +export interface InventoryAttemptReservationIdentityAuthority { + readonly readOrBind: ( + input: InventoryAttemptReservationIdentityBindingInput, + ) => Effect.Effect; +} + +export const InventoryAuthorityOperationSchema = Schema.Literals([ + 'PHYSICAL_STOCK_FACT', + 'RESERVATION_CREATE', + 'RESERVATION_RELEASE', + 'RESERVATION_CONFIRMATION', + 'COMMITMENT_PROTECTION', +]); + +const InventoryEvidenceIssuerSchema = Schema.Union([ + Schema.Struct({ + backend: InventoryBackendSchema, + kind: Schema.Literal('INVENTORY_BACKEND'), + }), + Schema.Struct({ kind: Schema.Literal('LOCAL_INVENTORY_BOOKKEEPING') }), + Schema.Struct({ kind: Schema.Literal('INTEGRATION_ROUTE') }), +]); + +const InventoryOwnerEvidenceObservationSchema = Schema.Union([ + Schema.Struct({ + issuer: InventoryEvidenceIssuerSchema, + kind: Schema.Literal('CONFIRMED'), + ownerEvidenceRef: AuthorityIdentifierSchema, + verification: Schema.Literal('OWNER_VERIFIED'), + }), + Schema.Struct({ kind: Schema.Literal('UNSUPPORTED') }), + Schema.Struct({ kind: Schema.Literal('UNAVAILABLE') }), + Schema.Struct({ kind: Schema.Literal('CONFLICT') }), + Schema.Struct({ kind: Schema.Literal('INDETERMINATE') }), +]); + +export const InventoryOwnerEvidenceInputSchema = Schema.Struct({ + authority: InventoryAuthorityAssignmentSchema, + observation: InventoryOwnerEvidenceObservationSchema, + operation: InventoryAuthorityOperationSchema, +}); +export type InventoryOwnerEvidenceInput = typeof InventoryOwnerEvidenceInputSchema.Type; + +export const InventoryOwnerEvidenceDecisionSchema = Schema.Struct({ + authorityRole: Schema.Literals(['PHYSICAL_STOCK_SYSTEM_OF_RECORD', 'RESERVATION_AUTHORITY']), + issuerBackend: InventoryBackendSchema, + kind: Schema.Literal('AUTHORITATIVE_OWNER_EVIDENCE'), + operation: InventoryAuthorityOperationSchema, + ownerEvidenceRef: AuthorityIdentifierSchema, +}); +export type InventoryOwnerEvidenceDecision = typeof InventoryOwnerEvidenceDecisionSchema.Type; + +export const InventoryCommitContinuationInputSchema = Schema.Struct({ + acceptedOrderEvidenceRef: AuthorityIdentifierSchema, + acceptedOrderId: AcceptedOrderIdSchema, + attemptId: OrderCommitmentAttemptIdSchema, + currentMeaning: Schema.Literal('PROVISIONAL_RESERVATION'), + reservationObligationId: InventoryReservationIdSchema, +}); +export type InventoryCommitContinuationInput = typeof InventoryCommitContinuationInputSchema.Type; + +export const CommittedInventoryObligationSchema = Schema.Struct({ + acceptedOrderEvidenceRef: AuthorityIdentifierSchema, + acceptedOrderId: AcceptedOrderIdSchema, + attemptId: OrderCommitmentAttemptIdSchema, + fulfillmentRole: Schema.Literal('EXECUTION_EVIDENCE_ONLY'), + lifecycleMeaning: Schema.Literal('COMMITTED_OBLIGATION'), + obligationOwner: Schema.Literal('INVENTORY'), + orderOwnerRole: Schema.Literal('ACCEPTED_PURCHASE'), + reservationObligationId: InventoryReservationIdSchema, +}); +export type CommittedInventoryObligation = typeof CommittedInventoryObligationSchema.Type; + +export const InventoryBackendContinuityInputSchema = Schema.Struct({ + currentAuthority: InventoryAuthorityAssignmentSchema, + requestedBackend: InventoryBackendSchema, +}); +export type InventoryBackendContinuityInput = typeof InventoryBackendContinuityInputSchema.Type; + +export const InventoryBackendContinuityDecisionSchema = Schema.Struct({ + backend: InventoryBackendSchema, + mode: Schema.Literal('UNCHANGED_RUNTIME_AUTHORITY'), +}); +export type InventoryBackendContinuityDecision = typeof InventoryBackendContinuityDecisionSchema.Type; + +export class InventoryAuthorityDecisionRejected extends Schema.TaggedError()( + 'InventoryAuthorityDecisionRejected', + { + attemptId: Schema.optionalKey(OrderCommitmentAttemptIdSchema), + code: Schema.Literal('inventory_authority_decision_rejected'), + customerConfigurationId: Schema.optionalKey(CustomerConfigurationIdSchema), + fallbackApplied: Schema.Literal(false), + outcome: Schema.Literals([ + 'unsupported', + 'unavailable', + 'conflict', + 'indeterminate', + 'invalid_cardinality', + 'authority_mismatch', + 'cutover_required', + ]), + reason: Schema.Literals([ + 'selected_backend_does_not_support_required_guarantee', + 'selected_backend_unavailable', + 'selected_backend_evidence_conflict', + 'selected_backend_evidence_indeterminate', + 'exactly_one_reservation_per_attempt_required', + 'all_allocations_require_selected_backend', + 'attempt_reservation_identity_conflict', + 'backend_change_requires_explicit_cutover', + 'owner_evidence_issuer_mismatch', + ]), + resolution: Schema.Literals([ + 'customer_configuration_change_required', + 'owner_resolution_required', + 'reservation_proposal_correction_required', + 'explicit_cutover_required', + ]), + selectedBackend: InventoryBackendSchema, + }, +) {} + +export const establishInventoryAuthority = ( + input: InventoryBackendConfigurationInput, +): Effect.Effect => + validateLaunchInventoryBackend(input).pipe( + Effect.map(({ backend, customerConfigurationId }) => { + const shared = { + authorityMode: 'SINGLE_CUSTOMER_CONFIGURATION_BACKEND' as const, + customerConfigurationId, + cutoverMode: 'EXPLICIT_ONLY' as const, + fallbackBackend: null, + }; + + return backend === 'external_business_system' + ? { + ...shared, + ownerAccess: 'DIRECT_EXTERNAL_OWNER_CONTRACT' as const, + physicalStockSystemOfRecord: backend, + reservationAuthority: backend, + selectedBackend: backend, + } + : { + ...shared, + ownerAccess: 'ONTOS_WMS_OWNER_CONTRACT' as const, + physicalStockSystemOfRecord: backend, + reservationAuthority: backend, + selectedBackend: backend, + }; + }), + ); + +const validateInventoryReservationProposal = ( + proposal: InventoryReservationAuthorityProposal, +): Effect.Effect< + Omit, + InventoryAuthorityDecisionRejected +> => { + const [reservationId] = proposal.reservationIds; + if (proposal.reservationIds.length !== 1 || reservationId === undefined) { + return Effect.fail( + new InventoryAuthorityDecisionRejected({ + attemptId: proposal.attemptId, + code: 'inventory_authority_decision_rejected', + fallbackApplied: false, + outcome: 'invalid_cardinality', + reason: 'exactly_one_reservation_per_attempt_required', + resolution: 'reservation_proposal_correction_required', + selectedBackend: proposal.authority.selectedBackend, + }), + ); + } + + if (proposal.allocations.some(({ authorityBackend }) => authorityBackend !== proposal.authority.selectedBackend)) { + return Effect.fail( + new InventoryAuthorityDecisionRejected({ + attemptId: proposal.attemptId, + code: 'inventory_authority_decision_rejected', + fallbackApplied: false, + outcome: 'authority_mismatch', + reason: 'all_allocations_require_selected_backend', + resolution: 'reservation_proposal_correction_required', + selectedBackend: proposal.authority.selectedBackend, + }), + ); + } + + return Effect.succeed({ + allocationCount: proposal.allocations.length, + attemptId: proposal.attemptId, + coverage: 'ALL_ATTEMPT_STOCK_REQUIREMENTS', + reservationAuthority: proposal.authority.reservationAuthority, + reservationId, + }); +}; + +export const makeInventoryReservationAuthorityService = ( + identityAuthority: InventoryAttemptReservationIdentityAuthority, +) => ({ + establish: ( + proposal: InventoryReservationAuthorityProposal, + ): Effect.Effect => + validateInventoryReservationProposal(proposal).pipe( + Effect.flatMap((validated) => + identityAuthority + .readOrBind({ + attemptId: validated.attemptId, + proposedReservationId: validated.reservationId, + }) + .pipe( + Effect.flatMap((binding) => { + if (binding.reservationId !== validated.reservationId) { + return Effect.fail( + new InventoryAuthorityDecisionRejected({ + attemptId: validated.attemptId, + code: 'inventory_authority_decision_rejected', + fallbackApplied: false, + outcome: 'conflict', + reason: 'attempt_reservation_identity_conflict', + resolution: 'reservation_proposal_correction_required', + selectedBackend: proposal.authority.selectedBackend, + }), + ); + } + + return Effect.succeed({ + ...validated, + reservationIdentityStatus: + binding.status === 'BOUND_NOW' ? ('ESTABLISHED' as const) : ('EXACT_RETRY' as const), + }); + }), + ), + ), + ), +}); + +export const resolveInventoryOwnerEvidence = ( + input: InventoryOwnerEvidenceInput, +): Effect.Effect => { + if (input.observation.kind === 'CONFIRMED') { + if ( + input.observation.issuer.kind !== 'INVENTORY_BACKEND' || + input.observation.issuer.backend !== input.authority.selectedBackend + ) { + return Effect.fail( + new InventoryAuthorityDecisionRejected({ + code: 'inventory_authority_decision_rejected', + customerConfigurationId: input.authority.customerConfigurationId, + fallbackApplied: false, + outcome: 'conflict', + reason: 'owner_evidence_issuer_mismatch', + resolution: 'owner_resolution_required', + selectedBackend: input.authority.selectedBackend, + }), + ); + } + + return Effect.succeed({ + authorityRole: + input.operation === 'PHYSICAL_STOCK_FACT' ? 'PHYSICAL_STOCK_SYSTEM_OF_RECORD' : 'RESERVATION_AUTHORITY', + issuerBackend: input.observation.issuer.backend, + kind: 'AUTHORITATIVE_OWNER_EVIDENCE', + operation: input.operation, + ownerEvidenceRef: input.observation.ownerEvidenceRef, + }); + } + + const rejection = { + CONFLICT: { + outcome: 'conflict' as const, + reason: 'selected_backend_evidence_conflict' as const, + resolution: 'owner_resolution_required' as const, + }, + INDETERMINATE: { + outcome: 'indeterminate' as const, + reason: 'selected_backend_evidence_indeterminate' as const, + resolution: 'owner_resolution_required' as const, + }, + UNAVAILABLE: { + outcome: 'unavailable' as const, + reason: 'selected_backend_unavailable' as const, + resolution: 'owner_resolution_required' as const, + }, + UNSUPPORTED: { + outcome: 'unsupported' as const, + reason: 'selected_backend_does_not_support_required_guarantee' as const, + resolution: 'customer_configuration_change_required' as const, + }, + }[input.observation.kind]; + + return Effect.fail( + new InventoryAuthorityDecisionRejected({ + code: 'inventory_authority_decision_rejected', + customerConfigurationId: input.authority.customerConfigurationId, + fallbackApplied: false, + ...rejection, + selectedBackend: input.authority.selectedBackend, + }), + ); +}; + +export const continueInventoryObligationAfterCommit = ( + input: InventoryCommitContinuationInput, +): Effect.Effect => + Effect.succeed({ + acceptedOrderEvidenceRef: input.acceptedOrderEvidenceRef, + acceptedOrderId: input.acceptedOrderId, + attemptId: input.attemptId, + fulfillmentRole: 'EXECUTION_EVIDENCE_ONLY', + lifecycleMeaning: 'COMMITTED_OBLIGATION', + obligationOwner: 'INVENTORY', + orderOwnerRole: 'ACCEPTED_PURCHASE', + reservationObligationId: input.reservationObligationId, + }); + +export const requireExplicitBackendCutover = ( + input: InventoryBackendContinuityInput, +): Effect.Effect => { + if (input.requestedBackend === input.currentAuthority.selectedBackend) { + return Effect.succeed({ + backend: input.currentAuthority.selectedBackend, + mode: 'UNCHANGED_RUNTIME_AUTHORITY', + }); + } + + return Effect.fail( + new InventoryAuthorityDecisionRejected({ + code: 'inventory_authority_decision_rejected', + customerConfigurationId: input.currentAuthority.customerConfigurationId, + fallbackApplied: false, + outcome: 'cutover_required', + reason: 'backend_change_requires_explicit_cutover', + resolution: 'explicit_cutover_required', + selectedBackend: input.currentAuthority.selectedBackend, + }), + ); +}; diff --git a/app/verticals/inventory/shared/domain/inventory-backend-configuration-persistence-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-backend-configuration-persistence-unavailable.ts new file mode 100644 index 000000000..e3930e601 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-backend-configuration-persistence-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class InventoryBackendConfigurationPersistenceUnavailable extends Schema.TaggedError()( + 'InventoryBackendConfigurationPersistenceUnavailable', + { + code: Schema.Literal('inventory_backend_configuration_persistence_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-backend-configuration.ts b/app/verticals/inventory/shared/domain/inventory-backend-configuration.ts new file mode 100644 index 000000000..8bc8a9574 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-backend-configuration.ts @@ -0,0 +1,113 @@ +import { Effect, Schema } from 'effect'; + +import { InventoryAuthorityAssignmentSchema, establishInventoryAuthority } from './inventory-authority.ts'; +import { InventoryBackendConfigurationPersistenceUnavailable } from './inventory-backend-configuration-persistence-unavailable.ts'; +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; +import { InventoryBackendSelectionRejected } from './inventory-backend-selection-rejected.ts'; +import { InventoryReservationGuaranteeUnsupported } from './inventory-reservation-guarantee-unsupported.ts'; +import { CustomerConfigurationIdSchema, InventoryBackendSchema } from '../inventory-launch-scope.ts'; +import type { InventoryLaunchCutlineRejected } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; + +const InventoryBackendConfigurationIdSchema = InventoryBackendConfigurationRefSchema.fields.resourceId; +const TenantIdSchema = InventoryBackendConfigurationRefSchema.fields.tenantId; +export const InventoryBackendConfigurationAuthorizationRefSchema = Schema.Struct({ + moduleId: InventoryBackendConfigurationRefSchema.fields.moduleId, + resourceId: InventoryBackendConfigurationIdSchema.check(Schema.isUUID()), + resourceType: InventoryBackendConfigurationRefSchema.fields.resourceType, + tenantId: TenantIdSchema, +}); +const InventoryInstantSchema = Schema.toEncoded(Schema.DateTimeUtcFromString); +const InventoryCapabilitySupportSchema = Schema.Literals(['SUPPORTED', 'UNSUPPORTED']); + +export const InventoryBackendSelectionSchema = Schema.Struct({ + backend: InventoryBackendSchema, + backendId: InventoryBackendIdSchema, + exactReservationCapability: InventoryCapabilitySupportSchema, + stockCorrectionCapability: InventoryCapabilitySupportSchema, +}).check( + Schema.makeFilter((selection) => + selection.backend === 'ontos_wms' && + (selection.exactReservationCapability !== 'SUPPORTED' || selection.stockCorrectionCapability !== 'SUPPORTED') + ? 'OntOS WMS always exposes the required exact Reservation and Stock Correction capabilities' + : undefined, + ), +); +export type InventoryBackendSelection = typeof InventoryBackendSelectionSchema.Type; + +export const SelectInventoryBackendPayloadSchema = Schema.Struct({ + authorizationTargetRef: InventoryBackendConfigurationAuthorizationRefSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + selection: InventoryBackendSelectionSchema, +}); +export type SelectInventoryBackendPayload = typeof SelectInventoryBackendPayloadSchema.Type; + +export const InventoryBackendConfigurationSchema = Schema.Struct({ + configurationId: InventoryBackendConfigurationIdSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + revision: Schema.Literal(1), + selectedAt: InventoryInstantSchema, + selection: InventoryBackendSelectionSchema, + tenantId: TenantIdSchema, +}); +export type InventoryBackendConfiguration = typeof InventoryBackendConfigurationSchema.Type; + +export const SelectInventoryBackendResultSchema = Schema.Union([ + Schema.Struct({ + configuration: InventoryBackendConfigurationSchema, + outcome: Schema.Literals(['SELECTED', 'EXACT_REPLAY']), + }), + Schema.Struct({ + configuration: InventoryBackendConfigurationSchema, + conflictRef: InventorySourceConflictRefSchema, + fallbackApplied: Schema.Literal(false), + outcome: Schema.Literal('BACKEND_CONFIGURATION_CONFLICT'), + }), +]); +export type SelectInventoryBackendResult = typeof SelectInventoryBackendResultSchema.Type; + +export const SelectInventoryBackendErrorSchema = Schema.Union([ + InventoryBackendSelectionRejected, + InventoryBackendConfigurationPersistenceUnavailable, +]); +export type SelectInventoryBackendError = typeof SelectInventoryBackendErrorSchema.Type; + +export const InventoryReservationAuthorityDispatchSchema = Schema.Struct({ + authority: InventoryAuthorityAssignmentSchema, + backendId: InventoryBackendIdSchema, +}); +export type InventoryReservationAuthorityDispatch = typeof InventoryReservationAuthorityDispatchSchema.Type; + +export const sameInventoryBackendSelection = ( + left: InventoryBackendSelection, + right: InventoryBackendSelection, +): boolean => + left.backendId === right.backendId && + left.backend === right.backend && + left.exactReservationCapability === right.exactReservationCapability && + left.stockCorrectionCapability === right.stockCorrectionCapability; + +export const dispatchReservationAuthority = ( + configuration: InventoryBackendConfiguration, +): Effect.Effect< + InventoryReservationAuthorityDispatch, + InventoryLaunchCutlineRejected | InventoryReservationGuaranteeUnsupported +> => { + const { selection } = configuration; + if (selection.exactReservationCapability === 'UNSUPPORTED') { + return Effect.fail( + new InventoryReservationGuaranteeUnsupported({ + code: 'inventory_reservation_guarantee_unsupported', + fallbackApplied: false, + proofIssued: false, + reason: 'selected_backend_does_not_support_required_guarantee', + selectedBackendId: selection.backendId, + }), + ); + } + return establishInventoryAuthority({ + customerConfigurationId: configuration.customerConfigurationId, + selectedBackends: [selection.backend], + }).pipe(Effect.map((authority) => ({ authority, backendId: selection.backendId }))); +}; diff --git a/app/verticals/inventory/shared/domain/inventory-backend-cutover.ts b/app/verticals/inventory/shared/domain/inventory-backend-cutover.ts new file mode 100644 index 000000000..7cbaf6fea --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-backend-cutover.ts @@ -0,0 +1,571 @@ +import { DateTime, Match, Result, Schema } from 'effect'; + +import { + InventoryBackendConfigurationSchema, + sameInventoryBackendSelection, +} from './inventory-backend-configuration.ts'; +import { + InventoryOpeningEvaluationInputSchema, + InventoryOpeningPacketSchema, + InventoryOpeningReadinessBlockerSchema, + InventoryOpeningReadySchema, + evaluateInventoryOpeningPacket, +} from './inventory-opening-stock-and-open-obligations.ts'; +import { + InventoryEffectLedgerKindSchema, + InventoryEffectLedgerRecordSchema, + ReservationCreateInventoryEffectLedgerIntentSchema, +} from './inventory-effect-ledger.ts'; +import { EstablishedReservationCreateEffectSchema } from './inventory-reservation-create.ts'; +import { ProvisionalInventoryReservationSchema } from './inventory-obligation.ts'; + +const cutoverInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const RetainSelectedInventoryBackendInputSchema = Schema.TaggedStruct('RETAIN_SELECTED_BACKEND', { + currentConfiguration: InventoryBackendConfigurationSchema, + evaluatedAt: cutoverInstant, +}); + +export const ReplaceSelectedInventoryBackendInputSchema = Schema.TaggedStruct('REPLACE_SELECTED_BACKEND', { + effectiveBoundary: cutoverInstant, + evaluatedAt: cutoverInstant, + openingFacts: InventoryOpeningEvaluationInputSchema, + postCutoverConfiguration: InventoryBackendConfigurationSchema, + preCutoverConfiguration: InventoryBackendConfigurationSchema, + rollbackPolicy: Schema.Literal('PRESERVE_PROVEN_COMMITTED_FACTS'), + scope: Schema.Literal('WHOLE_CUSTOMER_CONFIGURATION'), +}); + +export const InventoryBackendCutoverInputSchema = Schema.Union([ + RetainSelectedInventoryBackendInputSchema, + ReplaceSelectedInventoryBackendInputSchema, +]); +export type InventoryBackendCutoverInput = typeof InventoryBackendCutoverInputSchema.Type; + +export const InventoryBackendRetainedSchema = Schema.TaggedStruct('NO_REPLACEMENT_REQUIRED', { + evaluatedAt: cutoverInstant, + migrationRequired: Schema.Literal(false), + runtimeAuthorityMode: Schema.Literal('SINGLE_SELECTED_BACKEND'), + selectedConfiguration: InventoryBackendConfigurationSchema, +}); + +export const InventoryBackendCutoverScopeMismatchSchema = Schema.TaggedStruct('CUTOVER_SCOPE_MISMATCH', {}); +export const InventoryBackendCutoverBackendUnchangedSchema = Schema.TaggedStruct('BACKEND_UNCHANGED', {}); +export const InventoryBackendCutoverConfigurationIdentityReusedSchema = Schema.TaggedStruct( + 'CONFIGURATION_IDENTITY_REUSED', + {}, +); +export const InventoryBackendCutoverAuthorityBoundaryMismatchSchema = Schema.TaggedStruct( + 'AUTHORITY_BOUNDARY_MISMATCH', + { + reason: Schema.Literals(['PRE_CUTOVER_AUTHORITY_NOT_BEFORE_BOUNDARY', 'POST_CUTOVER_AUTHORITY_NOT_AT_BOUNDARY']), + }, +); +export const InventoryBackendCutoverOpeningConfigurationMismatchSchema = Schema.TaggedStruct( + 'OPENING_CONFIGURATION_MISMATCH', + {}, +); +export const InventoryBackendCutoverOpeningNotReadySchema = Schema.TaggedStruct('OPENING_NOT_READY', { + openingBlockers: Schema.NonEmptyArray(InventoryOpeningReadinessBlockerSchema), +}); +export const InventoryBackendCutoverProvisionalReservationSchema = Schema.TaggedStruct( + 'PROVISIONAL_RESERVATION_REMAINS', + { reservationRef: ProvisionalInventoryReservationSchema.fields.ref }, +); +export const InventoryBackendCutoverUnresolvedEffectSchema = Schema.TaggedStruct('UNRESOLVED_PRE_CUTOVER_EFFECT', { + effectId: InventoryEffectLedgerRecordSchema.fields.effectId, + kind: InventoryEffectLedgerKindSchema, + state: Schema.Literals(['REQUESTED', 'INDETERMINATE']), +}); +export const InventoryBackendCutoverMissingObligationSchema = Schema.TaggedStruct( + 'SUCCESSFUL_CREATE_OBLIGATION_MISSING', + { + effectId: InventoryEffectLedgerRecordSchema.fields.effectId, + reservationRef: ProvisionalInventoryReservationSchema.fields.ref, + }, +); + +export const InventoryBackendCutoverBlockerSchema = Schema.Union([ + InventoryBackendCutoverScopeMismatchSchema, + InventoryBackendCutoverBackendUnchangedSchema, + InventoryBackendCutoverConfigurationIdentityReusedSchema, + InventoryBackendCutoverAuthorityBoundaryMismatchSchema, + InventoryBackendCutoverOpeningConfigurationMismatchSchema, + InventoryBackendCutoverOpeningNotReadySchema, + InventoryBackendCutoverProvisionalReservationSchema, + InventoryBackendCutoverUnresolvedEffectSchema, + InventoryBackendCutoverMissingObligationSchema, +]); +export type InventoryBackendCutoverBlocker = typeof InventoryBackendCutoverBlockerSchema.Type; + +export const InventoryBackendCutoverBlockedSchema = Schema.TaggedStruct('BLOCKED', { + blockers: Schema.NonEmptyArray(InventoryBackendCutoverBlockerSchema), + evaluatedAt: cutoverInstant, + reconciliationRequired: Schema.Literal(true), + scope: Schema.Literal('WHOLE_CUSTOMER_CONFIGURATION'), +}); + +export const InventoryBackendAuthorityTransitionSchema = Schema.Struct({ + customerConfigurationId: InventoryBackendConfigurationSchema.fields.customerConfigurationId, + cutoverPurpose: Schema.Literal('PLANNED_BACKEND_REPLACEMENT_NOT_OUTAGE_RECOVERY'), + effectiveBoundary: cutoverInstant, + latePreCutoverEvidencePolicy: Schema.Literal('HISTORICAL_OR_RECONCILIATION_ONLY'), + migrationToolingAuthority: Schema.Literal('NONE'), + openingPacket: InventoryOpeningPacketSchema, + postCutoverAuthorityStartsAt: cutoverInstant, + postCutoverConfiguration: InventoryBackendConfigurationSchema, + preCutoverAuthorityValidBefore: cutoverInstant, + preCutoverConfiguration: InventoryBackendConfigurationSchema, + rollbackPolicy: Schema.Literal('PRESERVE_PROVEN_COMMITTED_FACTS'), + runtimeAuthorityMode: Schema.Literal('SINGLE_SELECTED_BACKEND'), + scope: Schema.Literal('WHOLE_CUSTOMER_CONFIGURATION'), + unresolvedEffectPolicy: Schema.Literal('BLOCK_SWITCH_AND_NEVER_REPEAT_AS_FRESH_EFFECT'), +}); + +const InventoryBackendCutoverConfigurationFenceSchema = Schema.Struct({ + configurationId: InventoryBackendConfigurationSchema.fields.configurationId, + customerConfigurationId: InventoryBackendConfigurationSchema.fields.customerConfigurationId, + revision: InventoryBackendConfigurationSchema.fields.revision, + tenantId: InventoryBackendConfigurationSchema.fields.tenantId, +}); + +export const InventoryBackendCutoverReadinessFenceSchema = Schema.TaggedStruct('CUTOVER_READINESS_FENCE', { + effectiveBoundary: cutoverInstant, + effectLedgerStateIdentity: Schema.String, + identity: Schema.String, + obligationSetIdentity: Schema.String, + openingPacketIdentity: Schema.String, + ownerFactsIdentity: Schema.String, + postCutoverConfiguration: InventoryBackendCutoverConfigurationFenceSchema, + preCutoverConfiguration: InventoryBackendCutoverConfigurationFenceSchema, +}); +export type InventoryBackendCutoverReadinessFence = typeof InventoryBackendCutoverReadinessFenceSchema.Type; + +export const InventoryBackendCutoverReadySchema = Schema.TaggedStruct('READY', { + authorityStatus: Schema.Literal('PRE_CUTOVER_BACKEND_REMAINS_AUTHORITATIVE'), + evaluatedAt: cutoverInstant, + readinessFence: InventoryBackendCutoverReadinessFenceSchema, + transitionCandidate: InventoryBackendAuthorityTransitionSchema, +}); + +export const InventoryBackendCutoverReadinessResultSchema = Schema.Union([ + InventoryBackendCutoverBlockedSchema, + InventoryBackendCutoverReadySchema, +]); +export type InventoryBackendCutoverReadinessResult = typeof InventoryBackendCutoverReadinessResultSchema.Type; + +export const InventoryBackendCutoverAuthorizationTimeMismatchSchema = Schema.TaggedStruct( + 'BOUNDARY_AUTHORIZATION_TIME_MISMATCH', + { + effectiveBoundary: cutoverInstant, + reason: Schema.Literals([ + 'BEFORE_EFFECTIVE_BOUNDARY', + 'AFTER_EFFECTIVE_BOUNDARY', + 'CURRENT_FACTS_NOT_EVALUATED_AT_BOUNDARY', + ]), + }, +); +export const InventoryBackendCutoverStaleReadinessFenceSchema = Schema.TaggedStruct('STALE_READINESS_FENCE', { + currentReadinessIdentity: Schema.String, + expectedReadinessIdentity: Schema.String, +}); +export const InventoryBackendCutoverAuthorizationBlockerSchema = Schema.Union([ + InventoryBackendCutoverBlockerSchema, + InventoryBackendCutoverAuthorizationTimeMismatchSchema, + InventoryBackendCutoverStaleReadinessFenceSchema, +]); +export type InventoryBackendCutoverAuthorizationBlocker = typeof InventoryBackendCutoverAuthorizationBlockerSchema.Type; + +export const AuthorizeInventoryBackendCutoverInputSchema = Schema.Struct({ + authorizedAt: cutoverInstant, + currentFacts: ReplaceSelectedInventoryBackendInputSchema, + readiness: InventoryBackendCutoverReadySchema, +}); +export type AuthorizeInventoryBackendCutoverInput = typeof AuthorizeInventoryBackendCutoverInputSchema.Type; + +export const InventoryBackendCutoverAuthorizationBlockedSchema = Schema.TaggedStruct('AUTHORIZATION_BLOCKED', { + authorityStatus: Schema.Literal('PRE_CUTOVER_BACKEND_REMAINS_AUTHORITATIVE'), + authorizedAt: cutoverInstant, + blockers: Schema.NonEmptyArray(InventoryBackendCutoverAuthorizationBlockerSchema), +}); + +export const InventoryBackendCutoverAuthorizedSchema = Schema.TaggedStruct('AUTHORIZED', { + authorityStatus: Schema.Literal('POST_CUTOVER_BACKEND_AUTHORITATIVE'), + authorizedAt: cutoverInstant, + readinessFence: InventoryBackendCutoverReadinessFenceSchema, + transition: InventoryBackendAuthorityTransitionSchema, +}); + +export const InventoryBackendCutoverAuthorizationResultSchema = Schema.Union([ + InventoryBackendCutoverAuthorizationBlockedSchema, + InventoryBackendCutoverAuthorizedSchema, +]); +export type InventoryBackendCutoverAuthorizationResult = typeof InventoryBackendCutoverAuthorizationResultSchema.Type; + +export const InventoryBackendCutoverResultSchema = Schema.Union([ + InventoryBackendRetainedSchema, + InventoryBackendCutoverBlockedSchema, + InventoryBackendCutoverReadySchema, +]); +export type InventoryBackendCutoverResult = typeof InventoryBackendCutoverResultSchema.Type; + +const epoch = (instant: string): number => DateTime.toEpochMillis(DateTime.makeUnsafe(instant)); + +const InventoryBackendCutoverOpeningPacketFenceEvidenceSchema = Schema.Struct({ + obligations: InventoryOpeningPacketSchema.fields.obligations, + selectedConfiguration: InventoryOpeningPacketSchema.fields.selectedConfiguration, + stock: InventoryOpeningPacketSchema.fields.stock, +}); +const InventoryBackendCutoverOwnerFactsFenceEvidenceSchema = Schema.Struct({ + bindings: InventoryOpeningEvaluationInputSchema.fields.bindings, + effectLedger: InventoryOpeningEvaluationInputSchema.fields.effectLedger, + legacyUncommittedHolds: InventoryOpeningEvaluationInputSchema.fields.legacyUncommittedHolds, + obligations: InventoryOpeningEvaluationInputSchema.fields.obligations, + selectedConfiguration: InventoryOpeningEvaluationInputSchema.fields.selectedConfiguration, + stockItems: InventoryOpeningEvaluationInputSchema.fields.stockItems, + stockPositions: InventoryOpeningEvaluationInputSchema.fields.stockPositions, +}); +const InventoryBackendCutoverReadinessIdentityEvidenceSchema = Schema.Struct({ + effectiveBoundary: cutoverInstant, + effectLedgerStateIdentity: Schema.String, + obligationSetIdentity: Schema.String, + openingPacketIdentity: Schema.String, + ownerFactsIdentity: Schema.String, + postCutoverConfiguration: InventoryBackendConfigurationSchema, + preCutoverConfiguration: InventoryBackendConfigurationSchema, +}); +const canonicalEffectLedgerFenceSchema = Schema.fromJsonString( + InventoryOpeningEvaluationInputSchema.fields.effectLedger, +); +const canonicalObligationSetFenceSchema = Schema.fromJsonString( + InventoryOpeningEvaluationInputSchema.fields.obligations, +); +const canonicalOpeningPacketFenceSchema = Schema.fromJsonString( + InventoryBackendCutoverOpeningPacketFenceEvidenceSchema, +); +const canonicalOwnerFactsFenceSchema = Schema.fromJsonString(InventoryBackendCutoverOwnerFactsFenceEvidenceSchema); +const canonicalReadinessIdentitySchema = Schema.fromJsonString(InventoryBackendCutoverReadinessIdentityEvidenceSchema); + +const configurationFence = ({ + configurationId, + customerConfigurationId, + revision, + tenantId, +}: typeof InventoryBackendConfigurationSchema.Type) => ({ + configurationId, + customerConfigurationId, + revision, + tenantId, +}); + +const sameConfiguration = ( + left: typeof InventoryBackendConfigurationSchema.Type, + right: typeof InventoryBackendConfigurationSchema.Type, +): boolean => + left.configurationId === right.configurationId && + left.customerConfigurationId === right.customerConfigurationId && + left.revision === right.revision && + epoch(left.selectedAt) === epoch(right.selectedAt) && + left.tenantId === right.tenantId && + sameInventoryBackendSelection(left.selection, right.selection); + +const effectCustomerConfigurationId = (record: typeof InventoryEffectLedgerRecordSchema.Type): string => + Match.value(record.intent).pipe( + Match.tag('RESERVATION_CREATE', ({ request }) => request.authority.customerConfigurationId), + Match.tag('RESERVATION_RELEASE', ({ request }) => request.reservation.authority.customerConfigurationId), + Match.tag( + 'ESTABLISH_COMMITMENT_PROTECTION', + ({ request }) => request.confirmation.reservation.authority.customerConfigurationId, + ), + Match.tag('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', ({ request }) => request.customerConfigurationId), + Match.exhaustive, + ); + +const reservationRefEquals = ( + left: { readonly resourceId: string; readonly tenantId: string }, + right: { readonly resourceId: string; readonly tenantId: string }, +) => left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +const successfulCreateReservationRef = (record: typeof InventoryEffectLedgerRecordSchema.Type) => { + if ( + record.currentState !== 'SUCCEEDED' || + !Schema.is(ReservationCreateInventoryEffectLedgerIntentSchema)(record.intent) || + record.resolution === null + ) { + return null; + } + return Match.value(record.resolution).pipe( + Match.tag('RESERVATION_CREATE', ({ effect }) => + Schema.is(EstablishedReservationCreateEffectSchema)(effect) ? effect.reservation.ref : null, + ), + Match.orElse(() => null), + ); +}; + +const makeReadinessFence = ( + input: typeof ReplaceSelectedInventoryBackendInputSchema.Type, + openingPacket: typeof InventoryOpeningPacketSchema.Type, +): InventoryBackendCutoverReadinessFence => { + const effectLedger = input.openingFacts.effectLedger.toSorted((left, right) => + left.effectId.localeCompare(right.effectId), + ); + const obligations = input.openingFacts.obligations.toSorted((left, right) => + left.ref.resourceId.localeCompare(right.ref.resourceId), + ); + const effectLedgerStateIdentity = Result.getOrThrow( + Schema.encodeResult(canonicalEffectLedgerFenceSchema)(effectLedger), + ); + const obligationSetIdentity = Result.getOrThrow(Schema.encodeResult(canonicalObligationSetFenceSchema)(obligations)); + const openingPacketIdentity = Result.getOrThrow( + Schema.encodeResult(canonicalOpeningPacketFenceSchema)({ + obligations: openingPacket.obligations.toSorted((left, right) => + left.ref.resourceId.localeCompare(right.ref.resourceId), + ), + selectedConfiguration: openingPacket.selectedConfiguration, + stock: openingPacket.stock.toSorted((left, right) => + left.position.ref.resourceId.localeCompare(right.position.ref.resourceId), + ), + }), + ); + const ownerFactsIdentity = Result.getOrThrow( + Schema.encodeResult(canonicalOwnerFactsFenceSchema)({ + bindings: input.openingFacts.bindings.toSorted((left, right) => + left.bindingRef.resourceId.localeCompare(right.bindingRef.resourceId), + ), + effectLedger, + legacyUncommittedHolds: input.openingFacts.legacyUncommittedHolds.toSorted((left, right) => + left.holdReference.localeCompare(right.holdReference), + ), + obligations, + selectedConfiguration: input.openingFacts.selectedConfiguration, + stockItems: input.openingFacts.stockItems.toSorted((left, right) => + left.stockItemRef.resourceId.localeCompare(right.stockItemRef.resourceId), + ), + stockPositions: input.openingFacts.stockPositions.toSorted((left, right) => + left.position.ref.resourceId.localeCompare(right.position.ref.resourceId), + ), + }), + ); + const postCutoverConfiguration = configurationFence(input.postCutoverConfiguration); + const preCutoverConfiguration = configurationFence(input.preCutoverConfiguration); + const identity = Result.getOrThrow( + Schema.encodeResult(canonicalReadinessIdentitySchema)({ + effectiveBoundary: input.effectiveBoundary, + effectLedgerStateIdentity, + obligationSetIdentity, + openingPacketIdentity, + ownerFactsIdentity, + postCutoverConfiguration: input.postCutoverConfiguration, + preCutoverConfiguration: input.preCutoverConfiguration, + }), + ); + + return { + _tag: 'CUTOVER_READINESS_FENCE', + effectiveBoundary: input.effectiveBoundary, + effectLedgerStateIdentity, + identity, + obligationSetIdentity, + openingPacketIdentity, + ownerFactsIdentity, + postCutoverConfiguration, + preCutoverConfiguration, + }; +}; + +const evaluateReplacement = ( + input: typeof ReplaceSelectedInventoryBackendInputSchema.Type, +): InventoryBackendCutoverReadinessResult => { + const blockers: InventoryBackendCutoverBlocker[] = []; + const { postCutoverConfiguration: post, preCutoverConfiguration: pre } = input; + + if (pre.tenantId !== post.tenantId || pre.customerConfigurationId !== post.customerConfigurationId) { + blockers.push({ _tag: 'CUTOVER_SCOPE_MISMATCH' }); + } + if (sameInventoryBackendSelection(pre.selection, post.selection)) { + blockers.push({ _tag: 'BACKEND_UNCHANGED' }); + } + if (pre.configurationId === post.configurationId) { + blockers.push({ _tag: 'CONFIGURATION_IDENTITY_REUSED' }); + } + if (epoch(pre.selectedAt) >= epoch(input.effectiveBoundary)) { + blockers.push({ _tag: 'AUTHORITY_BOUNDARY_MISMATCH', reason: 'PRE_CUTOVER_AUTHORITY_NOT_BEFORE_BOUNDARY' }); + } + if (epoch(post.selectedAt) !== epoch(input.effectiveBoundary)) { + blockers.push({ _tag: 'AUTHORITY_BOUNDARY_MISMATCH', reason: 'POST_CUTOVER_AUTHORITY_NOT_AT_BOUNDARY' }); + } + if ( + !sameConfiguration(input.openingFacts.selectedConfiguration, post) || + epoch(input.openingFacts.evaluatedAt) !== epoch(input.evaluatedAt) + ) { + blockers.push({ _tag: 'OPENING_CONFIGURATION_MISMATCH' }); + } + + const opening = evaluateInventoryOpeningPacket(input.openingFacts); + if (!Schema.is(InventoryOpeningReadySchema)(opening)) { + blockers.push({ _tag: 'OPENING_NOT_READY', openingBlockers: opening.blockers }); + } + + const scopedObligations = input.openingFacts.obligations.filter( + (obligation) => + String(obligation.ref.tenantId) === String(pre.tenantId) && + obligation.authority.customerConfigurationId === pre.customerConfigurationId, + ); + for (const obligation of scopedObligations) { + if (Schema.is(ProvisionalInventoryReservationSchema)(obligation)) { + blockers.push({ _tag: 'PROVISIONAL_RESERVATION_REMAINS', reservationRef: obligation.ref }); + } + } + + const scopedEffects = input.openingFacts.effectLedger.filter( + (record) => + record.tenantId === pre.tenantId && effectCustomerConfigurationId(record) === pre.customerConfigurationId, + ); + for (const record of scopedEffects) { + if (record.currentState === 'REQUESTED' || record.currentState === 'INDETERMINATE') { + blockers.push({ + _tag: 'UNRESOLVED_PRE_CUTOVER_EFFECT', + effectId: record.effectId, + kind: record.intent._tag, + state: record.currentState, + }); + continue; + } + const successfulReservationRef = successfulCreateReservationRef(record); + if ( + successfulReservationRef !== null && + !scopedObligations.some(({ ref }) => reservationRefEquals(ref, successfulReservationRef)) + ) { + blockers.push({ + _tag: 'SUCCESSFUL_CREATE_OBLIGATION_MISSING', + effectId: record.effectId, + reservationRef: successfulReservationRef, + }); + } + } + + const [firstBlocker, ...remainingBlockers] = blockers; + if (firstBlocker !== undefined) { + return { + _tag: 'BLOCKED', + blockers: [firstBlocker, ...remainingBlockers], + evaluatedAt: input.evaluatedAt, + reconciliationRequired: true, + scope: 'WHOLE_CUSTOMER_CONFIGURATION', + }; + } + if (!Schema.is(InventoryOpeningReadySchema)(opening)) { + return { + _tag: 'BLOCKED', + blockers: [{ _tag: 'OPENING_NOT_READY', openingBlockers: opening.blockers }], + evaluatedAt: input.evaluatedAt, + reconciliationRequired: true, + scope: 'WHOLE_CUSTOMER_CONFIGURATION', + }; + } + return { + _tag: 'READY', + authorityStatus: 'PRE_CUTOVER_BACKEND_REMAINS_AUTHORITATIVE', + evaluatedAt: input.evaluatedAt, + readinessFence: makeReadinessFence(input, opening.packet), + transitionCandidate: { + customerConfigurationId: post.customerConfigurationId, + cutoverPurpose: 'PLANNED_BACKEND_REPLACEMENT_NOT_OUTAGE_RECOVERY', + effectiveBoundary: input.effectiveBoundary, + latePreCutoverEvidencePolicy: 'HISTORICAL_OR_RECONCILIATION_ONLY', + migrationToolingAuthority: 'NONE', + openingPacket: opening.packet, + postCutoverAuthorityStartsAt: input.effectiveBoundary, + postCutoverConfiguration: post, + preCutoverAuthorityValidBefore: input.effectiveBoundary, + preCutoverConfiguration: pre, + rollbackPolicy: input.rollbackPolicy, + runtimeAuthorityMode: 'SINGLE_SELECTED_BACKEND', + scope: input.scope, + unresolvedEffectPolicy: 'BLOCK_SWITCH_AND_NEVER_REPEAT_AS_FRESH_EFFECT', + }, + }; +}; + +/** + * Evaluates the Inventory-owned safety contract only. It neither performs provider migration nor + * changes authority; the returned transition can be consumed by the later cutover operation. + */ +export const evaluateInventoryBackendCutover = (input: InventoryBackendCutoverInput): InventoryBackendCutoverResult => + Match.value(input).pipe( + Match.tag('RETAIN_SELECTED_BACKEND', ({ currentConfiguration, evaluatedAt }) => ({ + _tag: 'NO_REPLACEMENT_REQUIRED' as const, + evaluatedAt, + migrationRequired: false as const, + runtimeAuthorityMode: 'SINGLE_SELECTED_BACKEND' as const, + selectedConfiguration: currentConfiguration, + })), + Match.tag('REPLACE_SELECTED_BACKEND', evaluateReplacement), + Match.exhaustive, + ); + +/** Assesses cutover readiness without changing or authorizing runtime authority. */ +export const assessInventoryBackendCutoverReadiness = ( + input: typeof ReplaceSelectedInventoryBackendInputSchema.Type, +): InventoryBackendCutoverReadinessResult => evaluateReplacement(input); + +const authorizationBlocked = ( + input: AuthorizeInventoryBackendCutoverInput, + blockers: readonly [InventoryBackendCutoverAuthorizationBlocker, ...InventoryBackendCutoverAuthorizationBlocker[]], +): InventoryBackendCutoverAuthorizationResult => ({ + _tag: 'AUTHORIZATION_BLOCKED', + authorityStatus: 'PRE_CUTOVER_BACKEND_REMAINS_AUTHORITATIVE', + authorizedAt: input.authorizedAt, + blockers, +}); + +/** Revalidates fresh owner facts at the exact boundary before authorizing the authority transition. */ +export const authorizeInventoryBackendCutover = ( + input: AuthorizeInventoryBackendCutoverInput, +): InventoryBackendCutoverAuthorizationResult => { + const authorizationEpoch = epoch(input.authorizedAt); + const boundaryEpoch = epoch(input.readiness.transitionCandidate.effectiveBoundary); + if (authorizationEpoch !== boundaryEpoch) { + return authorizationBlocked(input, [ + { + _tag: 'BOUNDARY_AUTHORIZATION_TIME_MISMATCH', + effectiveBoundary: input.readiness.transitionCandidate.effectiveBoundary, + reason: authorizationEpoch < boundaryEpoch ? 'BEFORE_EFFECTIVE_BOUNDARY' : 'AFTER_EFFECTIVE_BOUNDARY', + }, + ]); + } + if ( + epoch(input.currentFacts.evaluatedAt) !== boundaryEpoch || + epoch(input.currentFacts.openingFacts.evaluatedAt) !== boundaryEpoch + ) { + return authorizationBlocked(input, [ + { + _tag: 'BOUNDARY_AUTHORIZATION_TIME_MISMATCH', + effectiveBoundary: input.readiness.transitionCandidate.effectiveBoundary, + reason: 'CURRENT_FACTS_NOT_EVALUATED_AT_BOUNDARY', + }, + ]); + } + + const currentReadiness = assessInventoryBackendCutoverReadiness(input.currentFacts); + if (Schema.is(InventoryBackendCutoverBlockedSchema)(currentReadiness)) { + return authorizationBlocked(input, currentReadiness.blockers); + } + if (currentReadiness.readinessFence.identity !== input.readiness.readinessFence.identity) { + return authorizationBlocked(input, [ + { + _tag: 'STALE_READINESS_FENCE', + currentReadinessIdentity: currentReadiness.readinessFence.identity, + expectedReadinessIdentity: input.readiness.readinessFence.identity, + }, + ]); + } + + return { + _tag: 'AUTHORIZED', + authorityStatus: 'POST_CUTOVER_BACKEND_AUTHORITATIVE', + authorizedAt: input.authorizedAt, + readinessFence: currentReadiness.readinessFence, + transition: currentReadiness.transitionCandidate, + }; +}; diff --git a/app/verticals/inventory/shared/domain/inventory-backend-identifiers.ts b/app/verticals/inventory/shared/domain/inventory-backend-identifiers.ts new file mode 100644 index 000000000..7576b5ac7 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-backend-identifiers.ts @@ -0,0 +1,5 @@ +import { Schema } from 'effect'; + +const BoundedIdentifierSchema = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(300)); + +export const InventoryBackendIdSchema = BoundedIdentifierSchema.pipe(Schema.brand('InventoryBackendId')); diff --git a/app/verticals/inventory/shared/domain/inventory-backend-selection-rejected.ts b/app/verticals/inventory/shared/domain/inventory-backend-selection-rejected.ts new file mode 100644 index 000000000..409cd4778 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-backend-selection-rejected.ts @@ -0,0 +1,17 @@ +import { Schema } from 'effect'; + +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; + +export class InventoryBackendSelectionRejected extends Schema.TaggedError()( + 'InventoryBackendSelectionRejected', + { + code: Schema.Literal('inventory_backend_selection_rejected'), + conflictRef: Schema.optional(InventorySourceConflictRefSchema), + customerConfigurationId: CustomerConfigurationIdSchema, + fallbackApplied: Schema.Literal(false), + reason: Schema.Literals(['authorization_target_mismatch', 'backend_change_requires_explicit_cutover']), + selectedBackendId: InventoryBackendIdSchema, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-domain-event-handoff.ts b/app/verticals/inventory/shared/domain/inventory-domain-event-handoff.ts new file mode 100644 index 000000000..93c70272b --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-domain-event-handoff.ts @@ -0,0 +1,218 @@ +import { Schema } from 'effect'; + +const INVENTORY_MODULE_KEY = 'commerce.inventory'; +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const checkedModuleKey = Schema.String.check( + Schema.isTrimmed(), + Schema.isPattern(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/u), + Schema.isMaxLength(200), +); +const moduleKey = checkedModuleKey.pipe( + Schema.brand('InventoryDomainEventModuleKey'), + Schema.decodeTo(checkedModuleKey), +); +const inventoryEventType = Schema.String.check( + Schema.isTrimmed(), + Schema.isPattern(/^commerce\.inventory\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*\.v[1-9][0-9]*$/u), + Schema.isMaxLength(200), +); +const checkedInventoryOwnerOperationKey = Schema.String.check( + Schema.isTrimmed(), + Schema.isPattern(/^commerce\.inventory\.api\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u), + Schema.isMaxLength(200), +); +const inventoryOwnerOperationKey = checkedInventoryOwnerOperationKey.pipe( + Schema.brand('InventoryOwnerReadOrProofKey'), + Schema.decodeTo(checkedInventoryOwnerOperationKey), +); +const positiveRevision = Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })); +const positiveTenantSequence = Schema.BigIntFromString.check(Schema.isGreaterThanBigInt(0n)); +const checkedUuid = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()); +const correlationId = boundedText.pipe(Schema.brand('InventoryDomainEventCorrelationId'), Schema.decodeTo(boundedText)); +const domainEventId = checkedUuid.pipe(Schema.brand('InventoryDomainEventId'), Schema.decodeTo(checkedUuid)); +const occurrenceId = boundedText.pipe(Schema.brand('InventoryDomainEventOccurrenceId'), Schema.decodeTo(boundedText)); +const resourceId = checkedUuid.pipe( + Schema.brand('InventoryDomainEventSubjectResourceId'), + Schema.decodeTo(checkedUuid), +); +const tenantId = checkedUuid.pipe(Schema.brand('InventoryDomainEventTenantId'), Schema.decodeTo(checkedUuid)); + +export const InventoryDomainEventFamilyKeySchema = Schema.Literals([ + 'RESERVATION_GUARANTEE_CHANGED', + 'COMMITMENT_PROTECTION_CHANGED', + 'STOCK_POSITION_EVIDENCE_CHANGED', + 'COMMITTED_OBLIGATION_CHANGED', +]); +export type InventoryDomainEventFamilyKey = typeof InventoryDomainEventFamilyKeySchema.Type; + +export const InventoryDomainEventOrderingKindSchema = Schema.Literals([ + 'IMMUTABLE_OCCURRENCE_IDENTITY', + 'OWNER_AGGREGATE_REVISION', +]); + +/** A public family is canonical only when every routing and owner-proof field is exact. */ +export const InventoryDomainEventFamilySchema = Schema.Struct({ + businessMeaning: boundedText, + consumer: Schema.Struct({ + behavior: Schema.Literal('INVALIDATE_AND_REREAD_OWNER'), + moduleKey, + useCase: boundedText, + }), + currentTruthBoundary: Schema.Literal('OWNER_READ_OR_PROOF_REQUIRED'), + deliveryFailureBoundary: Schema.Literal('RETRY_SEPARATELY_FROM_PRODUCER_COMMIT'), + duplicateBoundary: Schema.Literal('ONE_CONSUMER_EFFECT_PER_EVENT_SEQUENCE_PAIR'), + eventType: inventoryEventType, + family: InventoryDomainEventFamilyKeySchema, + ordering: InventoryDomainEventOrderingKindSchema, + outOfOrderBoundary: Schema.Literal('TENANT_SEQUENCE_IS_TRANSPORT_ORDER_NOT_OWNER_TRUTH'), + ownerReadOrProofKey: inventoryOwnerOperationKey, + producer: Schema.Struct({ + moduleKey: Schema.Literal(INVENTORY_MODULE_KEY), + revision: positiveRevision, + }), + retainedEventBoundary: Schema.Literal('HISTORICAL_FACT_NOT_CURRENT_GUARANTEE'), + subjectResourceTypes: Schema.Array( + Schema.String.check( + Schema.isTrimmed(), + Schema.isPattern(/^commerce\.inventory\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u), + Schema.isMaxLength(200), + ), + ).check(Schema.isMinLength(1)), +}).check( + Schema.makeFilter(({ eventType, producer }) => + eventType.endsWith(`.v${producer.revision}`) + ? undefined + : 'Inventory event type revision must equal the declared producer schema revision', + ), +); +export type InventoryDomainEventFamily = typeof InventoryDomainEventFamilySchema.Type; + +const familyBoundaries = { + currentTruthBoundary: 'OWNER_READ_OR_PROOF_REQUIRED', + deliveryFailureBoundary: 'RETRY_SEPARATELY_FROM_PRODUCER_COMMIT', + duplicateBoundary: 'ONE_CONSUMER_EFFECT_PER_EVENT_SEQUENCE_PAIR', + outOfOrderBoundary: 'TENANT_SEQUENCE_IS_TRANSPORT_ORDER_NOT_OWNER_TRUTH', + producer: { moduleKey: INVENTORY_MODULE_KEY, revision: 1 }, + retainedEventBoundary: 'HISTORICAL_FACT_NOT_CURRENT_GUARANTEE', +} as const; + +export const inventoryDomainEventFamilyByKey = Object.freeze({ + COMMITMENT_PROTECTION_CHANGED: InventoryDomainEventFamilySchema.make({ + ...familyBoundaries, + businessMeaning: 'Commitment Protection was established or became materially impaired after commit.', + consumer: { + behavior: 'INVALIDATE_AND_REREAD_OWNER', + moduleKey: moduleKey.make('commerce.order'), + useCase: 'Refresh exact Attempt-bound protection evidence without treating delivery as the commit gate.', + }, + eventType: 'commerce.inventory.commitment-protection-changed.v1', + family: 'COMMITMENT_PROTECTION_CHANGED', + ordering: 'OWNER_AGGREGATE_REVISION', + ownerReadOrProofKey: inventoryOwnerOperationKey.make('commerce.inventory.api.commitment-protection-verification'), + subjectResourceTypes: ['commerce.inventory.commitment-protection'], + }), + COMMITTED_OBLIGATION_CHANGED: InventoryDomainEventFamilySchema.make({ + ...familyBoundaries, + businessMeaning: 'The continuing committed Inventory obligation changed after an owner-governed transition.', + consumer: { + behavior: 'INVALIDATE_AND_REREAD_OWNER', + moduleKey: moduleKey.make('commerce.fulfillment'), + useCase: 'Refresh committed-obligation evidence for recovery or operations without repeating physical effects.', + }, + eventType: 'commerce.inventory.committed-obligation-changed.v1', + family: 'COMMITTED_OBLIGATION_CHANGED', + ordering: 'IMMUTABLE_OCCURRENCE_IDENTITY', + ownerReadOrProofKey: inventoryOwnerOperationKey.make('commerce.inventory.api.inventory-reconciliation-evidence'), + subjectResourceTypes: [ + 'commerce.inventory.inventory-reservation', + 'commerce.inventory.imported-committed-obligation', + ], + }), + RESERVATION_GUARANTEE_CHANGED: InventoryDomainEventFamilySchema.make({ + ...familyBoundaries, + businessMeaning: 'A material Reservation lifecycle or guarantee fact changed after commit.', + consumer: { + behavior: 'INVALIDATE_AND_REREAD_OWNER', + moduleKey: moduleKey.make('commerce.order'), + useCase: 'Refresh the exact Reservation guarantee before an Order or Fulfillment decision.', + }, + eventType: 'commerce.inventory.reservation-guarantee-changed.v1', + family: 'RESERVATION_GUARANTEE_CHANGED', + ordering: 'IMMUTABLE_OCCURRENCE_IDENTITY', + ownerReadOrProofKey: inventoryOwnerOperationKey.make('commerce.inventory.api.inventory-reservation-detail'), + subjectResourceTypes: ['commerce.inventory.inventory-reservation'], + }), + STOCK_POSITION_EVIDENCE_CHANGED: InventoryDomainEventFamilySchema.make({ + ...familyBoundaries, + businessMeaning: 'Material owner evidence for one exact Stock Position changed after commit.', + consumer: { + behavior: 'INVALIDATE_AND_REREAD_OWNER', + moduleKey: moduleKey.make('commerce.availability'), + useCase: 'Invalidate cached stock inputs and refresh them before recomputing an Availability promise.', + }, + eventType: 'commerce.inventory.stock-position-evidence-changed.v1', + family: 'STOCK_POSITION_EVIDENCE_CHANGED', + ordering: 'OWNER_AGGREGATE_REVISION', + ownerReadOrProofKey: inventoryOwnerOperationKey.make( + 'commerce.inventory.api.current-stock-evidence-for-availability', + ), + subjectResourceTypes: ['commerce.inventory.stock-position'], + }), +} satisfies Readonly>); + +export const inventoryDomainEventFamilies = Object.freeze([ + inventoryDomainEventFamilyByKey.RESERVATION_GUARANTEE_CHANGED, + inventoryDomainEventFamilyByKey.COMMITMENT_PROTECTION_CHANGED, + inventoryDomainEventFamilyByKey.STOCK_POSITION_EVIDENCE_CHANGED, + inventoryDomainEventFamilyByKey.COMMITTED_OBLIGATION_CHANGED, +]); + +export const InventoryCommittedEventSubjectRefSchema = Schema.Struct({ + moduleId: Schema.Literal(INVENTORY_MODULE_KEY), + resourceId, + resourceType: Schema.String.check( + Schema.isTrimmed(), + Schema.isPattern(/^commerce\.inventory\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u), + Schema.isMaxLength(200), + ), + tenantId, +}); + +export const InventoryImmutableOccurrenceOrderingSchema = Schema.TaggedStruct('IMMUTABLE_OCCURRENCE_IDENTITY', { + occurrenceId, +}); +export const InventoryOwnerAggregateRevisionOrderingSchema = Schema.TaggedStruct('OWNER_AGGREGATE_REVISION', { + revision: positiveRevision, +}); +export const InventoryCommittedEventOrderingSchema = Schema.Union([ + InventoryImmutableOccurrenceOrderingSchema, + InventoryOwnerAggregateRevisionOrderingSchema, +]); + +/** Payload metadata stays minimal; owner truth remains behind the canonical governed read/proof. */ +export const InventoryCommittedEventNoticeSchema = Schema.Struct({ + correlationId, + domainEventId, + eventType: inventoryEventType, + occurredAt: Schema.toEncoded(Schema.DateTimeUtcFromString), + ordering: InventoryCommittedEventOrderingSchema, + producerModuleKey: Schema.Literal(INVENTORY_MODULE_KEY), + producerRevision: positiveRevision, + subjectRef: InventoryCommittedEventSubjectRefSchema, + tenantSequenceNo: positiveTenantSequence, +}); + +const inventoryCurrentTruthRequirement = Object.freeze({ + currentTruthSource: 'SUPPORTED_OWNER_READ_OR_PROOF' as const, + eventSilenceIsCurrentProof: false as const, + retainedEventIsCurrentGuarantee: false as const, +}); + +/** Event presence, absence, retention, and delivery timing never establish Current Inventory. */ +export const currentInventoryTruthRequirement = () => inventoryCurrentTruthRequirement; + +/** A committed producer fact is never rolled back because asynchronous delivery needs a retry. */ +export const inventoryDomainEventDeliveryFailureBoundary = Object.freeze({ + producerTransactionRolledBack: false as const, + retry: 'SEPARATE_DELIVERY_RETRY' as const, +}); diff --git a/app/verticals/inventory/shared/domain/inventory-effect-ledger-conflict.ts b/app/verticals/inventory/shared/domain/inventory-effect-ledger-conflict.ts new file mode 100644 index 000000000..363d8e256 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-effect-ledger-conflict.ts @@ -0,0 +1,22 @@ +import { Schema } from 'effect'; + +import { InventoryEffectLedgerEffectIdSchema } from './inventory-effect-ledger-identifiers.ts'; + +const effectKindSchema = Schema.Literals([ + 'RESERVATION_CREATE', + 'RESERVATION_RELEASE', + 'ESTABLISH_COMMITMENT_PROTECTION', + 'PHYSICAL_RECEIPT', + 'PHYSICAL_ISSUE', +]); + +export class InventoryEffectLedgerConflict extends Schema.TaggedError()( + 'InventoryEffectLedgerConflict', + { + attemptedKind: effectKindSchema, + code: Schema.Literal('inventory_effect_ledger_conflict'), + effectId: InventoryEffectLedgerEffectIdSchema, + existingKind: effectKindSchema, + reason: Schema.Literal('MATERIAL_INTENT_CONFLICT'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-effect-ledger-identifiers.ts b/app/verticals/inventory/shared/domain/inventory-effect-ledger-identifiers.ts new file mode 100644 index 000000000..2a0e3c0ef --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-effect-ledger-identifiers.ts @@ -0,0 +1,7 @@ +import { Schema } from 'effect'; + +export const InventoryEffectLedgerEffectIdSchema = Schema.String.check( + Schema.isTrimmed(), + Schema.isMinLength(1), + Schema.isMaxLength(300), +).pipe(Schema.brand('InventoryEffectLedgerEffectId')); diff --git a/app/verticals/inventory/shared/domain/inventory-effect-ledger-rejected.ts b/app/verticals/inventory/shared/domain/inventory-effect-ledger-rejected.ts new file mode 100644 index 000000000..a05a8644b --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-effect-ledger-rejected.ts @@ -0,0 +1,18 @@ +import { Schema } from 'effect'; + +import { InventoryEffectLedgerEffectIdSchema } from './inventory-effect-ledger-identifiers.ts'; + +export class InventoryEffectLedgerRejected extends Schema.TaggedError()( + 'InventoryEffectLedgerRejected', + { + code: Schema.Literal('inventory_effect_ledger_rejected'), + effectId: InventoryEffectLedgerEffectIdSchema, + reason: Schema.Literals([ + 'INVALID_RESOLUTION', + 'INVALID_TRANSITION', + 'REVISION_CONFLICT', + 'TENANT_SCOPE_MISMATCH', + 'TERMINAL_EFFECT_IMMUTABLE', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-effect-ledger-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-effect-ledger-unavailable.ts new file mode 100644 index 000000000..82d3ac7f2 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-effect-ledger-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { InventoryEffectLedgerEffectIdSchema } from './inventory-effect-ledger-identifiers.ts'; + +export class InventoryEffectLedgerUnavailable extends Schema.TaggedError()( + 'InventoryEffectLedgerUnavailable', + { + code: Schema.Literal('inventory_effect_ledger_unavailable'), + effectId: InventoryEffectLedgerEffectIdSchema, + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-effect-ledger.ts b/app/verticals/inventory/shared/domain/inventory-effect-ledger.ts new file mode 100644 index 000000000..bddf155c9 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-effect-ledger.ts @@ -0,0 +1,120 @@ +import { Schema } from 'effect'; + +import { InventoryEffectLedgerConflict } from './inventory-effect-ledger-conflict.ts'; +import { InventoryEffectLedgerEffectIdSchema } from './inventory-effect-ledger-identifiers.ts'; +import { InventoryEffectLedgerRejected } from './inventory-effect-ledger-rejected.ts'; +import { CommitmentProtectionEffectRequestSchema, CommitmentProtectionEffectSchema } from './commitment-protection.ts'; +import { + InventoryReservationCreateRequestSchema, + ReservationCreateEffectSchema, +} from './inventory-reservation-create.ts'; +import { ReservationReleaseEffectSchema, ReservationReleaseRequestSchema } from './inventory-reservation-release.ts'; +import { PhysicalStockEffectRecordSchema, PhysicalStockEffectRequestSchema } from './physical-stock-effect.ts'; +import { InventoryEffectLedgerUnavailable } from './inventory-effect-ledger-unavailable.ts'; + +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export { InventoryEffectLedgerEffectIdSchema } from './inventory-effect-ledger-identifiers.ts'; +export const InventoryEffectLedgerKindSchema = Schema.Literals([ + 'RESERVATION_CREATE', + 'RESERVATION_RELEASE', + 'ESTABLISH_COMMITMENT_PROTECTION', + 'PHYSICAL_RECEIPT', + 'PHYSICAL_ISSUE', +]); +export const InventoryEffectLedgerStateSchema = Schema.Literals([ + 'REQUESTED', + 'INDETERMINATE', + 'SUCCEEDED', + 'REJECTED', +]); + +export const ReservationCreateInventoryEffectLedgerIntentSchema = Schema.TaggedStruct('RESERVATION_CREATE', { + request: Schema.Struct({ + authority: InventoryReservationCreateRequestSchema.fields.authority, + commerceContext: InventoryReservationCreateRequestSchema.fields.commerceContext, + effectId: InventoryReservationCreateRequestSchema.fields.effectId, + legalEntityId: InventoryReservationCreateRequestSchema.fields.legalEntityId, + reservation: InventoryReservationCreateRequestSchema.fields.reservation, + }), +}); +export const ReservationReleaseInventoryEffectLedgerIntentSchema = Schema.TaggedStruct('RESERVATION_RELEASE', { + request: Schema.Struct({ + effectId: ReservationReleaseRequestSchema.fields.effectId, + legalEntityId: ReservationReleaseRequestSchema.fields.legalEntityId, + reservation: ReservationReleaseRequestSchema.fields.reservation, + }), +}); +export const CommitmentProtectionInventoryEffectLedgerIntentSchema = Schema.TaggedStruct( + 'ESTABLISH_COMMITMENT_PROTECTION', + { request: CommitmentProtectionEffectRequestSchema }, +); +const physicalBusinessRequest = { + backend: PhysicalStockEffectRequestSchema.fields.backend, + backendConfigurationRef: PhysicalStockEffectRequestSchema.fields.backendConfigurationRef, + backendId: PhysicalStockEffectRequestSchema.fields.backendId, + customerConfigurationId: PhysicalStockEffectRequestSchema.fields.customerConfigurationId, + effectId: PhysicalStockEffectRequestSchema.fields.effectId, + kind: PhysicalStockEffectRequestSchema.fields.kind, + legalEntityId: PhysicalStockEffectRequestSchema.fields.legalEntityId, + positionRef: PhysicalStockEffectRequestSchema.fields.positionRef, + quantity: PhysicalStockEffectRequestSchema.fields.quantity, + reason: PhysicalStockEffectRequestSchema.fields.reason, + stockItemRef: PhysicalStockEffectRequestSchema.fields.stockItemRef, + stockLocationRef: PhysicalStockEffectRequestSchema.fields.stockLocationRef, +} as const; +const physicalReceiptIntent = Schema.TaggedStruct('PHYSICAL_RECEIPT', { + request: Schema.Struct(physicalBusinessRequest).check( + Schema.makeFilter(({ kind }) => (kind === 'RECEIPT' ? undefined : 'Receipt ledger intent must carry a Receipt')), + ), +}); +export const PhysicalIssueInventoryEffectLedgerIntentSchema = Schema.TaggedStruct('PHYSICAL_ISSUE', { + request: Schema.Struct(physicalBusinessRequest).check( + Schema.makeFilter(({ kind }) => (kind === 'ISSUE' ? undefined : 'Issue ledger intent must carry an Issue')), + ), +}); +export const InventoryEffectLedgerIntentSchema = Schema.Union([ + ReservationCreateInventoryEffectLedgerIntentSchema, + ReservationReleaseInventoryEffectLedgerIntentSchema, + CommitmentProtectionInventoryEffectLedgerIntentSchema, + physicalReceiptIntent, + PhysicalIssueInventoryEffectLedgerIntentSchema, +]); +export type InventoryEffectLedgerIntent = typeof InventoryEffectLedgerIntentSchema.Type; + +export const PhysicalIssueInventoryEffectLedgerResolutionSchema = Schema.TaggedStruct('PHYSICAL_ISSUE', { + effect: PhysicalStockEffectRecordSchema, +}); + +export const InventoryEffectLedgerResolutionSchema = Schema.Union([ + Schema.TaggedStruct('RESERVATION_CREATE', { effect: ReservationCreateEffectSchema }), + Schema.TaggedStruct('RESERVATION_RELEASE', { effect: ReservationReleaseEffectSchema }), + Schema.TaggedStruct('ESTABLISH_COMMITMENT_PROTECTION', { effect: CommitmentProtectionEffectSchema }), + Schema.TaggedStruct('PHYSICAL_RECEIPT', { effect: PhysicalStockEffectRecordSchema }), + PhysicalIssueInventoryEffectLedgerResolutionSchema, +]); +export type InventoryEffectLedgerResolution = typeof InventoryEffectLedgerResolutionSchema.Type; + +export const InventoryEffectLedgerRecordSchema = Schema.Struct({ + currentState: InventoryEffectLedgerStateSchema, + effectId: InventoryEffectLedgerEffectIdSchema, + intent: InventoryEffectLedgerIntentSchema, + requestedAt: instant, + // oxlint-disable-next-line effect-native/no-nullable-schema-field -- Persisted ledger snapshots use explicit JSON null before owner resolution; expires: 2027-03-31. + resolution: Schema.NullOr(InventoryEffectLedgerResolutionSchema), + revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)), + tenantId: PhysicalStockEffectRequestSchema.fields.positionRef.fields.tenantId, + updatedAt: instant, +}); +export type InventoryEffectLedgerRecord = typeof InventoryEffectLedgerRecordSchema.Type; + +export const InventoryEffectLedgerErrorSchema = Schema.Union([ + InventoryEffectLedgerConflict, + InventoryEffectLedgerRejected, + InventoryEffectLedgerUnavailable, +]); +export type InventoryEffectLedgerError = typeof InventoryEffectLedgerErrorSchema.Type; + +export { InventoryEffectLedgerUnavailable } from './inventory-effect-ledger-unavailable.ts'; +export { InventoryEffectLedgerConflict } from './inventory-effect-ledger-conflict.ts'; +export { InventoryEffectLedgerRejected } from './inventory-effect-ledger-rejected.ts'; diff --git a/app/verticals/inventory/shared/domain/inventory-effect-recovery.ts b/app/verticals/inventory/shared/domain/inventory-effect-recovery.ts new file mode 100644 index 000000000..5055114c5 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-effect-recovery.ts @@ -0,0 +1,166 @@ +import { DateTime, Match, Schema } from 'effect'; + +import { + InventoryEffectLedgerEffectIdSchema, + InventoryEffectLedgerIntentSchema, + InventoryEffectLedgerKindSchema, + InventoryEffectLedgerRecordSchema, + InventoryEffectLedgerResolutionSchema, +} from './inventory-effect-ledger.ts'; + +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const boundedEvidenceRef = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instantMillis = (value: string): number => DateTime.toEpochMillis(DateTime.makeUnsafe(value)); +const occursNoLaterThan = (earlier: string, later: string): boolean => instantMillis(earlier) <= instantMillis(later); + +export const InventoryEffectRecoveryFenceSchema = Schema.Literals([ + 'PRESERVE_POSSIBLE_PARTIAL_HOLD', + 'BLOCK_RELEASED_STOCK_REUSE', + 'PRESERVE_POSSIBLE_PROTECTION_FENCE', + 'PRESERVE_PHYSICAL_QUANTITY_UNCERTAINTY', +]); +export type InventoryEffectRecoveryFence = typeof InventoryEffectRecoveryFenceSchema.Type; + +export const InventoryEffectRecoveryIndeterminateReasonSchema = Schema.Literals([ + 'TIMEOUT', + 'MISSING_CALLBACK', + 'WORKER_CRASH', + 'TEMPORARY_NOT_FOUND', + 'OWNER_UNAVAILABLE', + 'TRANSPORT_UNAVAILABLE', + 'PARTIAL_BACKEND_EFFECT', + 'OUTCOME_UNKNOWN', +]); + +export const InventoryEffectRecoveryRequestSchema = Schema.Struct({ + effectId: InventoryEffectLedgerEffectIdSchema, + expectedKind: InventoryEffectLedgerKindSchema, + tenantId: InventoryEffectLedgerRecordSchema.fields.tenantId, +}); +export type InventoryEffectRecoveryRequest = typeof InventoryEffectRecoveryRequestSchema.Type; + +const recoveryAuthorityIdentity = { + effectId: InventoryEffectLedgerEffectIdSchema, + intent: InventoryEffectLedgerIntentSchema, + kind: InventoryEffectLedgerKindSchema, + learnedAt: instant, +} as const; + +export const AuthoritativeSuccessInventoryEffectRecoveryObservationSchema = Schema.TaggedStruct( + 'AUTHORITATIVE_SUCCESS', + { + ...recoveryAuthorityIdentity, + occurredAt: instant, + ownerEvidenceRef: boundedEvidenceRef, + resolution: InventoryEffectLedgerResolutionSchema, + }, +).check( + Schema.makeFilter(({ learnedAt, occurredAt }) => + occursNoLaterThan(occurredAt, learnedAt) ? undefined : 'Recovery cannot learn an effect before it occurred', + ), +); +export const DefinitiveNonEffectInventoryEffectRecoveryObservationSchema = Schema.TaggedStruct( + 'DEFINITIVE_NON_EFFECT', + { + ...recoveryAuthorityIdentity, + nonEffectFinal: Schema.Literal(true), + ownerEvidenceRef: boundedEvidenceRef, + provenAt: instant, + resolution: InventoryEffectLedgerResolutionSchema, + }, +).check( + Schema.makeFilter(({ learnedAt, provenAt }) => + occursNoLaterThan(provenAt, learnedAt) + ? undefined + : 'Recovery cannot learn definitive non-effect proof before it was established', + ), +); +export const IndeterminateInventoryEffectRecoveryObservationSchema = Schema.TaggedStruct('INDETERMINATE', { + ...recoveryAuthorityIdentity, + occurredAt: Schema.optionalKey(instant), + reason: InventoryEffectRecoveryIndeterminateReasonSchema, +}).check( + Schema.makeFilter(({ learnedAt, occurredAt }) => + occurredAt === undefined || occursNoLaterThan(occurredAt, learnedAt) + ? undefined + : 'An uncertain effect occurrence cannot be later than the recovery observation', + ), +); +export const InventoryEffectRecoveryAuthorityObservationSchema = Schema.Union([ + AuthoritativeSuccessInventoryEffectRecoveryObservationSchema, + DefinitiveNonEffectInventoryEffectRecoveryObservationSchema, + IndeterminateInventoryEffectRecoveryObservationSchema, +]); +export type InventoryEffectRecoveryAuthorityObservation = typeof InventoryEffectRecoveryAuthorityObservationSchema.Type; + +const reconciliationDebt = { + effectId: InventoryEffectLedgerEffectIdSchema, + fence: InventoryEffectRecoveryFenceSchema, + kind: InventoryEffectLedgerKindSchema, + learnedAt: instant, + possibleEffectOccurred: Schema.Literal(true), + reconciliationRequired: Schema.Literal(true), + record: Schema.optionalKey(InventoryEffectLedgerRecordSchema), + tenantId: InventoryEffectLedgerRecordSchema.fields.tenantId, +} as const; + +export const RecoveredInventoryEffectResultSchema = Schema.TaggedStruct('RECOVERED', { + effectId: InventoryEffectLedgerEffectIdSchema, + learnedAt: instant, + occurredAt: instant, + ownerEvidenceRef: boundedEvidenceRef, + record: InventoryEffectLedgerRecordSchema, +}); +export const DefinitiveNonEffectInventoryEffectResultSchema = Schema.TaggedStruct('DEFINITIVE_NON_EFFECT', { + effectId: InventoryEffectLedgerEffectIdSchema, + learnedAt: instant, + ownerEvidenceRef: boundedEvidenceRef, + provenAt: instant, + record: InventoryEffectLedgerRecordSchema, +}); +export const AlreadyTerminalInventoryEffectResultSchema = Schema.TaggedStruct('ALREADY_TERMINAL', { + effectId: InventoryEffectLedgerEffectIdSchema, + record: InventoryEffectLedgerRecordSchema, +}); +export const IndeterminateInventoryEffectResultSchema = Schema.TaggedStruct('INDETERMINATE', { + ...reconciliationDebt, + occurredAt: Schema.optionalKey(instant), + reason: InventoryEffectRecoveryIndeterminateReasonSchema, +}); +export type InventoryEffectRecoveryResult = + | typeof RecoveredInventoryEffectResultSchema.Type + | typeof DefinitiveNonEffectInventoryEffectResultSchema.Type + | typeof AlreadyTerminalInventoryEffectResultSchema.Type + | typeof IndeterminateInventoryEffectResultSchema.Type; + +export class InventoryEffectRecoveryRejected extends Schema.TaggedError()( + 'InventoryEffectRecoveryRejected', + { + code: Schema.Literal('inventory_effect_recovery_rejected'), + effectId: InventoryEffectLedgerEffectIdSchema, + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'EFFECT_KIND_MISMATCH', + 'AUTHORITY_IDENTITY_MISMATCH', + 'AUTHORITY_KIND_MISMATCH', + 'AUTHORITY_INTENT_MISMATCH', + 'INVALID_AUTHORITY_OUTCOME', + 'OWNER_EFFECT_NOT_FOUND', + 'OWNER_STATE_CONFLICT', + 'OWNER_PERSISTENCE_UNAVAILABLE', + 'PROTECTION_ESTABLISHED_AFTER_CONFIRMATION_EXPIRY', + 'PROTECTION_PROOF_TIME_MISMATCH', + ]), + }, +) {} + +export const inventoryEffectRecoveryFenceFor = ( + kind: typeof InventoryEffectLedgerKindSchema.Type, +): InventoryEffectRecoveryFence => + Match.value(kind).pipe( + Match.when('RESERVATION_CREATE', () => 'PRESERVE_POSSIBLE_PARTIAL_HOLD' as const), + Match.when('RESERVATION_RELEASE', () => 'BLOCK_RELEASED_STOCK_REUSE' as const), + Match.when('ESTABLISH_COMMITMENT_PROTECTION', () => 'PRESERVE_POSSIBLE_PROTECTION_FENCE' as const), + Match.whenOr('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', () => 'PRESERVE_PHYSICAL_QUANTITY_UNCERTAINTY' as const), + Match.exhaustive, + ); diff --git a/app/verticals/inventory/shared/domain/inventory-obligation-persistence-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-obligation-persistence-unavailable.ts new file mode 100644 index 000000000..b04a647a8 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-obligation-persistence-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class InventoryObligationPersistenceUnavailable extends Schema.TaggedError()( + 'InventoryObligationPersistenceUnavailable', + { + code: Schema.Literal('inventory_obligation_persistence_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-obligation.ts b/app/verticals/inventory/shared/domain/inventory-obligation.ts new file mode 100644 index 000000000..2c16eddf0 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-obligation.ts @@ -0,0 +1,449 @@ +import type { ProductUnitRefSchema } from '@app/catalog/resources/product-unit'; +import { Effect, Schema } from 'effect'; + +import { ResolvedCatalogStockDemandSchema } from './catalog-to-stock-binding.ts'; +import type { ResolvedCatalogStockDemand } from './catalog-to-stock-binding.ts'; +import type { ImportedOrderCommitProofRejected } from './imported-order-commit-proof-rejected.ts'; +import type { ImportedOrderCommitProofUnavailable } from './imported-order-commit-proof-unavailable.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import type { RuntimeOrderCommitProofRejected } from './runtime-order-commit-proof-rejected.ts'; +import type { RuntimeOrderCommitProofUnavailable } from './runtime-order-commit-proof-unavailable.ts'; +import { StockQuantitySchema } from './stock-position.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { ImportedCommittedObligationRefSchema } from '../resources/imported-committed-obligation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +const boundedIdentifier = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const obligationInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const StockAllocationIdSchema = boundedIdentifier.pipe(Schema.brand('InventoryStockAllocationId')); + +const sameRef = ( + left: { readonly resourceId: string; readonly tenantId: string }, + right: { readonly resourceId: string; readonly tenantId: string }, +) => left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +const sameUnit = (left: typeof ProductUnitRefSchema.Type, right: typeof ProductUnitRefSchema.Type) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +export const InventoryStockAllocationSchema = Schema.Struct({ + allocationId: StockAllocationIdSchema, + positionRef: StockPositionRefSchema, + quantity: StockQuantitySchema, + stockItemRef: StockItemRefSchema, +}); +export type InventoryStockAllocation = typeof InventoryStockAllocationSchema.Type; + +export const InventoryObligationRequirementSchema = Schema.Struct({ + ...ResolvedCatalogStockDemandSchema.fields, + allocations: Schema.Array(InventoryStockAllocationSchema).check(Schema.isMinLength(1)), +}).check( + Schema.makeFilter((requirement) => { + const { bindingRef, catalogSelection, exactSelectionMeaning, stockItem, unitRef } = requirement; + if ( + exactSelectionMeaning.id !== stockItem.exactSelectionMeaning.id || + exactSelectionMeaning.kind !== stockItem.exactSelectionMeaning.kind + ) { + return 'Resolved demand exact Selection meaning must match the immutable Stock Item meaning'; + } + if (!sameRef(unitRef, stockItem.unitRef)) { + return 'Resolved demand Unit must match the immutable Stock Item Unit'; + } + const { tenantId } = catalogSelection.productRef; + return [bindingRef.tenantId, stockItem.stockItemRef.tenantId, unitRef.tenantId].every( + (candidate) => candidate === tenantId, + ) + ? undefined + : 'Resolved demand provenance, binding, Stock Item, and Unit must share one Tenant'; + }), +); +export type InventoryObligationRequirement = typeof InventoryObligationRequirementSchema.Type; + +const RuntimeReservationOriginSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + kind: Schema.Literal('ORDER_COMMITMENT_ATTEMPT'), +}); + +const ImportedObligationOriginSchema = Schema.Struct({ + kind: Schema.Literal('IMPORTED_PROVEN_ORDER'), + sourceObligationId: boundedIdentifier.pipe(Schema.brand('ImportedSourceObligationId')), + sourceOrderId: boundedIdentifier.pipe(Schema.brand('ImportedSourceOrderId')), + sourceSystem: boundedIdentifier, +}); + +export const ImportedOrderCommitProofObservationSchema = Schema.Struct({ + acceptedOrderId: boundedIdentifier.pipe(Schema.brand('ImportedAcceptedOrderId')), + evidenceRef: boundedIdentifier.pipe(Schema.brand('ImportedOrderCommitEvidenceRef')), + observedAt: obligationInstant, + sourceOrderId: boundedIdentifier.pipe(Schema.brand('ImportedSourceOrderId')), + sourceSystem: boundedIdentifier, +}); +export type ImportedOrderCommitProofObservation = typeof ImportedOrderCommitProofObservationSchema.Type; + +export const VerifiedImportedOrderCommitProofSchema = Schema.Struct({ + ...ImportedOrderCommitProofObservationSchema.fields, + authority: Schema.Literal('ORDER_MIGRATION_PROOF_AUTHORITY'), + commitStatus: Schema.Literal('COMMITTED'), +}); +export type VerifiedImportedOrderCommitProof = typeof VerifiedImportedOrderCommitProofSchema.Type; + +export const RuntimeOrderCommitProofObservationSchema = Schema.Struct({ + acceptedOrderId: boundedIdentifier.pipe(Schema.brand('AcceptedOrderId')), + attemptId: OrderCommitmentAttemptIdSchema, + evidenceRef: boundedIdentifier.pipe(Schema.brand('OrderCommitEvidenceRef')), + observedAt: obligationInstant, + reservationRef: InventoryReservationRefSchema, + tenantId: InventoryReservationRefSchema.fields.tenantId, +}); +export type RuntimeOrderCommitProofObservation = typeof RuntimeOrderCommitProofObservationSchema.Type; + +export const VerifiedRuntimeOrderCommitProofSchema = Schema.Struct({ + ...RuntimeOrderCommitProofObservationSchema.fields, + authority: Schema.Literal('ORDER_COMMIT_PROOF_AUTHORITY'), + commitStatus: Schema.Literal('COMMITTED'), +}); +export type VerifiedRuntimeOrderCommitProof = typeof VerifiedRuntimeOrderCommitProofSchema.Type; + +export const EstablishInventoryReservationInputSchema = Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + establishedAt: obligationInstant, + origin: RuntimeReservationOriginSchema, + ref: InventoryReservationRefSchema, + requirements: Schema.Array(InventoryObligationRequirementSchema).check(Schema.isMinLength(1)), +}); +export type EstablishInventoryReservationInput = typeof EstablishInventoryReservationInputSchema.Type; + +export const ImportCommittedInventoryObligationInputSchema = Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + importedAt: obligationInstant, + orderProofObservation: ImportedOrderCommitProofObservationSchema, + origin: ImportedObligationOriginSchema, + ref: ImportedCommittedObligationRefSchema, + requirements: Schema.Array(InventoryObligationRequirementSchema).check(Schema.isMinLength(1)), + runtimeAttemptId: Schema.Null, +}); +export type ImportCommittedInventoryObligationInput = typeof ImportCommittedInventoryObligationInputSchema.Type; + +export const ProvisionalInventoryReservationSchema = Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + establishedAt: obligationInstant, + lifecycleMeaning: Schema.Literal('PROVISIONAL_RESERVATION'), + origin: RuntimeReservationOriginSchema, + ref: InventoryReservationRefSchema, + requirements: Schema.Array(InventoryObligationRequirementSchema).check(Schema.isMinLength(1)), +}); +export type ProvisionalInventoryReservation = typeof ProvisionalInventoryReservationSchema.Type; + +export const CommitInventoryReservationInputSchema = Schema.Struct({ + orderProofObservation: RuntimeOrderCommitProofObservationSchema, + reservation: ProvisionalInventoryReservationSchema, +}); +export type CommitInventoryReservationInput = typeof CommitInventoryReservationInputSchema.Type; + +export const RuntimeCommittedInventoryObligationSchema = Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + confirmationTerminationReleasesStock: Schema.Literal(false), + establishedAt: obligationInstant, + historicalBindingPolicy: Schema.Literal('PRESERVE_AND_RECONCILE'), + lifecycleMeaning: Schema.Literal('COMMITTED_OBLIGATION'), + obligationReductionCreatesOnHand: Schema.Literal(false), + orderProof: VerifiedRuntimeOrderCommitProofSchema, + origin: RuntimeReservationOriginSchema, + physicalIssueBoundary: Schema.Literal('SEPARATE_INVENTORY_TRANSITION'), + ref: InventoryReservationRefSchema, + remainingQuantityConstraint: Schema.Literal('OWNER_GOVERNED_TRANSITION_REQUIRED'), + requirements: Schema.Array(InventoryObligationRequirementSchema).check(Schema.isMinLength(1)), +}).check( + Schema.makeFilter(({ orderProof, origin, ref }) => + orderProof.tenantId === ref.tenantId && + orderProof.attemptId === origin.attemptId && + sameRef(orderProof.reservationRef, ref) + ? undefined + : 'Order commit proof must match the exact Reservation Tenant, Attempt, and identity', + ), +); +export type RuntimeCommittedInventoryObligation = typeof RuntimeCommittedInventoryObligationSchema.Type; + +export const ImportedCommittedObligationSchema = Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + importedAt: obligationInstant, + lifecycleMeaning: Schema.Literal('COMMITTED_OBLIGATION'), + orderProof: VerifiedImportedOrderCommitProofSchema, + origin: ImportedObligationOriginSchema, + ref: ImportedCommittedObligationRefSchema, + requirements: Schema.Array(InventoryObligationRequirementSchema).check(Schema.isMinLength(1)), + runtimeAttemptId: Schema.Null, +}); +export type ImportedCommittedObligation = typeof ImportedCommittedObligationSchema.Type; + +export const InventoryObligationSchema = Schema.Union([ + ProvisionalInventoryReservationSchema, + RuntimeCommittedInventoryObligationSchema, + ImportedCommittedObligationSchema, +]); +export type InventoryObligation = typeof InventoryObligationSchema.Type; + +export class InventoryObligationRejected extends Schema.TaggedError()( + 'InventoryObligationRejected', + { + code: Schema.Literal('inventory_obligation_rejected'), + purchaseDemandOccurrenceId: Schema.optionalKey(ResolvedCatalogStockDemandSchema.fields.purchaseDemandOccurrenceId), + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'SELECTED_AUTHORITY_REQUIRED', + 'DUPLICATE_DEMAND_OCCURRENCE', + 'DUPLICATE_ALLOCATION_IDENTITY', + 'ALLOCATION_ITEM_MISMATCH', + 'ALLOCATION_UNIT_MISMATCH', + 'ALLOCATION_QUANTITY_MISMATCH', + 'IDENTITY_NAMESPACE_COLLISION', + 'RESOLVED_DEMAND_MISMATCH', + 'IMPORT_PROOF_REJECTED', + 'IMPORT_PROOF_SCOPE_MISMATCH', + 'ATTEMPT_ALREADY_BOUND', + 'OBLIGATION_IDENTITY_CONFLICT', + 'SOURCE_LINEAGE_ALREADY_IMPORTED', + 'ORDER_COMMIT_BINDING_CONFLICT', + 'ORDER_COMMIT_PROOF_SCOPE_MISMATCH', + 'RESERVATION_NOT_PROVISIONAL', + 'INVALID_PERSISTED_OBLIGATION', + ]), + }, +) {} + +export { ImportedOrderCommitProofRejected } from './imported-order-commit-proof-rejected.ts'; + +/** Implemented only by the trusted migration owner; caller literals never establish committed truth. */ +export interface ImportedOrderCommitProofVerifier { + readonly verifyCommitted: ( + observation: ImportedOrderCommitProofObservation, + ) => Effect.Effect< + VerifiedImportedOrderCommitProof, + ImportedOrderCommitProofRejected | ImportedOrderCommitProofUnavailable + >; +} + +/** Implemented only by the trusted Order evidence adapter; caller literals never establish committed truth. */ +export interface RuntimeOrderCommitProofVerifier { + readonly verifyCommitted: ( + observation: RuntimeOrderCommitProofObservation, + ) => Effect.Effect< + VerifiedRuntimeOrderCommitProof, + RuntimeOrderCommitProofRejected | RuntimeOrderCommitProofUnavailable + >; +} + +const rejection = ( + reason: InventoryObligationRejected['reason'], + purchaseDemandOccurrenceId?: ResolvedCatalogStockDemand['purchaseDemandOccurrenceId'], +) => + purchaseDemandOccurrenceId === undefined + ? new InventoryObligationRejected({ code: 'inventory_obligation_rejected', reason }) + : new InventoryObligationRejected({ + code: 'inventory_obligation_rejected', + purchaseDemandOccurrenceId, + reason, + }); + +interface DecimalParts { + readonly coefficient: bigint; + readonly scale: number; +} + +const decimalParts = (amount: string): DecimalParts => { + const [integer = '0', fraction = ''] = amount.split('.'); + return { coefficient: BigInt(`${integer}${fraction}`), scale: fraction.length }; +}; + +const sumAmounts = (amounts: readonly string[]): DecimalParts => { + let scale = 0; + for (const amount of amounts) { + scale = Math.max(scale, decimalParts(amount).scale); + } + let coefficient = 0n; + for (const amount of amounts) { + const parts = decimalParts(amount); + coefficient += parts.coefficient * 10n ** BigInt(scale - parts.scale); + } + return { coefficient, scale }; +}; + +const equalAmount = (left: string, right: DecimalParts): boolean => { + const leftParts = decimalParts(left); + const scale = Math.max(leftParts.scale, right.scale); + return ( + leftParts.coefficient * 10n ** BigInt(scale - leftParts.scale) === + right.coefficient * 10n ** BigInt(scale - right.scale) + ); +}; + +const validateRequirements = Effect.fn('InventoryObligation.validateRequirements')( + function* validateObligationRequirements(tenantId: string, requirements: readonly InventoryObligationRequirement[]) { + const occurrenceIds = new Set(); + const allocationIds = new Set(); + for (const requirement of requirements) { + if (occurrenceIds.has(requirement.purchaseDemandOccurrenceId)) { + return yield* rejection('DUPLICATE_DEMAND_OCCURRENCE', requirement.purchaseDemandOccurrenceId); + } + occurrenceIds.add(requirement.purchaseDemandOccurrenceId); + if ( + requirement.bindingRef.tenantId !== tenantId || + requirement.catalogSelection.productRef.tenantId !== tenantId || + requirement.stockItem.stockItemRef.tenantId !== tenantId || + requirement.unitRef.tenantId !== tenantId + ) { + return yield* rejection('TENANT_SCOPE_MISMATCH', requirement.purchaseDemandOccurrenceId); + } + if ( + requirement.exactSelectionMeaning.id !== requirement.stockItem.exactSelectionMeaning.id || + requirement.exactSelectionMeaning.kind !== requirement.stockItem.exactSelectionMeaning.kind || + !sameRef(requirement.unitRef, requirement.stockItem.unitRef) + ) { + return yield* rejection('RESOLVED_DEMAND_MISMATCH', requirement.purchaseDemandOccurrenceId); + } + for (const allocation of requirement.allocations) { + if (allocationIds.has(allocation.allocationId)) { + return yield* rejection('DUPLICATE_ALLOCATION_IDENTITY', requirement.purchaseDemandOccurrenceId); + } + allocationIds.add(allocation.allocationId); + if ( + allocation.positionRef.tenantId !== tenantId || + allocation.stockItemRef.tenantId !== tenantId || + allocation.quantity.unitRef.tenantId !== tenantId + ) { + return yield* rejection('TENANT_SCOPE_MISMATCH', requirement.purchaseDemandOccurrenceId); + } + if (!sameRef(allocation.stockItemRef, requirement.stockItem.stockItemRef)) { + return yield* rejection('ALLOCATION_ITEM_MISMATCH', requirement.purchaseDemandOccurrenceId); + } + if (!sameUnit(allocation.quantity.unitRef, requirement.unitRef)) { + return yield* rejection('ALLOCATION_UNIT_MISMATCH', requirement.purchaseDemandOccurrenceId); + } + } + if ( + !equalAmount(requirement.quantity, sumAmounts(requirement.allocations.map(({ quantity }) => quantity.amount))) + ) { + return yield* rejection('ALLOCATION_QUANTITY_MISMATCH', requirement.purchaseDemandOccurrenceId); + } + } + return yield* Effect.void; + }, +); + +export const establishInventoryReservation = Effect.fn('establishInventoryReservation')(function* establishReservation( + input: EstablishInventoryReservationInput, +) { + if (String(input.ref.tenantId) !== String(input.authority.tenantId)) { + return yield* rejection('TENANT_SCOPE_MISMATCH'); + } + if (input.authority.selection.exactReservationCapability !== 'SUPPORTED') { + return yield* rejection('SELECTED_AUTHORITY_REQUIRED'); + } + if (String(input.ref.resourceId) === String(input.origin.attemptId)) { + return yield* rejection('IDENTITY_NAMESPACE_COLLISION'); + } + yield* validateRequirements(input.ref.tenantId, input.requirements); + return { + authority: input.authority, + establishedAt: input.establishedAt, + lifecycleMeaning: 'PROVISIONAL_RESERVATION' as const, + origin: input.origin, + ref: input.ref, + requirements: input.requirements, + } satisfies ProvisionalInventoryReservation; +}); + +export const makeInventoryReservationCommitter = (proofVerifier: RuntimeOrderCommitProofVerifier) => ({ + commit: Effect.fn('InventoryReservationCommitter.commit')(function* commitReservation( + input: CommitInventoryReservationInput, + ) { + const { orderProofObservation, reservation } = input; + if ( + orderProofObservation.tenantId !== reservation.ref.tenantId || + orderProofObservation.attemptId !== reservation.origin.attemptId || + !sameRef(orderProofObservation.reservationRef, reservation.ref) + ) { + return yield* rejection('ORDER_COMMIT_PROOF_SCOPE_MISMATCH'); + } + const orderProof = yield* proofVerifier.verifyCommitted(orderProofObservation); + if ( + orderProof.acceptedOrderId !== orderProofObservation.acceptedOrderId || + orderProof.attemptId !== reservation.origin.attemptId || + orderProof.evidenceRef !== orderProofObservation.evidenceRef || + orderProof.observedAt !== orderProofObservation.observedAt || + orderProof.tenantId !== reservation.ref.tenantId || + !sameRef(orderProof.reservationRef, reservation.ref) + ) { + return yield* rejection('ORDER_COMMIT_PROOF_SCOPE_MISMATCH'); + } + return { + authority: reservation.authority, + confirmationTerminationReleasesStock: false as const, + establishedAt: reservation.establishedAt, + historicalBindingPolicy: 'PRESERVE_AND_RECONCILE' as const, + lifecycleMeaning: 'COMMITTED_OBLIGATION' as const, + obligationReductionCreatesOnHand: false as const, + orderProof, + origin: reservation.origin, + physicalIssueBoundary: 'SEPARATE_INVENTORY_TRANSITION' as const, + ref: reservation.ref, + remainingQuantityConstraint: 'OWNER_GOVERNED_TRANSITION_REQUIRED' as const, + requirements: reservation.requirements, + } satisfies RuntimeCommittedInventoryObligation; + }), +}); + +export const makeImportedCommittedObligationImporter = (proofVerifier: ImportedOrderCommitProofVerifier) => ({ + import: Effect.fn('ImportedCommittedObligationImporter.import')(function* importObligation( + input: ImportCommittedInventoryObligationInput, + ) { + if (String(input.ref.tenantId) !== String(input.authority.tenantId)) { + return yield* rejection('TENANT_SCOPE_MISMATCH'); + } + if (input.authority.selection.exactReservationCapability !== 'SUPPORTED') { + return yield* rejection('SELECTED_AUTHORITY_REQUIRED'); + } + if ( + [ + input.orderProofObservation.acceptedOrderId, + input.orderProofObservation.sourceOrderId, + input.origin.sourceOrderId, + input.origin.sourceObligationId, + ].some((candidate) => String(candidate) === String(input.ref.resourceId)) + ) { + return yield* rejection('IDENTITY_NAMESPACE_COLLISION'); + } + if ( + input.orderProofObservation.sourceSystem !== input.origin.sourceSystem || + input.orderProofObservation.sourceOrderId !== input.origin.sourceOrderId + ) { + return yield* rejection('IMPORT_PROOF_SCOPE_MISMATCH'); + } + const orderProof = yield* proofVerifier.verifyCommitted(input.orderProofObservation); + if ( + orderProof.acceptedOrderId !== input.orderProofObservation.acceptedOrderId || + orderProof.evidenceRef !== input.orderProofObservation.evidenceRef || + orderProof.observedAt !== input.orderProofObservation.observedAt || + orderProof.sourceOrderId !== input.origin.sourceOrderId || + orderProof.sourceSystem !== input.origin.sourceSystem + ) { + return yield* rejection('IMPORT_PROOF_SCOPE_MISMATCH'); + } + yield* validateRequirements(input.ref.tenantId, input.requirements); + return { + authority: input.authority, + importedAt: input.importedAt, + lifecycleMeaning: 'COMMITTED_OBLIGATION' as const, + orderProof, + origin: input.origin, + ref: input.ref, + requirements: input.requirements, + runtimeAttemptId: null, + } satisfies ImportedCommittedObligation; + }), +}); diff --git a/app/verticals/inventory/shared/domain/inventory-opening-stock-and-open-obligations.ts b/app/verticals/inventory/shared/domain/inventory-opening-stock-and-open-obligations.ts new file mode 100644 index 000000000..2ddb2c8e2 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-opening-stock-and-open-obligations.ts @@ -0,0 +1,503 @@ +import { Match, Schema } from 'effect'; + +import { CatalogToStockBindingSchema } from './catalog-to-stock-binding.ts'; +import { ExternalStockCorrelationSchema } from './external-stock-correlation.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { + CommitmentProtectionInventoryEffectLedgerIntentSchema, + InventoryEffectLedgerRecordSchema, + ReservationCreateInventoryEffectLedgerIntentSchema, + ReservationReleaseInventoryEffectLedgerIntentSchema, +} from './inventory-effect-ledger.ts'; +import { + ImportedCommittedObligationSchema, + InventoryObligationSchema, + ProvisionalInventoryReservationSchema, +} from './inventory-obligation.ts'; +import { + DeterminateInventorySourceAssertionEvaluationSchema, + InventorySourceAssertionEvaluationSchema, +} from './inventory-source-assertion.ts'; +import { StockItemSchema } from './stock-item.ts'; +import { CurrentOnHandEvidenceSchema, StockPositionSchema } from './stock-position.ts'; + +const boundedReference = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const openingInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const ExternalOpeningStockSourceSchema = Schema.TaggedStruct('EXTERNAL_SOURCE_ASSERTION', { + evaluation: InventorySourceAssertionEvaluationSchema, + itemCorrelation: ExternalStockCorrelationSchema, + locationCorrelation: ExternalStockCorrelationSchema, +}); + +export const OntosWmsOpeningStockSourceSchema = Schema.TaggedStruct('ONTOS_WMS_OWNER_EVIDENCE', { + ownerEvidenceRef: boundedReference, +}); + +export const InventoryOpeningStockSourceSchema = Schema.Union([ + ExternalOpeningStockSourceSchema, + OntosWmsOpeningStockSourceSchema, +]); + +export const InventoryOpeningPositionFactSchema = Schema.Struct({ + position: StockPositionSchema, + source: InventoryOpeningStockSourceSchema, +}); +export type InventoryOpeningPositionFact = typeof InventoryOpeningPositionFactSchema.Type; + +const unresolvedLegacyHold = (tag: Tag) => + Schema.TaggedStruct(tag, { + observedAt: openingInstant, + reason: Schema.Literals(['NO_REAL_ATTEMPT', 'OWNER_OUTCOME_UNKNOWN']), + }); + +export const ActiveLegacyUncommittedHoldSchema = unresolvedLegacyHold('ACTIVE'); +export const PossiblyActiveLegacyUncommittedHoldSchema = unresolvedLegacyHold('POSSIBLY_ACTIVE'); +export const ResolvedLegacyUncommittedHoldSchema = Schema.TaggedStruct('RESOLVED', { + disposition: Schema.Literals(['DRAINED', 'EXPIRED', 'RELEASED', 'RECONCILED']), + ownerEvidenceRef: boundedReference, + resolvedAt: openingInstant, +}); + +export const LegacyUncommittedHoldFactSchema = Schema.Struct({ + customerConfigurationId: InventoryBackendConfigurationSchema.fields.customerConfigurationId, + holdReference: boundedReference, + state: Schema.Union([ + ActiveLegacyUncommittedHoldSchema, + PossiblyActiveLegacyUncommittedHoldSchema, + ResolvedLegacyUncommittedHoldSchema, + ]), + tenantId: InventoryBackendConfigurationSchema.fields.tenantId, +}); + +export const InventoryOpeningEvaluationInputSchema = Schema.Struct({ + bindings: Schema.Array(CatalogToStockBindingSchema), + effectLedger: Schema.Array(InventoryEffectLedgerRecordSchema), + evaluatedAt: openingInstant, + legacyUncommittedHolds: Schema.Array(LegacyUncommittedHoldFactSchema), + obligations: Schema.Array(InventoryObligationSchema), + selectedConfiguration: InventoryBackendConfigurationSchema, + stockItems: Schema.Array(StockItemSchema), + stockPositions: Schema.Array(InventoryOpeningPositionFactSchema), +}); +export type InventoryOpeningEvaluationInput = typeof InventoryOpeningEvaluationInputSchema.Type; + +const positionBlocker = (tag: Tag, fields: Fields) => + Schema.TaggedStruct(tag, { + positionRef: StockPositionSchema.fields.ref, + ...fields, + }); + +export const InventoryOpeningPositionNotCurrentBlockerSchema = positionBlocker('POSITION_NOT_CURRENT', {}); +export const InventoryOpeningPositionScopeMismatchBlockerSchema = positionBlocker('POSITION_SCOPE_MISMATCH', {}); +export const InventoryOpeningPositionOwnerMismatchBlockerSchema = positionBlocker('POSITION_OWNER_MISMATCH', {}); +export const InventoryOpeningStockItemNotCurrentBlockerSchema = positionBlocker('STOCK_ITEM_NOT_CURRENT', { + stockItemRef: StockItemSchema.fields.stockItemRef, +}); +export const InventoryOpeningBindingCoverageBlockerSchema = positionBlocker('BINDING_COVERAGE_INVALID', { + candidateCount: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), + stockItemRef: StockItemSchema.fields.stockItemRef, +}); +export const InventoryOpeningBindingMeaningBlockerSchema = positionBlocker('BINDING_MEANING_OR_UNIT_MISMATCH', { + bindingRef: CatalogToStockBindingSchema.fields.bindingRef, + stockItemRef: StockItemSchema.fields.stockItemRef, +}); +export const InventoryOpeningOnHandNotCurrentBlockerSchema = positionBlocker('ON_HAND_NOT_CURRENT', { + evidenceState: Schema.Literals(['UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE']), +}); +export const InventoryOpeningSourceKindMismatchBlockerSchema = positionBlocker('OPENING_SOURCE_KIND_MISMATCH', {}); +export const InventoryOpeningExternalSourceNotCurrentBlockerSchema = positionBlocker('EXTERNAL_SOURCE_NOT_CURRENT', { + sourceState: Schema.Literals(['HISTORICAL', 'INDETERMINATE']), +}); +export const InventoryOpeningExternalSourceScopeMismatchBlockerSchema = positionBlocker( + 'EXTERNAL_SOURCE_SCOPE_MISMATCH', + {}, +); +export const InventoryOpeningExternalCorrelationMismatchBlockerSchema = positionBlocker( + 'EXTERNAL_CORRELATION_MISMATCH', + {}, +); +export const InventoryOpeningPreCutoverReservationBlockerSchema = Schema.TaggedStruct( + 'PRE_CUTOVER_PROVISIONAL_RESERVATION', + { reservationRef: ProvisionalInventoryReservationSchema.fields.ref }, +); +export const InventoryOpeningUnresolvedEffectBlockerSchema = Schema.TaggedStruct('UNRESOLVED_RESERVATION_EFFECT', { + effectId: InventoryEffectLedgerRecordSchema.fields.effectId, + state: InventoryEffectLedgerRecordSchema.fields.currentState, +}); +export const InventoryOpeningLegacyHoldBlockerSchema = Schema.TaggedStruct('LEGACY_UNCOMMITTED_HOLD', { + holdReference: LegacyUncommittedHoldFactSchema.fields.holdReference, + state: Schema.Literals(['ACTIVE', 'POSSIBLY_ACTIVE']), +}); + +export const InventoryOpeningReadinessBlockerSchema = Schema.Union([ + InventoryOpeningPositionNotCurrentBlockerSchema, + InventoryOpeningPositionScopeMismatchBlockerSchema, + InventoryOpeningPositionOwnerMismatchBlockerSchema, + InventoryOpeningStockItemNotCurrentBlockerSchema, + InventoryOpeningBindingCoverageBlockerSchema, + InventoryOpeningBindingMeaningBlockerSchema, + InventoryOpeningOnHandNotCurrentBlockerSchema, + InventoryOpeningSourceKindMismatchBlockerSchema, + InventoryOpeningExternalSourceNotCurrentBlockerSchema, + InventoryOpeningExternalSourceScopeMismatchBlockerSchema, + InventoryOpeningExternalCorrelationMismatchBlockerSchema, + Schema.TaggedStruct('OBLIGATION_SCOPE_MISMATCH', { + obligationRef: Schema.Union([ + ProvisionalInventoryReservationSchema.fields.ref, + ImportedCommittedObligationSchema.fields.ref, + ]), + }), + InventoryOpeningPreCutoverReservationBlockerSchema, + InventoryOpeningUnresolvedEffectBlockerSchema, + InventoryOpeningLegacyHoldBlockerSchema, +]); +export type InventoryOpeningReadinessBlocker = typeof InventoryOpeningReadinessBlockerSchema.Type; + +export const InventoryOpeningPacketSchema = Schema.Struct({ + assembledAt: openingInstant, + obligations: Schema.Array(InventoryObligationSchema), + selectedConfiguration: InventoryBackendConfigurationSchema, + stock: Schema.Array( + Schema.Struct({ + binding: CatalogToStockBindingSchema, + item: StockItemSchema, + position: StockPositionSchema, + source: InventoryOpeningStockSourceSchema, + }), + ), +}); +export type InventoryOpeningPacket = typeof InventoryOpeningPacketSchema.Type; + +export const InventoryOpeningReadySchema = Schema.TaggedStruct('READY', { + packet: InventoryOpeningPacketSchema, +}); +export const InventoryOpeningNotReadySchema = Schema.TaggedStruct('NOT_READY', { + blockers: Schema.NonEmptyArray(InventoryOpeningReadinessBlockerSchema), + evaluatedFacts: InventoryOpeningEvaluationInputSchema, +}); +export const InventoryOpeningEvaluationResultSchema = Schema.Union([ + InventoryOpeningReadySchema, + InventoryOpeningNotReadySchema, +]); +export type InventoryOpeningEvaluationResult = typeof InventoryOpeningEvaluationResultSchema.Type; + +const sameRef = ( + left: { readonly resourceId: string; readonly tenantId: string }, + right: { readonly resourceId: string; readonly tenantId: string }, +) => left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +const sameUnit = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const selectedConfigurationRefMatches = ( + input: InventoryOpeningEvaluationInput, + position: InventoryOpeningPositionFact['position'], +) => + position.onHand.ownerConfigurationRef.resourceId === input.selectedConfiguration.configurationId && + position.onHand.ownerConfigurationRef.tenantId === input.selectedConfiguration.tenantId; + +const correlationMatchesAssertion = ( + correlation: typeof ExternalStockCorrelationSchema.Type, + expectedRef: (typeof ExternalStockCorrelationSchema.Type)['correlationRef'], + expectedKey: (typeof ExternalStockCorrelationSchema.Type)['externalKey'], + expectedTarget: (typeof ExternalStockCorrelationSchema.Type)['target'], +) => + sameRef(correlation.correlationRef, expectedRef) && + correlation.externalKey.customerConfigurationId === expectedKey.customerConfigurationId && + correlation.externalKey.externalScope === expectedKey.externalScope && + correlation.externalKey.externalValue === expectedKey.externalValue && + correlation.externalKey.identifierKind === expectedKey.identifierKind && + correlation.externalKey.issuer.backendId === expectedKey.issuer.backendId && + correlation.externalKey.issuer.backendKind === expectedKey.issuer.backendKind && + correlation.externalKey.namespace === expectedKey.namespace && + correlation.externalKey.tenantId === expectedKey.tenantId && + sameRef(correlation.target.ref, expectedTarget.ref); + +const positionScopeBlockers = ( + input: InventoryOpeningEvaluationInput, + position: InventoryOpeningPositionFact['position'], +): InventoryOpeningReadinessBlocker[] => { + const blockers: InventoryOpeningReadinessBlocker[] = []; + if (position.lifecycle !== 'CURRENT' || position.endedAt !== null) { + blockers.push({ _tag: 'POSITION_NOT_CURRENT', positionRef: position.ref }); + } + if ( + position.ref.tenantId !== input.selectedConfiguration.tenantId || + position.scope.customerConfigurationId !== input.selectedConfiguration.customerConfigurationId + ) { + blockers.push({ _tag: 'POSITION_SCOPE_MISMATCH', positionRef: position.ref }); + } + if (!selectedConfigurationRefMatches(input, position)) { + blockers.push({ _tag: 'POSITION_OWNER_MISMATCH', positionRef: position.ref }); + } + if (!Schema.is(CurrentOnHandEvidenceSchema)(position.onHand)) { + blockers.push({ + _tag: 'ON_HAND_NOT_CURRENT', + evidenceState: position.onHand._tag, + positionRef: position.ref, + }); + } + return blockers; +}; + +interface ItemAndBindingResult { + readonly binding: typeof CatalogToStockBindingSchema.Type | undefined; + readonly blockers: InventoryOpeningReadinessBlocker[]; + readonly item: typeof StockItemSchema.Type | undefined; +} + +const itemAndBindingResult = ( + input: InventoryOpeningEvaluationInput, + position: InventoryOpeningPositionFact['position'], +): ItemAndBindingResult => { + const blockers: InventoryOpeningReadinessBlocker[] = []; + const item = input.stockItems.find(({ stockItemRef }) => sameRef(stockItemRef, position.scope.stockItemRef)); + if (item === undefined || item.lifecycle !== 'CURRENT') { + blockers.push({ + _tag: 'STOCK_ITEM_NOT_CURRENT', + positionRef: position.ref, + stockItemRef: position.scope.stockItemRef, + }); + } + const bindings = input.bindings.filter(({ stockItemRef }) => sameRef(stockItemRef, position.scope.stockItemRef)); + const [binding] = bindings; + if (bindings.length !== 1 || binding === undefined) { + blockers.push({ + _tag: 'BINDING_COVERAGE_INVALID', + candidateCount: bindings.length, + positionRef: position.ref, + stockItemRef: position.scope.stockItemRef, + }); + } else if ( + item !== undefined && + (binding.exactSelectionMeaning.id !== item.exactSelectionMeaning.id || + binding.exactSelectionMeaning.kind !== item.exactSelectionMeaning.kind || + !sameUnit(binding.unitRef, item.unitRef) || + !sameUnit(binding.unitRef, position.scope.unitRef)) + ) { + blockers.push({ + _tag: 'BINDING_MEANING_OR_UNIT_MISMATCH', + bindingRef: binding.bindingRef, + positionRef: position.ref, + stockItemRef: position.scope.stockItemRef, + }); + } + return { binding, blockers, item }; +}; + +const externalAssertionScopeMatches = ( + input: InventoryOpeningEvaluationInput, + position: InventoryOpeningPositionFact['position'], + evaluation: typeof DeterminateInventorySourceAssertionEvaluationSchema.Type, +): boolean => { + const { assertion } = evaluation; + return ( + sameRef(assertion.positionRef, position.ref) && + assertion.customerConfigurationId === input.selectedConfiguration.customerConfigurationId && + assertion.authorityConfiguration.configurationId === input.selectedConfiguration.configurationId && + assertion.issuer.backendId === input.selectedConfiguration.selection.backendId && + assertion.issuer.backendKind === input.selectedConfiguration.selection.backend && + assertion.issuerAuthority === 'SELECTED_BACKEND' && + sameRef(assertion.stockItemRef, position.scope.stockItemRef) && + sameRef(assertion.stockLocationRef, position.scope.stockLocationRef) && + sameUnit(assertion.quantity.unitRef, position.scope.unitRef) && + Schema.is(CurrentOnHandEvidenceSchema)(position.onHand) && + assertion.ownerEvidenceRef === position.onHand.evidenceRef && + assertion.quantity.amount === position.onHand.quantity.amount + ); +}; + +const openingSourceBlockers = ( + input: InventoryOpeningEvaluationInput, + { position, source }: InventoryOpeningPositionFact, +): InventoryOpeningReadinessBlocker[] => { + const selectedExternal = input.selectedConfiguration.selection.backend === 'external_business_system'; + if ( + (selectedExternal && !Schema.is(ExternalOpeningStockSourceSchema)(source)) || + (!selectedExternal && !Schema.is(OntosWmsOpeningStockSourceSchema)(source)) + ) { + return [{ _tag: 'OPENING_SOURCE_KIND_MISMATCH', positionRef: position.ref }]; + } + if (Schema.is(ExternalOpeningStockSourceSchema)(source)) { + const { evaluation, itemCorrelation, locationCorrelation } = source; + if (!Schema.is(DeterminateInventorySourceAssertionEvaluationSchema)(evaluation)) { + return [ + { + _tag: 'EXTERNAL_SOURCE_NOT_CURRENT', + positionRef: position.ref, + sourceState: evaluation._tag, + }, + ]; + } + const blockers: InventoryOpeningReadinessBlocker[] = externalAssertionScopeMatches(input, position, evaluation) + ? [] + : [{ _tag: 'EXTERNAL_SOURCE_SCOPE_MISMATCH', positionRef: position.ref }]; + const { assertion } = evaluation; + if ( + !correlationMatchesAssertion(itemCorrelation, assertion.itemCorrelationRef, assertion.itemExternalKey, { + _tag: 'STOCK_ITEM', + ref: assertion.stockItemRef, + }) || + !correlationMatchesAssertion( + locationCorrelation, + assertion.locationCorrelationRef, + assertion.locationExternalKey, + { _tag: 'STOCK_LOCATION', ref: assertion.stockLocationRef }, + ) + ) { + blockers.push({ _tag: 'EXTERNAL_CORRELATION_MISMATCH', positionRef: position.ref }); + } + return blockers; + } + return Schema.is(CurrentOnHandEvidenceSchema)(position.onHand) && + source.ownerEvidenceRef !== position.onHand.evidenceRef + ? [{ _tag: 'EXTERNAL_SOURCE_SCOPE_MISMATCH', positionRef: position.ref }] + : []; +}; + +const positionBlockers = ( + input: InventoryOpeningEvaluationInput, + fact: InventoryOpeningPositionFact, +): { + readonly blockers: InventoryOpeningReadinessBlocker[]; + readonly stock?: InventoryOpeningPacket['stock'][number]; +} => { + const itemAndBinding = itemAndBindingResult(input, fact.position); + const blockers = [ + ...positionScopeBlockers(input, fact.position), + ...itemAndBinding.blockers, + ...openingSourceBlockers(input, fact), + ]; + return blockers.length === 0 && itemAndBinding.item !== undefined && itemAndBinding.binding !== undefined + ? { + blockers, + stock: { + binding: itemAndBinding.binding, + item: itemAndBinding.item, + position: fact.position, + source: fact.source, + }, + } + : { blockers }; +}; + +const obligationCustomerConfigurationId = (obligation: typeof InventoryObligationSchema.Type) => + obligation.authority.customerConfigurationId; + +const effectCustomerConfigurationId = (record: typeof InventoryEffectLedgerRecordSchema.Type) => + Match.value(record.intent).pipe( + Match.tag('RESERVATION_CREATE', ({ request }) => request.authority.customerConfigurationId), + Match.tag('RESERVATION_RELEASE', ({ request }) => request.reservation.authority.customerConfigurationId), + Match.tag( + 'ESTABLISH_COMMITMENT_PROTECTION', + ({ request }) => request.confirmation.reservation.authority.customerConfigurationId, + ), + Match.tag('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', ({ request }) => request.customerConfigurationId), + Match.exhaustive, + ); + +const isUnresolvedReservationEffect = (record: typeof InventoryEffectLedgerRecordSchema.Type) => + (Schema.is(ReservationCreateInventoryEffectLedgerIntentSchema)(record.intent) || + Schema.is(ReservationReleaseInventoryEffectLedgerIntentSchema)(record.intent) || + Schema.is(CommitmentProtectionInventoryEffectLedgerIntentSchema)(record.intent)) && + (record.currentState === 'REQUESTED' || record.currentState === 'INDETERMINATE'); + +/** + * Builds no new business fact: it only verifies and packages exact owner facts already persisted + * by Inventory. A NOT_READY result retains those facts verbatim so unknown or indeterminate + * evidence can never be collapsed into numeric zero or guessed Availability. + */ +export const evaluateInventoryOpeningPacket = ( + input: InventoryOpeningEvaluationInput, +): InventoryOpeningEvaluationResult => { + const blockers: InventoryOpeningReadinessBlocker[] = []; + const stock: InventoryOpeningPacket['stock'][number][] = []; + for (const fact of input.stockPositions) { + const result = positionBlockers(input, fact); + blockers.push(...result.blockers); + if (result.stock !== undefined) { + stock.push(result.stock); + } + } + + for (const obligation of input.obligations) { + if ( + String(obligation.ref.tenantId) !== String(input.selectedConfiguration.tenantId) || + obligationCustomerConfigurationId(obligation) !== input.selectedConfiguration.customerConfigurationId + ) { + blockers.push({ _tag: 'OBLIGATION_SCOPE_MISMATCH', obligationRef: obligation.ref }); + continue; + } + if ( + Schema.is(ProvisionalInventoryReservationSchema)(obligation) && + (obligation.authority.configurationId !== input.selectedConfiguration.configurationId || + obligation.authority.selection.backendId !== input.selectedConfiguration.selection.backendId || + obligation.authority.selection.backend !== input.selectedConfiguration.selection.backend) + ) { + blockers.push({ _tag: 'PRE_CUTOVER_PROVISIONAL_RESERVATION', reservationRef: obligation.ref }); + } + } + + for (const record of input.effectLedger) { + if ( + record.tenantId === input.selectedConfiguration.tenantId && + effectCustomerConfigurationId(record) === input.selectedConfiguration.customerConfigurationId && + isUnresolvedReservationEffect(record) + ) { + blockers.push({ + _tag: 'UNRESOLVED_RESERVATION_EFFECT', + effectId: record.effectId, + state: record.currentState, + }); + } + } + + for (const hold of input.legacyUncommittedHolds) { + if ( + hold.tenantId === input.selectedConfiguration.tenantId && + hold.customerConfigurationId === input.selectedConfiguration.customerConfigurationId && + !Schema.is(ResolvedLegacyUncommittedHoldSchema)(hold.state) + ) { + blockers.push({ + _tag: 'LEGACY_UNCOMMITTED_HOLD', + holdReference: hold.holdReference, + state: hold.state._tag, + }); + } + } + + const [firstBlocker, ...remainingBlockers] = blockers; + if (firstBlocker !== undefined) { + return { + _tag: 'NOT_READY', + blockers: [firstBlocker, ...remainingBlockers], + evaluatedFacts: input, + }; + } + return { + _tag: 'READY', + packet: { + assembledAt: input.evaluatedAt, + obligations: input.obligations, + selectedConfiguration: input.selectedConfiguration, + stock, + }, + }; +}; diff --git a/app/verticals/inventory/shared/domain/inventory-operator-recovery.ts b/app/verticals/inventory/shared/domain/inventory-operator-recovery.ts new file mode 100644 index 000000000..dcf990d3f --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-operator-recovery.ts @@ -0,0 +1,1030 @@ +import { Match, Schema } from 'effect'; + +import { CatalogStockDemandSchema } from './catalog-to-stock-binding.ts'; +import type { CatalogStockDemand } from './catalog-to-stock-binding.ts'; +import { CatalogToStockBindingResolutionFailure } from './catalog-to-stock-binding-resolution.ts'; +import { InventoryBackendCutoverBlockerSchema } from './inventory-backend-cutover.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import type { InventoryBackendConfiguration } from './inventory-backend-configuration.ts'; +import { ExternalStockKeySchema } from './external-stock-correlation.ts'; +import { + IndeterminateInventorySourceAssertionEvaluationSchema, + InventorySourceAssertionSchema, +} from './inventory-source-assertion.ts'; +import { + IndeterminateReservationCreateEffectSchema, + InventoryReservationCreateRequestSchema, + ReconciliationRequiredReservationCreateEffectSchema, + ReservationCreateAllocationSchema, +} from './inventory-reservation-create.ts'; +import { PhysicalStockEffectIdSchema } from './physical-stock-effect.ts'; +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; +import { StockQuantitySchema, compareExactStockQuantityAmounts } from './stock-position.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { CommitmentProtectionRefSchema } from '../resources/commitment-protection.ts'; +import { ImportedCommittedObligationRefSchema } from '../resources/imported-committed-obligation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +export const inventoryOperationalProblemKinds = [ + 'BACKEND_CONFIGURATION_INVALID', + 'BACKEND_CONFIGURATION_MISMATCH', + 'STOCK_EVIDENCE_STALE', + 'STOCK_EVIDENCE_MISSING', + 'STOCK_EVIDENCE_INDETERMINATE', + 'STOCK_EVIDENCE_CONFLICTING', + 'STOCK_CORRECTION_EVIDENCE_REQUIRED', + 'BINDING_MISSING', + 'BINDING_CONFLICTING', + 'BINDING_INCOMPATIBLE', + 'EXTERNAL_ITEM_CORRELATION_UNRESOLVED', + 'EXTERNAL_ITEM_CORRELATION_AMBIGUOUS', + 'EXTERNAL_LOCATION_CORRELATION_UNRESOLVED', + 'EXTERNAL_LOCATION_CORRELATION_AMBIGUOUS', + 'INVALID_QUANTITY', + 'INCOMPATIBLE_UNIT', + 'SOURCE_COVERAGE_UNCERTAIN', + 'CONFIRMATION_AT_RISK', + 'CONFIRMATION_REVOKED', + 'CONFIRMATION_EXPIRED', + 'CONFIRMATION_UNVERIFIABLE', + 'PROTECTION_AT_RISK', + 'PROTECTION_PROTECTED', + 'PROTECTION_LATE_ESTABLISHMENT_PROVEN', + 'PROTECTION_ESTABLISHMENT_INDETERMINATE', + 'CREATE_INDETERMINATE', + 'RELEASE_INDETERMINATE', + 'PHYSICAL_MUTATION_INDETERMINATE', + 'PARTIAL_CREATE_HOLD', + 'POSSIBLE_PARTIAL_CREATE_HOLD', + 'PRE_COMMIT_COMPENSATION_DEBT', + 'POST_COMMIT_OBLIGATION_DEBT', + 'IMPORTED_COMMITTED_ORIGIN', + 'UNRESOLVED_LEGACY_HOLD', + 'CUTOVER_BLOCKER', +] as const; + +export const InventoryOperationalProblemKindSchema = Schema.Literals(inventoryOperationalProblemKinds); +export type InventoryOperationalProblemKind = typeof InventoryOperationalProblemKindSchema.Type; + +export const InventoryOperationalActualOwnerSchema = Schema.Literals([ + 'CATALOG_TO_STOCK_BINDING_OWNER', + 'INVENTORY_CONFIGURATION_OWNER', + 'INVENTORY_INPUT_BOUNDARY', + 'INVENTORY_OBLIGATION_OWNER', + 'ORIGINAL_RESERVATION_AUTHORITY', + 'SELECTED_INVENTORY_BACKEND', +]); + +export const InventoryOperationalSafeNextActionSchema = Schema.Literals([ + 'ACQUIRE_OWNER_EVIDENCE', + 'BLOCK_AND_ESCALATE', + 'CORRECT_WITH_CURRENT_OWNER_EVIDENCE', + 'RECOVER_ORIGINAL_EFFECT', + 'RECONCILE', + 'RECONCILE_SOURCE_COVERAGE', + 'RECONCILE_WITHOUT_RELEASE', + 'REPAIR_CONFIGURATION', + 'REPAIR_CORRELATION', + 'REPAIR_INPUT', + 'REPAIR_OBLIGATION_WITHOUT_ORDER_ROLLBACK', + 'RESOLVE_CUTOVER_BLOCKERS', + 'RESOLVE_LEGACY_HOLD', + 'RESOLVE_PRE_COMMIT_DEBT', + 'RUN_BINDING_OWNER_LIFECYCLE', + 'PRESERVE_PROTECTION_FENCE', + 'START_NEW_ATTEMPT_AFTER_SAFE_PREDECESSOR_RESOLUTION', +]); + +export const InventoryOperationalProhibitedActionSchema = Schema.Literals([ + 'BACKEND_SWITCH_AS_RECOVERY', + 'INFER_STOCK_ITEM', + 'MANUAL_ON_HAND_ARITHMETIC', + 'PRIVATE_OWNER_MUTATION', + 'RELEASE_AT_RISK_PROTECTION', + 'REPLAY_UNRESOLVED_EFFECT_AS_FRESH', + 'RETARGET_COMMITTED_OBLIGATION', + 'REUSE_UNRESOLVED_HOLD', + 'ROLLBACK_COMMITTED_ORDER', +]); + +export const InventoryOperationalRecoveryPolicySchema = Schema.Struct({ + actualOwner: InventoryOperationalActualOwnerSchema, + backendSwitchingAllowed: Schema.Literal(false), + impact: Schema.Literals([ + 'BLOCKS_CUTOVER', + 'BLOCKS_READINESS', + 'BLOCKS_STOCK_TRUTH', + 'PRESERVES_COMMITTED_OBLIGATION', + 'PRESERVES_EXACT_CONSTRAINED_EFFECT', + 'PRESERVES_PROTECTION_FENCE', + 'PRESERVES_POSSIBLE_PROTECTION_FENCE', + 'PRESERVES_POSSIBLE_STOCK_EFFECT', + 'REQUIRES_INPUT_REPAIR', + ]), + permissionTransfersFactOwnership: Schema.Literal(false), + prohibitedActions: Schema.Array(InventoryOperationalProhibitedActionSchema).check(Schema.isMinLength(1)), + supportedSafeNextAction: InventoryOperationalSafeNextActionSchema, + truth: Schema.Literals(['PROVEN', 'UNKNOWN']), + unresolvedEffectMayBeReplayedAsFresh: Schema.Literal(false), +}); +export type InventoryOperationalRecoveryPolicy = typeof InventoryOperationalRecoveryPolicySchema.Type; + +const universalProhibitions = [ + 'BACKEND_SWITCH_AS_RECOVERY', + 'PRIVATE_OWNER_MUTATION', + 'REPLAY_UNRESOLVED_EFFECT_AS_FRESH', +] as const; + +const policy = ( + actualOwner: InventoryOperationalRecoveryPolicy['actualOwner'], + truth: InventoryOperationalRecoveryPolicy['truth'], + impact: InventoryOperationalRecoveryPolicy['impact'], + supportedSafeNextAction: InventoryOperationalRecoveryPolicy['supportedSafeNextAction'], + additionalProhibitions: readonly (typeof InventoryOperationalProhibitedActionSchema.Type)[] = [], +): InventoryOperationalRecoveryPolicy => ({ + actualOwner, + backendSwitchingAllowed: false, + impact, + permissionTransfersFactOwnership: false, + prohibitedActions: [...universalProhibitions, ...additionalProhibitions], + supportedSafeNextAction, + truth, + unresolvedEffectMayBeReplayedAsFresh: false, +}); + +const configurationPolicy = policy( + 'INVENTORY_CONFIGURATION_OWNER', + 'PROVEN', + 'BLOCKS_READINESS', + 'REPAIR_CONFIGURATION', +); +const uncertainEvidencePolicy = policy( + 'SELECTED_INVENTORY_BACKEND', + 'UNKNOWN', + 'BLOCKS_STOCK_TRUTH', + 'ACQUIRE_OWNER_EVIDENCE', + ['MANUAL_ON_HAND_ARITHMETIC'], +); +const bindingPolicy = policy( + 'CATALOG_TO_STOCK_BINDING_OWNER', + 'PROVEN', + 'BLOCKS_READINESS', + 'RUN_BINDING_OWNER_LIFECYCLE', + ['INFER_STOCK_ITEM'], +); +const correlationPolicy = policy('SELECTED_INVENTORY_BACKEND', 'UNKNOWN', 'BLOCKS_STOCK_TRUTH', 'REPAIR_CORRELATION'); +const inputPolicy = policy('INVENTORY_INPUT_BOUNDARY', 'PROVEN', 'REQUIRES_INPUT_REPAIR', 'REPAIR_INPUT'); +const effectPolicy = policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'UNKNOWN', + 'PRESERVES_POSSIBLE_STOCK_EFFECT', + 'RECOVER_ORIGINAL_EFFECT', + ['REUSE_UNRESOLVED_HOLD'], +); +const physicalEffectPolicy = policy( + 'SELECTED_INVENTORY_BACKEND', + 'UNKNOWN', + 'PRESERVES_POSSIBLE_STOCK_EFFECT', + 'RECOVER_ORIGINAL_EFFECT', + ['MANUAL_ON_HAND_ARITHMETIC', 'REUSE_UNRESOLVED_HOLD'], +); +const terminalConfirmationPolicy = policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'PROVEN', + 'BLOCKS_READINESS', + 'START_NEW_ATTEMPT_AFTER_SAFE_PREDECESSOR_RESOLUTION', + ['RELEASE_AT_RISK_PROTECTION', 'REUSE_UNRESOLVED_HOLD'], +); +const protectionAtRiskPolicy = policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'PROVEN', + 'PRESERVES_POSSIBLE_STOCK_EFFECT', + 'RECONCILE_WITHOUT_RELEASE', + ['RELEASE_AT_RISK_PROTECTION'], +); +const protectionFencePolicy = policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'PROVEN', + 'PRESERVES_PROTECTION_FENCE', + 'PRESERVE_PROTECTION_FENCE', + ['RELEASE_AT_RISK_PROTECTION'], +); +const indeterminateProtectionPolicy = policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'UNKNOWN', + 'PRESERVES_POSSIBLE_PROTECTION_FENCE', + 'RECOVER_ORIGINAL_EFFECT', + ['RELEASE_AT_RISK_PROTECTION', 'REUSE_UNRESOLVED_HOLD'], +); +const provenPartialCreatePolicy = policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'PROVEN', + 'PRESERVES_EXACT_CONSTRAINED_EFFECT', + 'RESOLVE_PRE_COMMIT_DEBT', + ['REUSE_UNRESOLVED_HOLD'], +); +const committedObligationPolicy = policy( + 'INVENTORY_OBLIGATION_OWNER', + 'PROVEN', + 'PRESERVES_COMMITTED_OBLIGATION', + 'REPAIR_OBLIGATION_WITHOUT_ORDER_ROLLBACK', + ['RETARGET_COMMITTED_OBLIGATION', 'ROLLBACK_COMMITTED_ORDER'], +); + +const policies = { + BACKEND_CONFIGURATION_INVALID: configurationPolicy, + BACKEND_CONFIGURATION_MISMATCH: configurationPolicy, + BINDING_CONFLICTING: bindingPolicy, + BINDING_INCOMPATIBLE: bindingPolicy, + BINDING_MISSING: bindingPolicy, + CONFIRMATION_AT_RISK: policy('ORIGINAL_RESERVATION_AUTHORITY', 'PROVEN', 'BLOCKS_READINESS', 'RECONCILE'), + CONFIRMATION_EXPIRED: terminalConfirmationPolicy, + CONFIRMATION_REVOKED: terminalConfirmationPolicy, + CONFIRMATION_UNVERIFIABLE: policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'UNKNOWN', + 'BLOCKS_READINESS', + 'ACQUIRE_OWNER_EVIDENCE', + ), + CREATE_INDETERMINATE: effectPolicy, + CUTOVER_BLOCKER: policy('INVENTORY_CONFIGURATION_OWNER', 'PROVEN', 'BLOCKS_CUTOVER', 'RESOLVE_CUTOVER_BLOCKERS'), + EXTERNAL_ITEM_CORRELATION_AMBIGUOUS: correlationPolicy, + EXTERNAL_ITEM_CORRELATION_UNRESOLVED: correlationPolicy, + EXTERNAL_LOCATION_CORRELATION_AMBIGUOUS: correlationPolicy, + EXTERNAL_LOCATION_CORRELATION_UNRESOLVED: correlationPolicy, + IMPORTED_COMMITTED_ORIGIN: policy( + 'INVENTORY_OBLIGATION_OWNER', + 'PROVEN', + 'PRESERVES_COMMITTED_OBLIGATION', + 'RECONCILE', + ['RETARGET_COMMITTED_OBLIGATION', 'ROLLBACK_COMMITTED_ORDER'], + ), + INCOMPATIBLE_UNIT: inputPolicy, + INVALID_QUANTITY: inputPolicy, + PARTIAL_CREATE_HOLD: provenPartialCreatePolicy, + PHYSICAL_MUTATION_INDETERMINATE: physicalEffectPolicy, + POSSIBLE_PARTIAL_CREATE_HOLD: effectPolicy, + POST_COMMIT_OBLIGATION_DEBT: committedObligationPolicy, + PRE_COMMIT_COMPENSATION_DEBT: policy( + 'ORIGINAL_RESERVATION_AUTHORITY', + 'UNKNOWN', + 'PRESERVES_POSSIBLE_STOCK_EFFECT', + 'RESOLVE_PRE_COMMIT_DEBT', + ['REUSE_UNRESOLVED_HOLD'], + ), + PROTECTION_AT_RISK: protectionAtRiskPolicy, + PROTECTION_ESTABLISHMENT_INDETERMINATE: indeterminateProtectionPolicy, + PROTECTION_LATE_ESTABLISHMENT_PROVEN: protectionFencePolicy, + PROTECTION_PROTECTED: protectionFencePolicy, + RELEASE_INDETERMINATE: effectPolicy, + SOURCE_COVERAGE_UNCERTAIN: policy( + 'SELECTED_INVENTORY_BACKEND', + 'UNKNOWN', + 'BLOCKS_STOCK_TRUTH', + 'RECONCILE_SOURCE_COVERAGE', + ['MANUAL_ON_HAND_ARITHMETIC'], + ), + STOCK_CORRECTION_EVIDENCE_REQUIRED: policy( + 'SELECTED_INVENTORY_BACKEND', + 'UNKNOWN', + 'BLOCKS_STOCK_TRUTH', + 'CORRECT_WITH_CURRENT_OWNER_EVIDENCE', + ['MANUAL_ON_HAND_ARITHMETIC'], + ), + STOCK_EVIDENCE_CONFLICTING: policy('SELECTED_INVENTORY_BACKEND', 'PROVEN', 'BLOCKS_STOCK_TRUTH', 'RECONCILE', [ + 'MANUAL_ON_HAND_ARITHMETIC', + ]), + STOCK_EVIDENCE_INDETERMINATE: uncertainEvidencePolicy, + STOCK_EVIDENCE_MISSING: uncertainEvidencePolicy, + STOCK_EVIDENCE_STALE: uncertainEvidencePolicy, + UNRESOLVED_LEGACY_HOLD: policy( + 'INVENTORY_OBLIGATION_OWNER', + 'UNKNOWN', + 'PRESERVES_POSSIBLE_STOCK_EFFECT', + 'RESOLVE_LEGACY_HOLD', + ['REUSE_UNRESOLVED_HOLD'], + ), +} satisfies Record; + +export const inventoryOperationalPolicyFor = ( + problem: InventoryOperationalProblemKind, +): InventoryOperationalRecoveryPolicy => policies[problem]; + +const samePolicy = (left: InventoryOperationalRecoveryPolicy, right: InventoryOperationalRecoveryPolicy): boolean => + left.actualOwner === right.actualOwner && + left.backendSwitchingAllowed === right.backendSwitchingAllowed && + left.impact === right.impact && + left.permissionTransfersFactOwnership === right.permissionTransfersFactOwnership && + left.supportedSafeNextAction === right.supportedSafeNextAction && + left.truth === right.truth && + left.unresolvedEffectMayBeReplayedAsFresh === right.unresolvedEffectMayBeReplayedAsFresh && + left.prohibitedActions.length === right.prohibitedActions.length && + left.prohibitedActions.every((action, index) => action === right.prohibitedActions[index]); + +const sameTenantId = (left: string, right: string): boolean => left === right; +const sameResourceRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +): boolean => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + sameTenantId(left.tenantId, right.tenantId); + +const sameBackendConfiguration = (left: InventoryBackendConfiguration, right: InventoryBackendConfiguration): boolean => + left.configurationId === right.configurationId && + left.customerConfigurationId === right.customerConfigurationId && + left.revision === right.revision && + left.selectedAt === right.selectedAt && + sameTenantId(left.tenantId, right.tenantId) && + left.selection.backend === right.selection.backend && + left.selection.backendId === right.selection.backendId && + left.selection.exactReservationCapability === right.selection.exactReservationCapability && + left.selection.stockCorrectionCapability === right.selection.stockCorrectionCapability; + +const boundedOperationalReference = Schema.String.check( + Schema.isTrimmed(), + Schema.isMinLength(1), + Schema.isMaxLength(300), +); +const operationalSubjectScope = { + customerConfigurationId: InventoryBackendConfigurationSchema.fields.customerConfigurationId, + tenantId: InventoryBackendConfigurationSchema.fields.tenantId, +} as const; + +export const InventoryOperationalSubjectSchema = Schema.Union([ + Schema.TaggedStruct('BACKEND_CONFIGURATION', { + ...operationalSubjectScope, + configurationId: InventoryBackendConfigurationSchema.fields.configurationId, + }), + Schema.TaggedStruct('CATALOG_DEMAND', { ...operationalSubjectScope, demand: CatalogStockDemandSchema }), + Schema.TaggedStruct('COMMITTED_OBLIGATION', { + ...operationalSubjectScope, + obligationRef: Schema.Union([InventoryReservationRefSchema, ImportedCommittedObligationRefSchema]), + }), + Schema.TaggedStruct('CONFIRMATION', { + ...operationalSubjectScope, + attemptId: OrderCommitmentAttemptIdSchema, + confirmationRef: ReservationConfirmationRefSchema, + }), + Schema.TaggedStruct('CUTOVER', { + ...operationalSubjectScope, + blocker: InventoryBackendCutoverBlockerSchema, + evaluatedAt: Schema.toEncoded(Schema.DateTimeUtcFromString), + postCutoverConfigurationId: InventoryBackendConfigurationSchema.fields.configurationId, + preCutoverConfigurationId: InventoryBackendConfigurationSchema.fields.configurationId, + }), + Schema.TaggedStruct('DEMAND_INPUT', { ...operationalSubjectScope, demand: CatalogStockDemandSchema }), + Schema.TaggedStruct('EXTERNAL_CORRELATION', { + ...operationalSubjectScope, + externalKey: ExternalStockKeySchema, + resolution: Schema.Literals(['AMBIGUOUS', 'UNRESOLVED']), + }), + Schema.TaggedStruct('IMPORTED_OBLIGATION', { + ...operationalSubjectScope, + obligationRef: ImportedCommittedObligationRefSchema, + }), + Schema.TaggedStruct('LEGACY_HOLD', { + ...operationalSubjectScope, + holdReference: boundedOperationalReference, + }), + Schema.TaggedStruct('PHYSICAL_EFFECT', { + ...operationalSubjectScope, + effectId: PhysicalStockEffectIdSchema, + positionRef: StockPositionRefSchema, + }), + Schema.TaggedStruct('PROTECTION', { + ...operationalSubjectScope, + attemptId: OrderCommitmentAttemptIdSchema, + effectId: ReservationAuthorityEffectIdSchema, + fence: Schema.Literals(['ACTIVE', 'AT_RISK', 'PRESERVE_POSSIBLE_PROTECTION_FENCE']), + protectionRef: CommitmentProtectionRefSchema, + }), + Schema.TaggedStruct('RESERVATION_EFFECT', { + ...operationalSubjectScope, + attemptId: OrderCommitmentAttemptIdSchema, + effectId: ReservationAuthorityEffectIdSchema, + reservationRef: InventoryReservationRefSchema, + }), + Schema.TaggedStruct('SOURCE_ASSERTION', { + ...operationalSubjectScope, + assertionId: InventorySourceAssertionSchema.fields.assertionId, + materialEffectIds: Schema.Array(PhysicalStockEffectIdSchema), + positionRef: StockPositionRefSchema, + }), + Schema.TaggedStruct('STOCK_POSITION', { + ...operationalSubjectScope, + positionRef: StockPositionRefSchema, + }), +]); +export type InventoryOperationalSubject = typeof InventoryOperationalSubjectSchema.Type; + +export const InventoryOperationalOwnerIdentitySchema = Schema.Union([ + Schema.TaggedStruct('CATALOG_TO_STOCK_BINDING_OWNER', { + ...operationalSubjectScope, + ownerAuthority: Schema.Literal('INVENTORY_BINDING_OWNER'), + }), + Schema.TaggedStruct('INVENTORY_CONFIGURATION_OWNER', { + ...operationalSubjectScope, + configurationId: InventoryBackendConfigurationSchema.fields.configurationId, + }), + Schema.TaggedStruct('INVENTORY_INPUT_BOUNDARY', { + ...operationalSubjectScope, + boundary: Schema.Literal('INVENTORY_PUBLIC_INPUT'), + }), + Schema.TaggedStruct('INVENTORY_OBLIGATION_OWNER', { + ...operationalSubjectScope, + ownerModuleId: Schema.Literal('commerce.inventory'), + }), + Schema.TaggedStruct('ORIGINAL_RESERVATION_AUTHORITY', { + ...operationalSubjectScope, + backend: InventoryBackendConfigurationSchema.fields.selection.fields.backend, + backendId: InventoryBackendConfigurationSchema.fields.selection.fields.backendId, + configurationId: InventoryBackendConfigurationSchema.fields.configurationId, + }), + Schema.TaggedStruct('SELECTED_INVENTORY_BACKEND', { + ...operationalSubjectScope, + backend: InventoryBackendConfigurationSchema.fields.selection.fields.backend, + backendId: InventoryBackendConfigurationSchema.fields.selection.fields.backendId, + configurationId: InventoryBackendConfigurationSchema.fields.configurationId, + }), +]); +export type InventoryOperationalOwnerIdentity = typeof InventoryOperationalOwnerIdentitySchema.Type; + +export const inventoryOperationalSubjectTags = [ + 'BACKEND_CONFIGURATION', + 'CATALOG_DEMAND', + 'COMMITTED_OBLIGATION', + 'CONFIRMATION', + 'CUTOVER', + 'DEMAND_INPUT', + 'EXTERNAL_CORRELATION', + 'IMPORTED_OBLIGATION', + 'LEGACY_HOLD', + 'PHYSICAL_EFFECT', + 'PROTECTION', + 'RESERVATION_EFFECT', + 'SOURCE_ASSERTION', + 'STOCK_POSITION', +] as const; +export type InventoryOperationalSubjectTag = (typeof inventoryOperationalSubjectTags)[number]; + +const subjectTags = { + BACKEND_CONFIGURATION_INVALID: 'BACKEND_CONFIGURATION', + BACKEND_CONFIGURATION_MISMATCH: 'BACKEND_CONFIGURATION', + BINDING_CONFLICTING: 'CATALOG_DEMAND', + BINDING_INCOMPATIBLE: 'CATALOG_DEMAND', + BINDING_MISSING: 'CATALOG_DEMAND', + CONFIRMATION_AT_RISK: 'CONFIRMATION', + CONFIRMATION_EXPIRED: 'CONFIRMATION', + CONFIRMATION_REVOKED: 'CONFIRMATION', + CONFIRMATION_UNVERIFIABLE: 'CONFIRMATION', + CREATE_INDETERMINATE: 'RESERVATION_EFFECT', + CUTOVER_BLOCKER: 'CUTOVER', + EXTERNAL_ITEM_CORRELATION_AMBIGUOUS: 'EXTERNAL_CORRELATION', + EXTERNAL_ITEM_CORRELATION_UNRESOLVED: 'EXTERNAL_CORRELATION', + EXTERNAL_LOCATION_CORRELATION_AMBIGUOUS: 'EXTERNAL_CORRELATION', + EXTERNAL_LOCATION_CORRELATION_UNRESOLVED: 'EXTERNAL_CORRELATION', + IMPORTED_COMMITTED_ORIGIN: 'IMPORTED_OBLIGATION', + INCOMPATIBLE_UNIT: 'DEMAND_INPUT', + INVALID_QUANTITY: 'DEMAND_INPUT', + PARTIAL_CREATE_HOLD: 'RESERVATION_EFFECT', + PHYSICAL_MUTATION_INDETERMINATE: 'PHYSICAL_EFFECT', + POSSIBLE_PARTIAL_CREATE_HOLD: 'RESERVATION_EFFECT', + POST_COMMIT_OBLIGATION_DEBT: 'COMMITTED_OBLIGATION', + PRE_COMMIT_COMPENSATION_DEBT: 'RESERVATION_EFFECT', + PROTECTION_AT_RISK: 'PROTECTION', + PROTECTION_ESTABLISHMENT_INDETERMINATE: 'PROTECTION', + PROTECTION_LATE_ESTABLISHMENT_PROVEN: 'PROTECTION', + PROTECTION_PROTECTED: 'PROTECTION', + RELEASE_INDETERMINATE: 'RESERVATION_EFFECT', + SOURCE_COVERAGE_UNCERTAIN: 'SOURCE_ASSERTION', + STOCK_CORRECTION_EVIDENCE_REQUIRED: 'STOCK_POSITION', + STOCK_EVIDENCE_CONFLICTING: 'STOCK_POSITION', + STOCK_EVIDENCE_INDETERMINATE: 'STOCK_POSITION', + STOCK_EVIDENCE_MISSING: 'STOCK_POSITION', + STOCK_EVIDENCE_STALE: 'STOCK_POSITION', + UNRESOLVED_LEGACY_HOLD: 'LEGACY_HOLD', +} satisfies Record; + +export const inventoryOperationalSubjectTagFor = ( + problem: InventoryOperationalProblemKind, +): InventoryOperationalSubjectTag => subjectTags[problem]; + +const ownerIdentityFor = ( + actualOwner: InventoryOperationalRecoveryPolicy['actualOwner'], + authority: InventoryBackendConfiguration, +): InventoryOperationalOwnerIdentity => { + const scope = { customerConfigurationId: authority.customerConfigurationId, tenantId: authority.tenantId }; + return Match.value(actualOwner).pipe( + Match.when('CATALOG_TO_STOCK_BINDING_OWNER', () => ({ + _tag: 'CATALOG_TO_STOCK_BINDING_OWNER' as const, + ...scope, + ownerAuthority: 'INVENTORY_BINDING_OWNER' as const, + })), + Match.when('INVENTORY_CONFIGURATION_OWNER', () => ({ + _tag: 'INVENTORY_CONFIGURATION_OWNER' as const, + ...scope, + configurationId: authority.configurationId, + })), + Match.when('INVENTORY_INPUT_BOUNDARY', () => ({ + _tag: 'INVENTORY_INPUT_BOUNDARY' as const, + ...scope, + boundary: 'INVENTORY_PUBLIC_INPUT' as const, + })), + Match.when('INVENTORY_OBLIGATION_OWNER', () => ({ + _tag: 'INVENTORY_OBLIGATION_OWNER' as const, + ...scope, + ownerModuleId: 'commerce.inventory' as const, + })), + Match.when('ORIGINAL_RESERVATION_AUTHORITY', () => ({ + _tag: 'ORIGINAL_RESERVATION_AUTHORITY' as const, + ...scope, + backend: authority.selection.backend, + backendId: authority.selection.backendId, + configurationId: authority.configurationId, + })), + Match.when('SELECTED_INVENTORY_BACKEND', () => ({ + _tag: 'SELECTED_INVENTORY_BACKEND' as const, + ...scope, + backend: authority.selection.backend, + backendId: authority.selection.backendId, + configurationId: authority.configurationId, + })), + Match.exhaustive, + ); +}; + +const ownerIdentityKey = (identity: InventoryOperationalOwnerIdentity): string => + Match.value(identity).pipe( + Match.tag('CATALOG_TO_STOCK_BINDING_OWNER', ({ customerConfigurationId, ownerAuthority, tenantId }) => + [customerConfigurationId, ownerAuthority, tenantId].join('|'), + ), + Match.tag('INVENTORY_CONFIGURATION_OWNER', ({ configurationId, customerConfigurationId, tenantId }) => + [configurationId, customerConfigurationId, tenantId].join('|'), + ), + Match.tag('INVENTORY_INPUT_BOUNDARY', ({ boundary, customerConfigurationId, tenantId }) => + [boundary, customerConfigurationId, tenantId].join('|'), + ), + Match.tag('INVENTORY_OBLIGATION_OWNER', ({ customerConfigurationId, ownerModuleId, tenantId }) => + [customerConfigurationId, ownerModuleId, tenantId].join('|'), + ), + Match.tag( + 'ORIGINAL_RESERVATION_AUTHORITY', + ({ backend, backendId, configurationId, customerConfigurationId, tenantId }) => + [backend, backendId, configurationId, customerConfigurationId, tenantId].join('|'), + ), + Match.tag( + 'SELECTED_INVENTORY_BACKEND', + ({ backend, backendId, configurationId, customerConfigurationId, tenantId }) => + [backend, backendId, configurationId, customerConfigurationId, tenantId].join('|'), + ), + Match.exhaustive, + ); +const ownerIdentityMatches = ( + left: InventoryOperationalOwnerIdentity, + right: InventoryOperationalOwnerIdentity, +): boolean => ownerIdentityKey(left) === ownerIdentityKey(right); + +const subjectRefTenantMatches = (subject: InventoryOperationalSubject): boolean => + Match.value(subject).pipe( + Match.tag('BACKEND_CONFIGURATION', () => true), + Match.tag('CATALOG_DEMAND', ({ demand, tenantId }) => + sameTenantId(demand.catalogSelection.productRef.tenantId, tenantId), + ), + Match.tag('COMMITTED_OBLIGATION', ({ obligationRef, tenantId }) => sameTenantId(obligationRef.tenantId, tenantId)), + Match.tag('CONFIRMATION', ({ confirmationRef, tenantId }) => sameTenantId(confirmationRef.tenantId, tenantId)), + Match.tag('CUTOVER', () => true), + Match.tag('DEMAND_INPUT', ({ demand, tenantId }) => + sameTenantId(demand.catalogSelection.productRef.tenantId, tenantId), + ), + Match.tag( + 'EXTERNAL_CORRELATION', + ({ customerConfigurationId, externalKey, tenantId }) => + sameTenantId(externalKey.tenantId, tenantId) && externalKey.customerConfigurationId === customerConfigurationId, + ), + Match.tag('IMPORTED_OBLIGATION', ({ obligationRef, tenantId }) => sameTenantId(obligationRef.tenantId, tenantId)), + Match.tag('LEGACY_HOLD', () => true), + Match.tag('PHYSICAL_EFFECT', ({ positionRef, tenantId }) => sameTenantId(positionRef.tenantId, tenantId)), + Match.tag('PROTECTION', ({ protectionRef, tenantId }) => sameTenantId(protectionRef.tenantId, tenantId)), + Match.tag('RESERVATION_EFFECT', ({ reservationRef, tenantId }) => sameTenantId(reservationRef.tenantId, tenantId)), + Match.tag('SOURCE_ASSERTION', ({ positionRef, tenantId }) => sameTenantId(positionRef.tenantId, tenantId)), + Match.tag('STOCK_POSITION', ({ positionRef, tenantId }) => sameTenantId(positionRef.tenantId, tenantId)), + Match.exhaustive, + ); + +const subjectTagOf = (subject: InventoryOperationalSubject): InventoryOperationalSubjectTag => + Match.value(subject).pipe( + Match.tag('BACKEND_CONFIGURATION', () => 'BACKEND_CONFIGURATION' as const), + Match.tag('CATALOG_DEMAND', () => 'CATALOG_DEMAND' as const), + Match.tag('COMMITTED_OBLIGATION', () => 'COMMITTED_OBLIGATION' as const), + Match.tag('CONFIRMATION', () => 'CONFIRMATION' as const), + Match.tag('CUTOVER', () => 'CUTOVER' as const), + Match.tag('DEMAND_INPUT', () => 'DEMAND_INPUT' as const), + Match.tag('EXTERNAL_CORRELATION', () => 'EXTERNAL_CORRELATION' as const), + Match.tag('IMPORTED_OBLIGATION', () => 'IMPORTED_OBLIGATION' as const), + Match.tag('LEGACY_HOLD', () => 'LEGACY_HOLD' as const), + Match.tag('PHYSICAL_EFFECT', () => 'PHYSICAL_EFFECT' as const), + Match.tag('PROTECTION', () => 'PROTECTION' as const), + Match.tag('RESERVATION_EFFECT', () => 'RESERVATION_EFFECT' as const), + Match.tag('SOURCE_ASSERTION', () => 'SOURCE_ASSERTION' as const), + Match.tag('STOCK_POSITION', () => 'STOCK_POSITION' as const), + Match.exhaustive, + ); + +const externalCorrelationMeaningMatches = ( + problem: InventoryOperationalProblemKind, + subject: Extract, +): boolean => + Match.value(problem).pipe( + Match.when( + 'EXTERNAL_ITEM_CORRELATION_AMBIGUOUS', + () => subject.externalKey.identifierKind === 'ITEM' && subject.resolution === 'AMBIGUOUS', + ), + Match.when( + 'EXTERNAL_ITEM_CORRELATION_UNRESOLVED', + () => subject.externalKey.identifierKind === 'ITEM' && subject.resolution === 'UNRESOLVED', + ), + Match.when( + 'EXTERNAL_LOCATION_CORRELATION_AMBIGUOUS', + () => subject.externalKey.identifierKind === 'LOCATION' && subject.resolution === 'AMBIGUOUS', + ), + Match.when( + 'EXTERNAL_LOCATION_CORRELATION_UNRESOLVED', + () => subject.externalKey.identifierKind === 'LOCATION' && subject.resolution === 'UNRESOLVED', + ), + Match.orElse(() => false), + ); + +const protectionMeaningMatches = ( + problem: InventoryOperationalProblemKind, + subject: Extract, +): boolean => + Match.value(problem).pipe( + Match.when('PROTECTION_AT_RISK', () => subject.fence === 'AT_RISK'), + Match.whenOr('PROTECTION_LATE_ESTABLISHMENT_PROVEN', 'PROTECTION_PROTECTED', () => subject.fence === 'ACTIVE'), + Match.when('PROTECTION_ESTABLISHMENT_INDETERMINATE', () => subject.fence === 'PRESERVE_POSSIBLE_PROTECTION_FENCE'), + Match.orElse(() => false), + ); + +const subjectMeaningMatches = (problem: InventoryOperationalProblemKind, subject: InventoryOperationalSubject) => + Match.value(subject).pipe( + Match.tag('EXTERNAL_CORRELATION', (correlation) => externalCorrelationMeaningMatches(problem, correlation)), + Match.tag('PROTECTION', (protection) => protectionMeaningMatches(problem, protection)), + Match.orElse(() => true), + ); + +const subjectAuthorityMatches = ( + subject: InventoryOperationalSubject, + selectedConfiguration: InventoryBackendConfiguration, +): boolean => + Match.value(subject).pipe( + Match.tag( + 'BACKEND_CONFIGURATION', + ({ configurationId }) => configurationId === selectedConfiguration.configurationId, + ), + Match.tag( + 'CUTOVER', + ({ postCutoverConfigurationId }) => postCutoverConfigurationId === selectedConfiguration.configurationId, + ), + Match.tag( + 'EXTERNAL_CORRELATION', + ({ externalKey }) => + externalKey.issuer.backendKind === selectedConfiguration.selection.backend && + externalKey.issuer.backendId === selectedConfiguration.selection.backendId, + ), + Match.orElse(() => true), + ); + +export const InventoryCanonicalOperationalFindingSchema = Schema.TaggedStruct('OPERATIONAL_FINDING', { + ownerIdentity: InventoryOperationalOwnerIdentitySchema, + policy: InventoryOperationalRecoveryPolicySchema, + problem: InventoryOperationalProblemKindSchema, + reason: InventoryOperationalProblemKindSchema, + scope: InventoryOperationalSubjectSchema, + selectedConfiguration: InventoryBackendConfigurationSchema, +}).check( + Schema.makeFilter(({ ownerIdentity, policy: actualPolicy, problem, reason, scope, selectedConfiguration }) => { + const expectedPolicy = inventoryOperationalPolicyFor(problem); + const expectedOwner = ownerIdentityFor(expectedPolicy.actualOwner, selectedConfiguration); + return reason === problem && + subjectTagOf(scope) === inventoryOperationalSubjectTagFor(problem) && + sameTenantId(scope.tenantId, selectedConfiguration.tenantId) && + scope.customerConfigurationId === selectedConfiguration.customerConfigurationId && + subjectRefTenantMatches(scope) && + subjectMeaningMatches(problem, scope) && + subjectAuthorityMatches(scope, selectedConfiguration) && + ownerIdentityMatches(ownerIdentity, expectedOwner) && + samePolicy(actualPolicy, expectedPolicy) + ? undefined + : 'Operational finding must preserve its exact problem, owner identity, scope, reason, and safe policy'; + }), +); +export type InventoryCanonicalOperationalFinding = typeof InventoryCanonicalOperationalFindingSchema.Type; + +export const makeInventoryOperationalFinding = (input: { + readonly problem: InventoryOperationalProblemKind; + readonly scope: InventoryOperationalSubject; + readonly selectedConfiguration: InventoryBackendConfiguration; +}): InventoryCanonicalOperationalFinding => { + const canonicalPolicy = inventoryOperationalPolicyFor(input.problem); + return { + _tag: 'OPERATIONAL_FINDING', + ownerIdentity: ownerIdentityFor(canonicalPolicy.actualOwner, input.selectedConfiguration), + policy: canonicalPolicy, + problem: input.problem, + reason: input.problem, + scope: input.scope, + selectedConfiguration: input.selectedConfiguration, + }; +}; + +export const InventoryBindingFailureFindingSchema = Schema.TaggedStruct('BINDING_FAILURE', { + canonical: InventoryCanonicalOperationalFindingSchema, + failure: CatalogToStockBindingResolutionFailure, + inferredStockItemRef: Schema.Null, + policy: InventoryOperationalRecoveryPolicySchema, + problem: Schema.Literals(['BINDING_MISSING', 'BINDING_CONFLICTING', 'BINDING_INCOMPATIBLE']), + scope: Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + demand: CatalogStockDemandSchema, + }), +}).check( + Schema.makeFilter(({ canonical, failure, problem, scope }) => { + const expectedProblem = `BINDING_${failure.outcome}`; + return sameTenantId(scope.authority.tenantId, scope.demand.catalogSelection.productRef.tenantId) && + canonical.problem === problem && + problem === expectedProblem + ? undefined + : 'Binding finding must preserve the exact demand Tenant and typed binding outcome'; + }), +); + +export const InventorySourceCoverageUncertaintyFindingSchema = Schema.TaggedStruct('SOURCE_COVERAGE_UNCERTAINTY', { + assertionId: InventorySourceAssertionSchema.fields.assertionId, + authority: InventoryBackendConfigurationSchema, + canonical: InventoryCanonicalOperationalFindingSchema, + customerConfigurationId: InventorySourceAssertionSchema.fields.customerConfigurationId, + evaluation: IndeterminateInventorySourceAssertionEvaluationSchema, + issuer: InventorySourceAssertionSchema.fields.issuer, + manualArithmeticAuthoritative: Schema.Literal(false), + materialEffectIds: IndeterminateInventorySourceAssertionEvaluationSchema.fields.materialEffectIds, + policy: InventoryOperationalRecoveryPolicySchema, + positionRef: InventorySourceAssertionSchema.fields.positionRef, + problem: Schema.Literal('SOURCE_COVERAGE_UNCERTAIN'), + provenPostEffectOnHand: Schema.Null, + quantity: StockQuantitySchema, + reason: IndeterminateInventorySourceAssertionEvaluationSchema.fields.reason, + reconciliationRequired: Schema.Literal(true), + stockItemRef: InventorySourceAssertionSchema.fields.stockItemRef, + stockLocationRef: InventorySourceAssertionSchema.fields.stockLocationRef, +}).check( + Schema.makeFilter((finding) => { + const { tenantId } = finding.authority; + const { assertion } = finding.evaluation; + const evaluationEffectIds = new Set(finding.evaluation.materialEffectIds); + return finding.canonical.problem === finding.problem && + finding.assertionId === assertion.assertionId && + sameBackendConfiguration(finding.authority, assertion.authorityConfiguration) && + sameBackendConfiguration(finding.authority, finding.canonical.selectedConfiguration) && + finding.authority.customerConfigurationId === finding.customerConfigurationId && + finding.customerConfigurationId === assertion.customerConfigurationId && + finding.issuer.backendId === assertion.issuer.backendId && + finding.issuer.backendKind === assertion.issuer.backendKind && + finding.reason === finding.evaluation.reason && + finding.materialEffectIds.length === finding.evaluation.materialEffectIds.length && + finding.materialEffectIds.every((effectId) => evaluationEffectIds.has(effectId)) && + [ + finding.positionRef.tenantId, + finding.quantity.unitRef.tenantId, + finding.stockItemRef.tenantId, + finding.stockLocationRef.tenantId, + ].every((candidate) => sameTenantId(candidate, tenantId)) + ? undefined + : 'Coverage uncertainty must preserve one exact authority, Position, Item, Location, and Unit scope'; + }), +); + +export const InventoryPartialCreateDebtFindingSchema = Schema.TaggedStruct('PARTIAL_CREATE_DEBT', { + attemptId: OrderCommitmentAttemptIdSchema, + authority: InventoryBackendConfigurationSchema, + canonical: InventoryCanonicalOperationalFindingSchema, + effectId: ReservationAuthorityEffectIdSchema, + evidenceState: Schema.Literals(['PROVEN_PARTIAL_HOLD', 'POSSIBLE_PARTIAL_HOLD']), + heldAllocations: Schema.NonEmptyArray(ReservationCreateAllocationSchema), + observedAt: Schema.toEncoded(Schema.DateTimeUtcFromString), + ownerEvidenceRef: Schema.optionalKey( + Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)), + ), + policy: InventoryOperationalRecoveryPolicySchema, + problem: Schema.Literals(['PARTIAL_CREATE_HOLD', 'POSSIBLE_PARTIAL_CREATE_HOLD']), + request: InventoryReservationCreateRequestSchema, + requestedReservationRef: InventoryReservationRefSchema, + safelyReusable: Schema.Literal(false), + successfulReservationEstablished: Schema.Literal(false), +}).check( + Schema.makeFilter( + ({ + attemptId, + authority, + canonical, + effectId, + evidenceState, + heldAllocations, + ownerEvidenceRef, + problem, + request, + requestedReservationRef, + }) => { + const { tenantId } = authority; + const requestAllocations = request.reservation.requirements.flatMap(({ allocations }) => allocations); + const heldAllocationIds = heldAllocations.map(({ allocationId }) => allocationId); + const allocationsMatch = heldAllocations.every((held) => + requestAllocations.some( + (planned) => + held.allocationId === planned.allocationId && + sameResourceRef(held.stockItemRef, planned.stockItemRef) && + sameResourceRef(held.stockPositionRef, planned.positionRef) && + sameResourceRef(held.quantity.unitRef, planned.quantity.unitRef) && + sameTenantId(held.stockItemRef.tenantId, authority.tenantId) && + sameTenantId(held.stockPositionRef.tenantId, authority.tenantId) && + sameTenantId(held.quantity.unitRef.tenantId, authority.tenantId) && + compareExactStockQuantityAmounts(held.quantity.amount, planned.quantity.amount) <= 0, + ), + ); + const authorityMatches = sameBackendConfiguration(authority, request.authority); + const evidenceMatchesProblem = + evidenceState === 'PROVEN_PARTIAL_HOLD' + ? problem === 'PARTIAL_CREATE_HOLD' && ownerEvidenceRef !== undefined + : problem === 'POSSIBLE_PARTIAL_CREATE_HOLD' && ownerEvidenceRef === undefined; + return canonical.problem === problem && + sameTenantId(requestedReservationRef.tenantId, tenantId) && + sameResourceRef(request.reservation.ref, requestedReservationRef) && + request.reservation.origin.attemptId === attemptId && + request.effectId === effectId && + authorityMatches && + sameBackendConfiguration(authority, canonical.selectedConfiguration) && + evidenceMatchesProblem && + new Set(heldAllocationIds).size === heldAllocationIds.length && + allocationsMatch + ? undefined + : 'Partial create debt must preserve the original effect, Attempt, request requirements, allocations, and authority'; + }, + ), +); + +export const InventoryOperationalFindingSchema = Schema.Union([ + InventoryCanonicalOperationalFindingSchema, + InventoryBindingFailureFindingSchema, + InventorySourceCoverageUncertaintyFindingSchema, + InventoryPartialCreateDebtFindingSchema, +]).check( + Schema.makeFilter(({ policy: actual, problem }) => + samePolicy(actual, inventoryOperationalPolicyFor(problem)) + ? undefined + : 'Operational finding policy must match the canonical fail-closed recovery meaning', + ), +); + +const bindingProblemFor = ( + outcome: CatalogToStockBindingResolutionFailure['outcome'], +): 'BINDING_MISSING' | 'BINDING_CONFLICTING' | 'BINDING_INCOMPATIBLE' => `BINDING_${outcome}`; + +export const investigateInventoryBindingFailure = (input: { + readonly authority: InventoryBackendConfiguration; + readonly demand: CatalogStockDemand; + readonly failure: CatalogToStockBindingResolutionFailure; +}) => { + const problem = bindingProblemFor(input.failure.outcome); + const canonical = makeInventoryOperationalFinding({ + problem, + scope: { + _tag: 'CATALOG_DEMAND', + customerConfigurationId: input.authority.customerConfigurationId, + demand: input.demand, + tenantId: input.authority.tenantId, + }, + selectedConfiguration: input.authority, + }); + return { + _tag: 'BINDING_FAILURE' as const, + canonical, + failure: input.failure, + inferredStockItemRef: null, + policy: inventoryOperationalPolicyFor(problem), + problem, + scope: { authority: input.authority, demand: input.demand }, + }; +}; + +export const InventorySourceCoverageUncertaintyInputSchema = IndeterminateInventorySourceAssertionEvaluationSchema; +export type InventorySourceCoverageUncertaintyInput = typeof InventorySourceCoverageUncertaintyInputSchema.Type; + +export const investigateInventorySourceCoverageUncertainty = (input: InventorySourceCoverageUncertaintyInput) => { + const canonical = makeInventoryOperationalFinding({ + problem: 'SOURCE_COVERAGE_UNCERTAIN', + scope: { + _tag: 'SOURCE_ASSERTION', + assertionId: input.assertion.assertionId, + customerConfigurationId: input.assertion.customerConfigurationId, + materialEffectIds: input.materialEffectIds, + positionRef: input.assertion.positionRef, + tenantId: input.assertion.authorityConfiguration.tenantId, + }, + selectedConfiguration: input.assertion.authorityConfiguration, + }); + return { + _tag: 'SOURCE_COVERAGE_UNCERTAINTY' as const, + assertionId: input.assertion.assertionId, + authority: input.assertion.authorityConfiguration, + canonical, + customerConfigurationId: input.assertion.customerConfigurationId, + evaluation: input, + issuer: input.assertion.issuer, + manualArithmeticAuthoritative: false as const, + materialEffectIds: input.materialEffectIds, + policy: inventoryOperationalPolicyFor('SOURCE_COVERAGE_UNCERTAIN'), + positionRef: input.assertion.positionRef, + problem: 'SOURCE_COVERAGE_UNCERTAIN' as const, + provenPostEffectOnHand: null, + quantity: input.assertion.quantity, + reason: input.reason, + reconciliationRequired: true as const, + stockItemRef: input.assertion.stockItemRef, + stockLocationRef: input.assertion.stockLocationRef, + }; +}; + +export const InventoryPartialCreateDebtInputSchema = Schema.Union([ + ReconciliationRequiredReservationCreateEffectSchema, + IndeterminateReservationCreateEffectSchema, +]); +export type InventoryPartialCreateDebtInput = typeof InventoryPartialCreateDebtInputSchema.Type; + +const partialCreateDebtBase = (input: InventoryPartialCreateDebtInput) => ({ + _tag: 'PARTIAL_CREATE_DEBT' as const, + attemptId: input.request.reservation.origin.attemptId, + authority: input.request.authority, + effectId: input.request.effectId, + observedAt: input.observedAt, + request: input.request, + requestedReservationRef: input.request.reservation.ref, + safelyReusable: false as const, + successfulReservationEstablished: false as const, +}); + +export const investigateInventoryPartialCreateDebt = (input: InventoryPartialCreateDebtInput) => + Match.value(input).pipe( + Match.tag('RECONCILIATION_REQUIRED', (effect) => ({ + ...partialCreateDebtBase(effect), + canonical: makeInventoryOperationalFinding({ + problem: 'PARTIAL_CREATE_HOLD', + scope: { + _tag: 'RESERVATION_EFFECT', + attemptId: effect.request.reservation.origin.attemptId, + customerConfigurationId: effect.request.authority.customerConfigurationId, + effectId: effect.request.effectId, + reservationRef: effect.request.reservation.ref, + tenantId: effect.request.authority.tenantId, + }, + selectedConfiguration: effect.request.authority, + }), + evidenceState: 'PROVEN_PARTIAL_HOLD' as const, + heldAllocations: effect.constrainedAllocations, + ownerEvidenceRef: effect.ownerEvidenceRef, + policy: inventoryOperationalPolicyFor('PARTIAL_CREATE_HOLD'), + problem: 'PARTIAL_CREATE_HOLD' as const, + })), + Match.tag('INDETERMINATE', (effect) => ({ + ...partialCreateDebtBase(effect), + canonical: makeInventoryOperationalFinding({ + problem: 'POSSIBLE_PARTIAL_CREATE_HOLD', + scope: { + _tag: 'RESERVATION_EFFECT', + attemptId: effect.request.reservation.origin.attemptId, + customerConfigurationId: effect.request.authority.customerConfigurationId, + effectId: effect.request.effectId, + reservationRef: effect.request.reservation.ref, + tenantId: effect.request.authority.tenantId, + }, + selectedConfiguration: effect.request.authority, + }), + evidenceState: 'POSSIBLE_PARTIAL_HOLD' as const, + heldAllocations: effect.possibleConstrainedAllocations, + policy: inventoryOperationalPolicyFor('POSSIBLE_PARTIAL_CREATE_HOLD'), + problem: 'POSSIBLE_PARTIAL_CREATE_HOLD' as const, + })), + Match.exhaustive, + ); diff --git a/app/verticals/inventory/shared/domain/inventory-post-commit-reconciliation-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-post-commit-reconciliation-unavailable.ts new file mode 100644 index 000000000..699189510 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-post-commit-reconciliation-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class InventoryPostCommitReconciliationUnavailable extends Schema.TaggedError()( + 'InventoryPostCommitReconciliationUnavailable', + { + code: Schema.Literal('inventory_post_commit_reconciliation_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-post-commit-reservation-reconciliation.ts b/app/verticals/inventory/shared/domain/inventory-post-commit-reservation-reconciliation.ts new file mode 100644 index 000000000..7434cde51 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-post-commit-reservation-reconciliation.ts @@ -0,0 +1,107 @@ +import type { Effect as EffectType, Option } from 'effect'; +import { Schema } from 'effect'; + +import { PurchaseDemandOccurrenceIdSchema } from './catalog-to-stock-binding.ts'; +import type { CatalogToStockBinding } from './catalog-to-stock-binding.ts'; +import { + ImportedCommittedObligationSchema, + RuntimeCommittedInventoryObligationSchema, + StockAllocationIdSchema, +} from './inventory-obligation.ts'; +import type { + ImportedCommittedObligation, + InventoryObligationRequirement, + InventoryStockAllocation, + ProvisionalInventoryReservation, + RuntimeCommittedInventoryObligation, + RuntimeOrderCommitProofObservation, +} from './inventory-obligation.ts'; +import { InventoryCommittedObligationStateEvidenceSchema } from './inventory-source-obligation-reconciliation.ts'; +import type { InventoryPostCommitReconciliationUnavailable } from './inventory-post-commit-reconciliation-unavailable.ts'; +import { PhysicalStockEffectIdSchema } from './physical-stock-effect.ts'; +import type { AppliedPhysicalStockEffectSchema, PhysicalStockEffectRecord } from './physical-stock-effect.ts'; +import { ImportedCommittedObligationRefSchema } from '../resources/imported-committed-obligation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; + +export const PostCommitInventoryObligationSchema = Schema.Union([ + RuntimeCommittedInventoryObligationSchema, + ImportedCommittedObligationSchema, +]); +export type PostCommitInventoryObligation = typeof PostCommitInventoryObligationSchema.Type; + +export const PostCommitObligationRefSchema = Schema.Union([ + InventoryReservationRefSchema, + ImportedCommittedObligationRefSchema, +]); + +export const InventoryPostCommitReductionRequestSchema = Schema.Struct({ + allocationId: StockAllocationIdSchema, + issueEffectId: PhysicalStockEffectIdSchema, + obligationRef: PostCommitObligationRefSchema, + purchaseDemandOccurrenceId: PurchaseDemandOccurrenceIdSchema, +}); +export type InventoryPostCommitReductionRequest = typeof InventoryPostCommitReductionRequestSchema.Type; + +export const InventoryPostCommitReductionResultSchema = Schema.Struct({ + evidence: InventoryCommittedObligationStateEvidenceSchema, + outcome: Schema.Literals(['REDUCED', 'EXACT_REPLAY']), +}); +export type InventoryPostCommitReductionResult = typeof InventoryPostCommitReductionResultSchema.Type; + +export interface InventoryPostCommitAppliedIssueReduction { + readonly allocation: InventoryStockAllocation; + readonly issue: typeof AppliedPhysicalStockEffectSchema.Type; + readonly obligation: PostCommitInventoryObligation; + readonly requirement: InventoryObligationRequirement; +} + +export interface InventoryPostCommitTransition { + readonly transition: ( + reservation: ProvisionalInventoryReservation, + observation: RuntimeOrderCommitProofObservation, + ) => EffectType.Effect< + RuntimeCommittedInventoryObligation, + InventoryPostCommitReconciliationRejected | InventoryPostCommitReconciliationUnavailable + >; +} + +export class InventoryPostCommitReconciliationRejected extends Schema.TaggedError()( + 'InventoryPostCommitReconciliationRejected', + { + code: Schema.Literal('inventory_post_commit_reconciliation_rejected'), + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'OBLIGATION_NOT_FOUND', + 'OBLIGATION_NOT_COMMITTED', + 'ORDER_COMMIT_PROOF_MISMATCH', + 'PHYSICAL_EFFECT_NOT_FOUND', + 'PHYSICAL_ISSUE_NOT_APPLIED', + 'PHYSICAL_ISSUE_SCOPE_MISMATCH', + 'OBLIGATION_REQUIREMENT_NOT_FOUND', + 'ALLOCATION_NOT_FOUND', + 'REDUCTION_EVIDENCE_SCOPE_MISMATCH', + 'BINDING_SCOPE_MISMATCH', + ]), + }, +) {} + +export interface InventoryPostCommitPhysicalEffectReader { + readonly read: ( + effectId: typeof PhysicalStockEffectIdSchema.Type, + ) => EffectType.Effect, InventoryPostCommitReconciliationUnavailable>; +} + +export interface InventoryPostCommitReductionWriter { + readonly reduceAfterAppliedIssue: ( + request: InventoryPostCommitAppliedIssueReduction, + ) => EffectType.Effect< + InventoryPostCommitReductionResult, + InventoryPostCommitReconciliationRejected | InventoryPostCommitReconciliationUnavailable + >; +} + +export interface InventoryPostCommitBindingAssessmentInput { + readonly currentBinding: CatalogToStockBinding; + readonly obligation: ImportedCommittedObligation | RuntimeCommittedInventoryObligation; + readonly purchaseDemandOccurrenceId: typeof PurchaseDemandOccurrenceIdSchema.Type; +} diff --git a/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation-rejected.ts b/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation-rejected.ts new file mode 100644 index 000000000..092b82605 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation-rejected.ts @@ -0,0 +1,20 @@ +import { Schema } from 'effect'; + +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +export class InventoryPreCommitCompensationRejected extends Schema.TaggedError()( + 'InventoryPreCommitCompensationRejected', + { + code: Schema.Literal('inventory_pre_commit_compensation_rejected'), + createEffectId: ReservationAuthorityEffectIdSchema, + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'AUTHORIZATION_TARGET_MISMATCH', + 'EFFECT_NOT_FOUND', + 'ATTEMPT_SCOPE_MISMATCH', + 'EFFECT_ID_CONFLICT', + 'INVALID_CLEANUP_OBSERVATION', + 'RELEASE_CONFLICT', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation-unavailable.ts new file mode 100644 index 000000000..e0532f70d --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation-unavailable.ts @@ -0,0 +1,15 @@ +import { Schema } from 'effect'; + +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); + +export class InventoryPreCommitCompensationUnavailable extends Schema.TaggedError()( + 'InventoryPreCommitCompensationUnavailable', + { + code: Schema.Literal('inventory_pre_commit_compensation_unavailable'), + createEffectId: ReservationAuthorityEffectIdSchema, + reason: boundedText, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation.ts b/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation.ts new file mode 100644 index 000000000..e7334abd1 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-pre-commit-compensation.ts @@ -0,0 +1,100 @@ +import { Schema } from 'effect'; + +import { InventoryPreCommitCompensationRejected } from './inventory-pre-commit-compensation-rejected.ts'; +import { InventoryPreCommitCompensationUnavailable } from './inventory-pre-commit-compensation-unavailable.ts'; +import { + ReservationCreateAllocationSchema, + ReservationCreateEffectSchema, + ResolvedNoReservationCreateEffectSchema, +} from './inventory-reservation-create.ts'; +import { ReservationEvidenceIssuerSchema } from './reservation-authority.ts'; +import { ReleaseInventoryReservationResultSchema } from './inventory-reservation-release.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const CompensateInventoryPreCommitPayloadSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + authorizationTargetRef: InventoryReservationRefSchema, + createEffectId: ReservationAuthorityEffectIdSchema, +}); +export type CompensateInventoryPreCommitPayload = typeof CompensateInventoryPreCommitPayloadSchema.Type; + +export const InventoryPreCommitCleanupObservationSchema = Schema.Union([ + Schema.TaggedStruct('CLEANED', { + authorityIssuer: ReservationEvidenceIssuerSchema, + cleanedAllocations: Schema.Array(ReservationCreateAllocationSchema), + cleanedAt: instant, + cleanupEvidenceRef: boundedText, + effectAbsenceProven: Schema.Literal(true), + effectId: ReservationAuthorityEffectIdSchema, + }), + Schema.TaggedStruct('ALREADY_CLEANED', { + authorityIssuer: ReservationEvidenceIssuerSchema, + cleanedAllocations: Schema.Array(ReservationCreateAllocationSchema), + cleanedAt: instant, + cleanupEvidenceRef: boundedText, + effectAbsenceProven: Schema.Literal(true), + effectId: ReservationAuthorityEffectIdSchema, + }), + Schema.TaggedStruct('INDETERMINATE', { + effectId: ReservationAuthorityEffectIdSchema, + observedAt: instant, + reason: Schema.Literals(['AUTHORITY_OUTCOME_UNKNOWN', 'CLEANUP_EVIDENCE_UNAVAILABLE']), + }), +]); +export type InventoryPreCommitCleanupObservation = typeof InventoryPreCommitCleanupObservationSchema.Type; + +const blockedResult = Schema.Struct({ + effect: ReservationCreateEffectSchema, + orderTruth: Schema.Union([ + Schema.TaggedStruct('COMMITTED', { evidenceRef: boundedText, observedAt: instant }), + Schema.TaggedStruct('NOT_COMMITTED_OPEN', { evidenceRef: boundedText, observedAt: instant }), + Schema.TaggedStruct('INDETERMINATE', { + observedAt: instant, + reason: Schema.Literals(['ORDER_EVIDENCE_MISSING', 'ORDER_EVIDENCE_UNAVAILABLE', 'ORDER_EVIDENCE_INDETERMINATE']), + }), + ]), + outcome: Schema.Literal('BLOCKED'), + reason: Schema.Literals(['ORDER_COMMITTED', 'ATTEMPT_NOT_CLOSED', 'ORDER_TRUTH_UNKNOWN']), + safelyReusable: Schema.Literal(false), +}); + +export const CompensateInventoryPreCommitResultSchema = Schema.Union([ + Schema.Struct({ + effect: ResolvedNoReservationCreateEffectSchema, + outcome: Schema.Literals(['CREATE_EFFECT_COMPENSATED', 'ALREADY_COMPENSATED']), + safelyReusable: Schema.Literal(true), + }), + Schema.Struct({ + effect: ResolvedNoReservationCreateEffectSchema, + outcome: Schema.Literal('NO_COMPENSATION_REQUIRED'), + safelyReusable: Schema.Literal(true), + }), + Schema.Struct({ + createEffect: ReservationCreateEffectSchema, + outcome: Schema.Literal('RESERVATION_RELEASE'), + release: ReleaseInventoryReservationResultSchema, + }), + Schema.Struct({ + effect: ReservationCreateEffectSchema, + observedAt: instant, + outcome: Schema.Literal('RECONCILIATION_REQUIRED'), + reason: Schema.Literal('CLEANUP_OUTCOME_UNKNOWN'), + safelyReusable: Schema.Literal(false), + }), + blockedResult, +]); +export type CompensateInventoryPreCommitResult = typeof CompensateInventoryPreCommitResultSchema.Type; + +export const CompensateInventoryPreCommitErrorSchema = Schema.Union([ + InventoryPreCommitCompensationRejected, + InventoryPreCommitCompensationUnavailable, +]); +export type CompensateInventoryPreCommitError = typeof CompensateInventoryPreCommitErrorSchema.Type; + +export { InventoryPreCommitCompensationRejected } from './inventory-pre-commit-compensation-rejected.ts'; +export { InventoryPreCommitCompensationUnavailable } from './inventory-pre-commit-compensation-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/inventory-reconciliation-evidence-rejected.ts b/app/verticals/inventory/shared/domain/inventory-reconciliation-evidence-rejected.ts new file mode 100644 index 000000000..2eac05310 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reconciliation-evidence-rejected.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class InventoryReconciliationEvidenceRejected extends Schema.TaggedError()( + 'InventoryReconciliationEvidenceRejected', + { + code: Schema.Literal('inventory_reconciliation_evidence_rejected'), + reason: Schema.Literals(['CORRELATION_NOT_ENDED', 'EVIDENCE_LIMIT_EXCEEDED']), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-reconciliation-evidence-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-reconciliation-evidence-unavailable.ts new file mode 100644 index 000000000..cb0e13d08 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reconciliation-evidence-unavailable.ts @@ -0,0 +1,10 @@ +import { Schema } from 'effect'; + +export class InventoryReconciliationEvidenceUnavailable extends Schema.TaggedError()( + 'InventoryReconciliationEvidenceUnavailable', + { + code: Schema.Literal('inventory_reconciliation_evidence_unavailable'), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-create-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-reservation-create-unavailable.ts new file mode 100644 index 000000000..06507b467 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-create-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; + +export class InventoryReservationCreateUnavailable extends Schema.TaggedError()( + 'InventoryReservationCreateUnavailable', + { + code: Schema.Literal('inventory_reservation_create_unavailable'), + effectId: ReservationAuthorityEffectIdSchema, + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-create.ts b/app/verticals/inventory/shared/domain/inventory-reservation-create.ts new file mode 100644 index 000000000..9157b998d --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-create.ts @@ -0,0 +1,229 @@ +import { Schema } from 'effect'; + +import { CatalogStockDemandSchema } from './catalog-to-stock-binding.ts'; +import { CatalogToStockBindingResolutionFailure } from './catalog-to-stock-binding-resolution.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { + InventoryObligationRequirementSchema, + InventoryStockAllocationSchema, + ProvisionalInventoryReservationSchema, +} from './inventory-obligation.ts'; +import { InventoryReservationCreateUnavailable } from './inventory-reservation-create-unavailable.ts'; +import { InventoryReservationGuaranteeUnsupported } from './inventory-reservation-guarantee-unsupported.ts'; +import { ActionInvocationIdSchema, LegalEntityIdSchema } from './physical-stock-effect.ts'; +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; +import { TrustedCurrentCommercePurchasingContextSchema } from './stock-sharing-eligibility.ts'; +import { CustomerConfigurationIdSchema, OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); +export const InventoryReservationCreateMutationIdSchema = Schema.String.check(Schema.isUUID()).pipe( + Schema.brand('InventoryReservationCreateMutationId'), +); +const reservationCreateIndeterminateReasonSchema = Schema.Literals([ + 'DISPATCH_PENDING', + 'BACKEND_OUTCOME_UNKNOWN', + 'EVIDENCE_UNVERIFIABLE', + 'AUTHORITY_UNAVAILABLE', +]); +const reservationCreateRejectedReasonSchema = Schema.Literals([ + 'INSUFFICIENT_STOCK', + 'BACKEND_REJECTED', + 'PRE_COMMIT_COMPENSATED', +]); + +export const ReservationCreateAllocationSchema = Schema.Struct({ + allocationId: InventoryStockAllocationSchema.fields.allocationId, + quantity: InventoryStockAllocationSchema.fields.quantity, + stockItemRef: InventoryStockAllocationSchema.fields.stockItemRef, + stockPositionRef: InventoryStockAllocationSchema.fields.positionRef, +}); +export type ReservationCreateAllocation = typeof ReservationCreateAllocationSchema.Type; + +export const CreateInventoryReservationPayloadSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + commerceContext: TrustedCurrentCommercePurchasingContextSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + demands: Schema.Array(CatalogStockDemandSchema).check(Schema.isMinLength(1)), + effectId: ReservationAuthorityEffectIdSchema, + reservationRef: InventoryReservationRefSchema, +}).check( + Schema.makeFilter(({ commerceContext, customerConfigurationId, demands, reservationRef }) => { + const { tenantId } = reservationRef; + if ( + commerceContext.tenantId !== tenantId || + commerceContext.customerConfigurationId !== customerConfigurationId || + demands.some( + ({ catalogSelection: { productRef }, unitRef }) => + productRef.tenantId !== tenantId || unitRef.tenantId !== tenantId, + ) + ) { + return 'Reservation request, Commerce context, demand, and Unit must share one Tenant and Customer Configuration'; + } + const occurrences = demands.map(({ purchaseDemandOccurrenceId }) => purchaseDemandOccurrenceId); + return new Set(occurrences).size === occurrences.length + ? undefined + : 'Purchase Demand Occurrence identities must remain distinct'; + }), +); +export type CreateInventoryReservationPayload = typeof CreateInventoryReservationPayloadSchema.Type; + +export const InventoryReservationCreateRequestSchema = Schema.Struct({ + authority: InventoryBackendConfigurationSchema, + commerceContext: TrustedCurrentCommercePurchasingContextSchema, + effectId: ReservationAuthorityEffectIdSchema, + legalEntityId: LegalEntityIdSchema, + mutationId: InventoryReservationCreateMutationIdSchema, + requestedAt: instant, + reservation: Schema.Struct({ + origin: Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + kind: Schema.Literal('ORDER_COMMITMENT_ATTEMPT'), + }), + ref: InventoryReservationRefSchema, + requirements: Schema.Array(InventoryObligationRequirementSchema).check(Schema.isMinLength(1)), + }), + sourceActionInvocationId: ActionInvocationIdSchema, +}); +export type InventoryReservationCreateRequest = typeof InventoryReservationCreateRequestSchema.Type; + +export const ReservationCreateBackendObservationSchema = Schema.Union([ + Schema.TaggedStruct('ESTABLISHED', { + allocations: Schema.Array(ReservationCreateAllocationSchema).check(Schema.isMinLength(1)), + effectId: ReservationAuthorityEffectIdSchema, + establishedAt: instant, + ownerEvidenceRef: boundedText, + }), + Schema.TaggedStruct('REJECTED', { + effectAbsenceProven: Schema.Literal(true), + effectId: ReservationAuthorityEffectIdSchema, + reason: reservationCreateRejectedReasonSchema, + }), + Schema.TaggedStruct('PARTIAL', { + constrainedAllocations: Schema.Array(ReservationCreateAllocationSchema).check(Schema.isMinLength(1)), + effectId: ReservationAuthorityEffectIdSchema, + observedAt: instant, + ownerEvidenceRef: boundedText, + }), + Schema.TaggedStruct('INDETERMINATE', { + effectId: ReservationAuthorityEffectIdSchema, + observedAt: instant, + reason: reservationCreateIndeterminateReasonSchema, + }), +]); +export type ReservationCreateBackendObservation = typeof ReservationCreateBackendObservationSchema.Type; + +const effectBase = { + request: InventoryReservationCreateRequestSchema, +} as const; + +export const RequestedReservationCreateEffectSchema = Schema.TaggedStruct('REQUESTED', effectBase); +export const EstablishedReservationCreateEffectSchema = Schema.TaggedStruct('ESTABLISHED', { + ...effectBase, + ownerEvidenceRef: boundedText, + reservation: ProvisionalInventoryReservationSchema, +}); +export const ReconciliationRequiredReservationCreateEffectSchema = Schema.TaggedStruct('RECONCILIATION_REQUIRED', { + ...effectBase, + constrainedAllocations: Schema.Array(ReservationCreateAllocationSchema).check(Schema.isMinLength(1)), + observedAt: instant, + ownerEvidenceRef: boundedText, +}); +export const IndeterminateReservationCreateEffectSchema = Schema.TaggedStruct('INDETERMINATE', { + ...effectBase, + observedAt: instant, + possibleConstrainedAllocations: Schema.Array(ReservationCreateAllocationSchema).check(Schema.isMinLength(1)), + reason: reservationCreateIndeterminateReasonSchema, +}); +export const ReservationCreatePreCommitCompensationSchema = Schema.Struct({ + authorityIssuer: Schema.Struct({ + backend: InventoryBackendConfigurationSchema.fields.selection.fields.backend, + backendId: InventoryBackendConfigurationSchema.fields.selection.fields.backendId, + origin: Schema.Literals(['EXTERNAL_BUSINESS_SYSTEM', 'ONTOS_WMS']), + }), + cleanedAllocations: Schema.Array(ReservationCreateAllocationSchema), + cleanedAt: instant, + cleanupEvidenceRef: boundedText, + cleanupOutcome: Schema.Literals(['CLEANED', 'ALREADY_CLEANED']), + orderProof: Schema.TaggedStruct('NOT_COMMITTED_CLOSED', { + closureEvidenceRef: boundedText, + nonCommitEvidenceRef: boundedText, + observedAt: instant, + }), + originalEffectState: Schema.Literals(['REQUESTED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE']), + originalObservedAt: Schema.optionalKey(instant), + originalOwnerEvidenceRef: Schema.optionalKey(boundedText), +}); + +export const ResolvedNoReservationCreateEffectSchema = Schema.TaggedStruct('RESOLVED_NO_RESERVATION', { + ...effectBase, + effectAbsenceProven: Schema.Literal(true), + observedAt: instant, + preCommitCompensation: Schema.optionalKey(ReservationCreatePreCommitCompensationSchema), + reason: reservationCreateRejectedReasonSchema, +}).check( + Schema.makeFilter(({ preCommitCompensation, reason }) => + (reason === 'PRE_COMMIT_COMPENSATED') === (preCommitCompensation !== undefined) + ? undefined + : 'Pre-commit compensation evidence must exist exactly for PRE_COMMIT_COMPENSATED resolution', + ), +); +export const ReservationCreateEffectSchema = Schema.Union([ + RequestedReservationCreateEffectSchema, + EstablishedReservationCreateEffectSchema, + ReconciliationRequiredReservationCreateEffectSchema, + IndeterminateReservationCreateEffectSchema, + ResolvedNoReservationCreateEffectSchema, +]); +export type ReservationCreateEffect = typeof ReservationCreateEffectSchema.Type; + +const establishedResultFields = { + effect: EstablishedReservationCreateEffectSchema, + reservation: ProvisionalInventoryReservationSchema, +} as const; +export const CreateInventoryReservationResultSchema = Schema.Union([ + Schema.Struct({ effect: RequestedReservationCreateEffectSchema, outcome: Schema.Literal('PENDING') }), + Schema.Struct({ ...establishedResultFields, outcome: Schema.Literal('ESTABLISHED') }), + Schema.Struct({ ...establishedResultFields, outcome: Schema.Literal('EXACT_REPLAY') }), + Schema.Struct({ + effect: ReconciliationRequiredReservationCreateEffectSchema, + outcome: Schema.Literal('RECONCILIATION_REQUIRED'), + }), + Schema.Struct({ effect: IndeterminateReservationCreateEffectSchema, outcome: Schema.Literal('INDETERMINATE') }), + Schema.Struct({ + effect: ResolvedNoReservationCreateEffectSchema, + outcome: Schema.Literal('RESOLVED_NO_RESERVATION'), + }), +]); +export type CreateInventoryReservationResult = typeof CreateInventoryReservationResultSchema.Type; + +export class InventoryReservationCreateRejected extends Schema.TaggedError()( + 'InventoryReservationCreateRejected', + { + code: Schema.Literal('inventory_reservation_create_rejected'), + effectId: ReservationAuthorityEffectIdSchema, + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'AUTHORITY_NOT_SELECTED', + 'INSUFFICIENT_CONSTRAINED_STOCK', + 'EFFECT_ID_CONFLICT', + 'ATTEMPT_ALREADY_BOUND', + 'ATTEMPT_HAS_UNRESOLVED_EFFECT', + 'ATTEMPT_ALREADY_RESOLVED', + 'BACKEND_REJECTED_WITHOUT_EFFECT', + 'INVALID_BACKEND_OBSERVATION', + 'COMMERCE_CONTEXT_NOT_ELIGIBLE', + ]), + }, +) {} + +export const CreateInventoryReservationErrorSchema = Schema.Union([ + InventoryReservationCreateRejected, + InventoryReservationCreateUnavailable, + CatalogToStockBindingResolutionFailure, + InventoryReservationGuaranteeUnsupported, +]); +export type CreateInventoryReservationError = typeof CreateInventoryReservationErrorSchema.Type; + +export { InventoryReservationCreateUnavailable } from './inventory-reservation-create-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-evidence-handoff.ts b/app/verticals/inventory/shared/domain/inventory-reservation-evidence-handoff.ts new file mode 100644 index 000000000..585b19c64 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-evidence-handoff.ts @@ -0,0 +1,439 @@ +import { DateTime, Effect, Match, Schema } from 'effect'; + +import { + CatalogToStockBindingHistoryEntrySchema, + CatalogToStockBindingSchema, + PurchaseDemandOccurrenceIdSchema, +} from './catalog-to-stock-binding.ts'; +import { CommitmentProtectionSchema } from './commitment-protection.ts'; +import { ProvisionalInventoryReservationSchema } from './inventory-obligation.ts'; +import { ReservationConfirmationSchema } from './reservation-confirmation.ts'; +import { ReservationEvidenceIssuerSchema } from './reservation-authority.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; + +const boundedEvidenceRef = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); + +/** + * Inventory never owns or re-hashes the Order bundle. It retains only the exact + * immutable owner binding that the Order Commitment Attempt already selected. + */ +export const OrderAcceptanceDecisionBundleBindingSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + bundleHash: boundedEvidenceRef, + bundleSchemaVersion: boundedEvidenceRef, + meaning: Schema.Literal('EXACT_PRE_ATTEMPT_PURCHASE'), + tenantId: ProvisionalInventoryReservationSchema.fields.ref.fields.tenantId, +}); +export type OrderAcceptanceDecisionBundleBinding = typeof OrderAcceptanceDecisionBundleBindingSchema.Type; + +export const InventoryReservationRequirementBindingEvidenceSchema = Schema.Struct({ + acceptedBinding: CatalogToStockBindingSchema, + acceptedBindingOwnerEvidenceRef: boundedEvidenceRef, + currentCorrection: Schema.optionalKey( + Schema.Struct({ + currentBinding: CatalogToStockBindingSchema, + historyEntry: CatalogToStockBindingHistoryEntrySchema, + }), + ), + purchaseDemandOccurrenceId: PurchaseDemandOccurrenceIdSchema, +}); +export type InventoryReservationRequirementBindingEvidence = + typeof InventoryReservationRequirementBindingEvidenceSchema.Type; + +const SafeInventoryReservationOwnerReferencesSchema = Schema.Struct({ + confirmationEffectId: ReservationConfirmationSchema.fields.authorityEvidence.fields.effectId, + confirmationOwnerEvidenceRef: + ReservationConfirmationSchema.fields.authorityEvidence.fields.evidence.fields.ownerEvidenceRef, + issuer: ReservationEvidenceIssuerSchema, + protectionEffectId: CommitmentProtectionSchema.fields.authorityEvidence.fields.effectId, + protectionOwnerEvidenceRef: + CommitmentProtectionSchema.fields.authorityEvidence.fields.evidence.fields.ownerEvidenceRef, +}); + +/** The public handoff references its one top-level Current Confirmation instead of embedding a second copy. */ +export const InventoryReservationProtectionHandoffEvidenceSchema = Schema.Struct({ + authorityEvidence: CommitmentProtectionSchema.fields.authorityEvidence, + confirmationRef: ReservationConfirmationSchema.fields.ref, + establishedAt: CommitmentProtectionSchema.fields.establishedAt, + health: CommitmentProtectionSchema.fields.health, + ref: CommitmentProtectionSchema.fields.ref, + revision: CommitmentProtectionSchema.fields.revision, +}); +export type InventoryReservationProtectionHandoffEvidence = + typeof InventoryReservationProtectionHandoffEvidenceSchema.Type; + +const InventoryReservationEvidenceHandoffBaseSchema = Schema.TaggedStruct('InventoryReservationEvidenceHandoff', { + backendFallbackApplied: Schema.Literal(false), + bundleBinding: OrderAcceptanceDecisionBundleBindingSchema, + confirmation: ReservationConfirmationSchema, + proofSetPlacement: Schema.Literal('ORDER_COMMITMENT_PROOF_SET'), + protection: InventoryReservationProtectionHandoffEvidenceSchema, + requirementBindingEvidence: Schema.Array(InventoryReservationRequirementBindingEvidenceSchema).check( + Schema.isMinLength(1), + ), + reservation: ProvisionalInventoryReservationSchema, + reservationConfirmationRenewalSupported: Schema.Literal(false), + safeOwnerReferences: SafeInventoryReservationOwnerReferencesSchema, +}); + +export class InventoryReservationEvidenceHandoffRejected extends Schema.TaggedError()( + 'InventoryReservationEvidenceHandoffRejected', + { + code: Schema.Literal('inventory_reservation_evidence_handoff_rejected'), + fallbackApplied: Schema.Literal(false), + reason: Schema.Literals([ + 'INVALID_HANDOFF', + 'TENANT_SCOPE_MISMATCH', + 'ATTEMPT_BUNDLE_MISMATCH', + 'RESERVATION_CONFIRMATION_MISMATCH', + 'CONFIRMATION_PROTECTION_MISMATCH', + 'AUTHORITY_SCOPE_MISMATCH', + 'PROTECTION_ESTABLISHMENT_OUTSIDE_CONFIRMATION', + 'BINDING_EVIDENCE_MISSING', + 'BINDING_EVIDENCE_MISMATCH', + 'CORRECTION_EVIDENCE_MISMATCH', + 'CORRECTION_HEALTH_MISMATCH', + 'CORRECTION_PROVENANCE_MISMATCH', + ]), + }, +) {} + +export const InventoryReservationEvidenceHandoffInputSchema = Schema.Struct({ + bundleBinding: OrderAcceptanceDecisionBundleBindingSchema, + confirmation: ReservationConfirmationSchema, + protection: CommitmentProtectionSchema, + requirementBindingEvidence: Schema.Array(InventoryReservationRequirementBindingEvidenceSchema), + reservation: ProvisionalInventoryReservationSchema, +}); +export type InventoryReservationEvidenceHandoffInput = typeof InventoryReservationEvidenceHandoffInputSchema.Type; + +const rejected = (reason: InventoryReservationEvidenceHandoffRejected['reason']) => + new InventoryReservationEvidenceHandoffRejected({ + code: 'inventory_reservation_evidence_handoff_rejected', + fallbackApplied: false, + reason, + }); + +const sameRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameRequirements = Schema.toEquivalence(ProvisionalInventoryReservationSchema.fields.requirements); +const sameBackendConfiguration = Schema.toEquivalence(ProvisionalInventoryReservationSchema.fields.authority); +const sameBinding = Schema.toEquivalence(CatalogToStockBindingSchema); +const sameCatalogSelection = Schema.toEquivalence(CatalogToStockBindingSchema.fields.catalogSelection); +const sameSelectionMeaning = Schema.toEquivalence(CatalogToStockBindingSchema.fields.exactSelectionMeaning); +const sameConfirmationAuthorityEvidence = Schema.toEquivalence(ReservationConfirmationSchema.fields.authorityEvidence); +const sameConfirmationHealth = Schema.toEquivalence(ReservationConfirmationSchema.fields.health); +const sameIssuanceRank = Schema.toEquivalence(ReservationConfirmationSchema.fields.issuanceRank); +const sameAuthorityAllocations = Schema.toEquivalence( + ReservationConfirmationSchema.fields.authorityEvidence.fields.evidence.fields.allocations, +); + +const sameAuthority = ( + issuer: typeof ReservationEvidenceIssuerSchema.Type, + expected: typeof ReservationEvidenceIssuerSchema.Type, +) => + issuer.backend === expected.backend && issuer.backendId === expected.backendId && issuer.origin === expected.origin; + +const expectedIssuer = ( + reservation: typeof ProvisionalInventoryReservationSchema.Type, +): typeof ReservationEvidenceIssuerSchema.Type => ({ + backend: reservation.authority.selection.backend, + backendId: reservation.authority.selection.backendId, + origin: + reservation.authority.selection.backend === 'external_business_system' ? 'EXTERNAL_BUSINESS_SYSTEM' : 'ONTOS_WMS', +}); + +interface HandoffLineage { + readonly bundleBinding: OrderAcceptanceDecisionBundleBinding; + readonly confirmation: typeof ReservationConfirmationSchema.Type; + readonly protection: InventoryReservationProtectionHandoffEvidence; + readonly reservation: typeof ProvisionalInventoryReservationSchema.Type; +} + +const toProtectionHandoffEvidence = ( + protection: typeof CommitmentProtectionSchema.Type, +): InventoryReservationProtectionHandoffEvidence => ({ + authorityEvidence: protection.authorityEvidence, + confirmationRef: protection.confirmation.ref, + establishedAt: protection.establishedAt, + health: protection.health, + ref: protection.ref, + revision: protection.revision, +}); + +const protectionProofMatchesLineage = ( + protection: InventoryReservationProtectionHandoffEvidence, + confirmation: typeof ReservationConfirmationSchema.Type, + reservation: typeof ProvisionalInventoryReservationSchema.Type, +) => { + const proof = protection.authorityEvidence; + return ( + proof.operation === 'COMMITMENT_PROTECTION' && + String(proof.evidence.tenantId) === String(reservation.ref.tenantId) && + proof.evidence.reservationId === reservation.ref.resourceId && + proof.evidence.attemptId === reservation.origin.attemptId && + sameAuthorityAllocations(proof.evidence.allocations, confirmation.authorityEvidence.evidence.allocations) + ); +}; + +const validateHandoffLineage = ( + input: HandoffLineage, +): InventoryReservationEvidenceHandoffRejected['reason'] | undefined => { + const { bundleBinding, confirmation, protection, reservation } = input; + const { + ref: { tenantId }, + } = reservation; + if ( + bundleBinding.tenantId !== tenantId || + confirmation.ref.tenantId !== tenantId || + protection.ref.tenantId !== tenantId + ) { + return 'TENANT_SCOPE_MISMATCH'; + } + if (bundleBinding.attemptId !== reservation.origin.attemptId) { + return 'ATTEMPT_BUNDLE_MISMATCH'; + } + if ( + !sameRef(confirmation.reservation.ref, reservation.ref) || + confirmation.reservation.origin.attemptId !== reservation.origin.attemptId || + confirmation.reservation.establishedAt !== reservation.establishedAt || + !sameRequirements(confirmation.reservation.requirements, reservation.requirements) || + !sameBackendConfiguration(confirmation.reservation.authority, reservation.authority) + ) { + return 'RESERVATION_CONFIRMATION_MISMATCH'; + } + if (!sameRef(protection.confirmationRef, confirmation.ref)) { + return 'CONFIRMATION_PROTECTION_MISMATCH'; + } + if (!protectionProofMatchesLineage(protection, confirmation, reservation)) { + return 'CONFIRMATION_PROTECTION_MISMATCH'; + } + const issuer = expectedIssuer(reservation); + if ( + !sameAuthority(confirmation.authorityEvidence.issuer, issuer) || + !sameAuthority(protection.authorityEvidence.issuer, issuer) || + confirmation.authorityEvidence.evidence.customerConfigurationId !== reservation.authority.customerConfigurationId || + protection.authorityEvidence.evidence.customerConfigurationId !== reservation.authority.customerConfigurationId + ) { + return 'AUTHORITY_SCOPE_MISMATCH'; + } + const establishedAt = DateTime.toEpochMillis(DateTime.makeUnsafe(protection.establishedAt)); + const issuedAt = DateTime.toEpochMillis(DateTime.makeUnsafe(confirmation.issuedAt)); + const expiresAt = DateTime.toEpochMillis(DateTime.makeUnsafe(confirmation.expiresAt)); + if (establishedAt < issuedAt || establishedAt >= expiresAt) { + return 'PROTECTION_ESTABLISHMENT_OUTSIDE_CONFIRMATION'; + } + return undefined; +}; + +const validateInputLineage = ( + input: InventoryReservationEvidenceHandoffInput, +): InventoryReservationEvidenceHandoffRejected['reason'] | undefined => { + const handoffFailure = validateHandoffLineage({ + ...input, + protection: toProtectionHandoffEvidence(input.protection), + }); + if (handoffFailure !== undefined) { + return handoffFailure; + } + const { confirmation, protection, reservation } = input; + const protectedConfirmation = protection.confirmation; + return !sameRef(protectedConfirmation.ref, confirmation.ref) || + !sameRef(protectedConfirmation.reservation.ref, reservation.ref) || + protectedConfirmation.reservation.origin.attemptId !== reservation.origin.attemptId || + protectedConfirmation.reservation.establishedAt !== reservation.establishedAt || + !sameRequirements(protectedConfirmation.reservation.requirements, reservation.requirements) || + !sameBackendConfiguration(protectedConfirmation.reservation.authority, reservation.authority) || + !sameConfirmationAuthorityEvidence(protectedConfirmation.authorityEvidence, confirmation.authorityEvidence) || + !sameIssuanceRank(protectedConfirmation.issuanceRank, confirmation.issuanceRank) || + protectedConfirmation.issuedAt !== confirmation.issuedAt || + protectedConfirmation.expiresAt !== confirmation.expiresAt || + protectedConfirmation.revision > confirmation.revision || + (protectedConfirmation.revision === confirmation.revision && + !sameConfirmationHealth(protectedConfirmation.health, confirmation.health)) + ? 'CONFIRMATION_PROTECTION_MISMATCH' + : undefined; +}; + +const validateCorrectionEvidence = ( + accepted: typeof CatalogToStockBindingSchema.Type, + evidence: InventoryReservationRequirementBindingEvidence, +): InventoryReservationEvidenceHandoffRejected['reason'] | undefined => { + const correction = evidence.currentCorrection; + if (correction === undefined) { + return undefined; + } + const { currentBinding, historyEntry } = correction; + const acceptedAt = DateTime.toEpochMillis(DateTime.makeUnsafe(accepted.effectiveFrom)); + const correctedAt = DateTime.toEpochMillis(DateTime.makeUnsafe(currentBinding.effectiveFrom)); + return historyEntry.transition !== 'CORRECTED' || + !sameBinding(historyEntry.binding, accepted) || + historyEntry.endedAt !== currentBinding.effectiveFrom || + correctedAt <= acceptedAt || + !sameRef(currentBinding.bindingRef, accepted.bindingRef) || + currentBinding.revision <= accepted.revision || + sameRef(currentBinding.stockItemRef, accepted.stockItemRef) || + !sameRef(currentBinding.unitRef, accepted.unitRef) || + !sameCatalogSelection(currentBinding.catalogSelection, accepted.catalogSelection) || + !sameSelectionMeaning(currentBinding.exactSelectionMeaning, accepted.exactSelectionMeaning) + ? 'CORRECTION_EVIDENCE_MISMATCH' + : undefined; +}; + +type BindingEvidenceValidationInput = Pick< + InventoryReservationEvidenceHandoffInput, + 'confirmation' | 'requirementBindingEvidence' | 'reservation' +> & { + readonly protection: Pick; +}; + +const bindingCorrectionObservation = ( + observation: + | (typeof ReservationConfirmationSchema.Type)['health']['observation'] + | InventoryReservationProtectionHandoffEvidence['health']['observation'], +) => + Match.value(observation).pipe( + Match.tag('BINDING_CORRECTION', ({ correctionEvidenceRef, effectiveAt }) => ({ + correctionEvidenceRef, + effectiveAt, + })), + Match.orElse(() => null), + ); + +const validateCorrectionProvenance = ( + input: BindingEvidenceValidationInput, + evidence: InventoryReservationRequirementBindingEvidence, +): InventoryReservationEvidenceHandoffRejected['reason'] | undefined => { + const correction = evidence.currentCorrection; + if (correction === undefined) { + return undefined; + } + const confirmationObservation = bindingCorrectionObservation(input.confirmation.health.observation); + const protectionObservation = bindingCorrectionObservation(input.protection.health.observation); + const { historyEntry } = correction; + return confirmationObservation === null || + protectionObservation === null || + confirmationObservation.correctionEvidenceRef !== historyEntry.ownerEvidenceRef || + protectionObservation.correctionEvidenceRef !== historyEntry.ownerEvidenceRef || + confirmationObservation.effectiveAt !== historyEntry.endedAt || + protectionObservation.effectiveAt !== historyEntry.endedAt + ? 'CORRECTION_PROVENANCE_MISMATCH' + : undefined; +}; + +const validateBindingEvidence = ( + input: BindingEvidenceValidationInput, +): InventoryReservationEvidenceHandoffRejected['reason'] | undefined => { + const evidenceByOccurrence = new Map( + input.requirementBindingEvidence.map((evidence) => [String(evidence.purchaseDemandOccurrenceId), evidence]), + ); + if ( + evidenceByOccurrence.size !== input.requirementBindingEvidence.length || + evidenceByOccurrence.size !== input.reservation.requirements.length + ) { + return 'BINDING_EVIDENCE_MISSING'; + } + let hasCorrection = false; + for (const requirement of input.reservation.requirements) { + const evidence = evidenceByOccurrence.get(String(requirement.purchaseDemandOccurrenceId)); + if (evidence === undefined) { + return 'BINDING_EVIDENCE_MISSING'; + } + const accepted = evidence.acceptedBinding; + if ( + !sameRef(accepted.bindingRef, requirement.bindingRef) || + !sameRef(accepted.stockItemRef, requirement.stockItem.stockItemRef) || + !sameRef(accepted.unitRef, requirement.unitRef) || + !sameCatalogSelection(accepted.catalogSelection, requirement.catalogSelection) || + !sameSelectionMeaning(accepted.exactSelectionMeaning, requirement.exactSelectionMeaning) + ) { + return 'BINDING_EVIDENCE_MISMATCH'; + } + if (evidence.currentCorrection === undefined) { + continue; + } + hasCorrection = true; + const correctionFailure = validateCorrectionEvidence(accepted, evidence); + if (correctionFailure !== undefined) { + return correctionFailure; + } + const provenanceFailure = validateCorrectionProvenance(input, evidence); + if (provenanceFailure !== undefined) { + return provenanceFailure; + } + } + return hasCorrection && + (input.protection.health.state !== 'AT_RISK' || !input.protection.health.reconciliationRequired) + ? 'CORRECTION_HEALTH_MISMATCH' + : undefined; +}; + +const validateSafeOwnerReferences = ( + handoff: Pick & { + readonly safeOwnerReferences: typeof SafeInventoryReservationOwnerReferencesSchema.Type; + }, +): InventoryReservationEvidenceHandoffRejected['reason'] | undefined => { + const { confirmation, protection, safeOwnerReferences } = handoff; + return safeOwnerReferences.confirmationEffectId !== confirmation.authorityEvidence.effectId || + safeOwnerReferences.confirmationOwnerEvidenceRef !== confirmation.authorityEvidence.evidence.ownerEvidenceRef || + safeOwnerReferences.protectionEffectId !== protection.authorityEvidence.effectId || + safeOwnerReferences.protectionOwnerEvidenceRef !== protection.authorityEvidence.evidence.ownerEvidenceRef || + !sameAuthority(safeOwnerReferences.issuer, confirmation.authorityEvidence.issuer) + ? 'AUTHORITY_SCOPE_MISMATCH' + : undefined; +}; + +export const InventoryReservationEvidenceHandoffSchema = InventoryReservationEvidenceHandoffBaseSchema.check( + Schema.makeFilter((handoff) => { + const failure = + validateHandoffLineage(handoff) ?? validateBindingEvidence(handoff) ?? validateSafeOwnerReferences(handoff); + return failure === undefined ? undefined : `Invalid Inventory Reservation evidence handoff: ${failure}`; + }), +); +export type InventoryReservationEvidenceHandoff = typeof InventoryReservationEvidenceHandoffSchema.Type; + +/** + * Builds the Inventory-owned proof-set handoff without importing Order-private + * code. The returned value keeps the actual historical Reservation lineage; + * Current corrections are explanatory evidence and never retarget that lineage. + */ +export const createInventoryReservationEvidenceHandoff = Effect.fn('InventoryReservationEvidenceHandoff.create')( + function* createHandoff(input: InventoryReservationEvidenceHandoffInput) { + const invariantFailure = validateInputLineage(input) ?? validateBindingEvidence(input); + if (invariantFailure !== undefined) { + return yield* rejected(invariantFailure); + } + return yield* Schema.decodeEffect(InventoryReservationEvidenceHandoffSchema)({ + _tag: 'InventoryReservationEvidenceHandoff', + backendFallbackApplied: false, + ...input, + proofSetPlacement: 'ORDER_COMMITMENT_PROOF_SET', + protection: toProtectionHandoffEvidence(input.protection), + reservationConfirmationRenewalSupported: false, + safeOwnerReferences: { + confirmationEffectId: input.confirmation.authorityEvidence.effectId, + confirmationOwnerEvidenceRef: input.confirmation.authorityEvidence.evidence.ownerEvidenceRef, + issuer: input.confirmation.authorityEvidence.issuer, + protectionEffectId: input.protection.authorityEvidence.effectId, + protectionOwnerEvidenceRef: input.protection.authorityEvidence.evidence.ownerEvidenceRef, + }, + }).pipe(Effect.mapError((cause) => Object.assign(rejected('INVALID_HANDOFF'), { cause }))); + }, +); diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-guarantee-unsupported.ts b/app/verticals/inventory/shared/domain/inventory-reservation-guarantee-unsupported.ts new file mode 100644 index 000000000..684bc1cf8 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-guarantee-unsupported.ts @@ -0,0 +1,14 @@ +import { Schema } from 'effect'; + +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; + +export class InventoryReservationGuaranteeUnsupported extends Schema.TaggedError()( + 'InventoryReservationGuaranteeUnsupported', + { + code: Schema.Literal('inventory_reservation_guarantee_unsupported'), + fallbackApplied: Schema.Literal(false), + proofIssued: Schema.Literal(false), + reason: Schema.Literal('selected_backend_does_not_support_required_guarantee'), + selectedBackendId: InventoryBackendIdSchema, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-release-identifiers.ts b/app/verticals/inventory/shared/domain/inventory-reservation-release-identifiers.ts new file mode 100644 index 000000000..38abef5ab --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-release-identifiers.ts @@ -0,0 +1,7 @@ +import { Schema } from 'effect'; + +export const ReservationReleaseEffectIdSchema = Schema.String.check( + Schema.isTrimmed(), + Schema.isMinLength(1), + Schema.isMaxLength(300), +).pipe(Schema.brand('ReservationReleaseEffectId')); diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-release-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-reservation-release-unavailable.ts new file mode 100644 index 000000000..4ca2ecb2c --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-release-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { ReservationReleaseEffectIdSchema } from './inventory-reservation-release-identifiers.ts'; + +export class InventoryReservationReleaseUnavailable extends Schema.TaggedError()( + 'InventoryReservationReleaseUnavailable', + { + code: Schema.Literal('inventory_reservation_release_unavailable'), + effectId: Schema.optionalKey(ReservationReleaseEffectIdSchema), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-reservation-release.ts b/app/verticals/inventory/shared/domain/inventory-reservation-release.ts new file mode 100644 index 000000000..0abc43fa6 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-reservation-release.ts @@ -0,0 +1,220 @@ +import { Schema } from 'effect'; + +import { ProvisionalInventoryReservationSchema } from './inventory-obligation.ts'; +import { ReservationReleaseEffectIdSchema } from './inventory-reservation-release-identifiers.ts'; +import { InventoryReservationReleaseUnavailable } from './inventory-reservation-release-unavailable.ts'; +import { ReservationAuthorityAllocationsSchema, ReservationEvidenceIssuerSchema } from './reservation-authority.ts'; +import { ResolvedCatalogStockDemandSchema } from './catalog-to-stock-binding.ts'; +import { ActionInvocationIdSchema, LegalEntityIdSchema } from './physical-stock-effect.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { OrderCommitmentAttemptIdSchema } from '../inventory-launch-scope.ts'; + +const boundedIdentifier = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const releaseInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export { ReservationReleaseEffectIdSchema } from './inventory-reservation-release-identifiers.ts'; +export const ReservationReleaseMutationIdSchema = Schema.String.check(Schema.isTrimmed(), Schema.isUUID()).pipe( + Schema.brand('ReservationReleaseMutationId'), +); + +export const WholeReservationReleaseScopeSchema = Schema.TaggedStruct('WHOLE_RESERVATION', {}); +export const PartialReservationReleaseScopeSchema = Schema.TaggedStruct('PARTIAL_RESERVATION', { + requirementIds: Schema.Array(ResolvedCatalogStockDemandSchema.fields.purchaseDemandOccurrenceId).check( + Schema.isMinLength(1), + ), +}); +export const ReservationReleaseScopeSchema = Schema.Union([ + WholeReservationReleaseScopeSchema, + PartialReservationReleaseScopeSchema, +]); + +export const ReleaseInventoryReservationPayloadSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + releaseEffectId: ReservationReleaseEffectIdSchema, + reservationRef: InventoryReservationRefSchema, + scope: ReservationReleaseScopeSchema, +}); +export type ReleaseInventoryReservationPayload = typeof ReleaseInventoryReservationPayloadSchema.Type; + +export const ReservationReleaseRequestSchema = Schema.Struct({ + effectId: ReservationReleaseEffectIdSchema, + legalEntityId: LegalEntityIdSchema, + mutationId: ReservationReleaseMutationIdSchema, + requestedAt: releaseInstant, + reservation: ProvisionalInventoryReservationSchema, + sourceActionInvocationId: ActionInvocationIdSchema, +}); +export type ReservationReleaseRequest = typeof ReservationReleaseRequestSchema.Type; + +export const ReservationReleaseNotCommittedClosedTruthSchema = Schema.TaggedStruct('NOT_COMMITTED_CLOSED', { + closureEvidenceRef: boundedIdentifier, + nonCommitEvidenceRef: boundedIdentifier, + observedAt: releaseInstant, +}); +export const ReservationReleaseCommittedTruthSchema = Schema.TaggedStruct('COMMITTED', { + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, +}); +export const ReservationReleaseNotCommittedOpenTruthSchema = Schema.TaggedStruct('NOT_COMMITTED_OPEN', { + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, +}); +export const ReservationReleaseOrderIndeterminateTruthSchema = Schema.TaggedStruct('INDETERMINATE', { + observedAt: releaseInstant, + reason: Schema.Literals(['ORDER_EVIDENCE_MISSING', 'ORDER_EVIDENCE_UNAVAILABLE', 'ORDER_EVIDENCE_INDETERMINATE']), +}); +export const ReservationReleaseOrderTruthSchema = Schema.Union([ + ReservationReleaseNotCommittedClosedTruthSchema, + ReservationReleaseCommittedTruthSchema, + ReservationReleaseNotCommittedOpenTruthSchema, + ReservationReleaseOrderIndeterminateTruthSchema, +]); +export type ReservationReleaseOrderTruth = typeof ReservationReleaseOrderTruthSchema.Type; + +export const ReservationReleaseProtectionAbsentTruthSchema = Schema.TaggedStruct('ABSENT_PROVEN', { + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, +}); +export const ReservationReleaseProtectionEstablishedTruthSchema = Schema.TaggedStruct('ESTABLISHED', { + establishedAt: releaseInstant, + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, +}); +export const ReservationReleaseProtectionIndeterminateTruthSchema = Schema.TaggedStruct('INDETERMINATE', { + observedAt: releaseInstant, + reason: Schema.Literals([ + 'PROTECTION_EVIDENCE_MISSING', + 'PROTECTION_EVIDENCE_UNAVAILABLE', + 'PROTECTION_EVIDENCE_INDETERMINATE', + ]), +}); +export const ReservationReleaseProtectionTruthSchema = Schema.Union([ + ReservationReleaseProtectionAbsentTruthSchema, + ReservationReleaseProtectionEstablishedTruthSchema, + ReservationReleaseProtectionIndeterminateTruthSchema, +]); +export type ReservationReleaseProtectionTruth = typeof ReservationReleaseProtectionTruthSchema.Type; + +export const ReservationReleaseExactScopeSchema = Schema.Struct({ + allocations: ReservationAuthorityAllocationsSchema, + attemptId: OrderCommitmentAttemptIdSchema, + reservationId: InventoryReservationRefSchema.fields.resourceId, + tenantId: InventoryReservationRefSchema.fields.tenantId, +}); + +export const ReservationReleasedBackendObservationSchema = Schema.TaggedStruct('RELEASED', { + effectId: ReservationReleaseEffectIdSchema, + issuer: ReservationEvidenceIssuerSchema, + ownerEvidenceRef: boundedIdentifier, + releasedAt: releaseInstant, + scope: ReservationReleaseExactScopeSchema, +}); +export const ReservationAlreadyReleasedBackendObservationSchema = Schema.TaggedStruct('ALREADY_RELEASED', { + effectId: ReservationReleaseEffectIdSchema, + issuer: ReservationEvidenceIssuerSchema, + ownerEvidenceRef: boundedIdentifier, + releasedAt: releaseInstant, + scope: ReservationReleaseExactScopeSchema, +}); +export const ReservationCommittedBackendObservationSchema = Schema.TaggedStruct('COMMITTED', { + effectId: ReservationReleaseEffectIdSchema, + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, +}); +export const ReservationIndeterminateBackendObservationSchema = Schema.TaggedStruct('INDETERMINATE', { + effectId: ReservationReleaseEffectIdSchema, + observedAt: releaseInstant, + reason: Schema.Literal('AUTHORITY_OUTCOME_UNKNOWN'), +}); +export const ReservationReleaseBackendObservationSchema = Schema.Union([ + ReservationReleasedBackendObservationSchema, + ReservationAlreadyReleasedBackendObservationSchema, + ReservationCommittedBackendObservationSchema, + ReservationIndeterminateBackendObservationSchema, +]); +export type ReservationReleaseBackendObservation = typeof ReservationReleaseBackendObservationSchema.Type; + +export const RequestedReleaseEffectSchema = Schema.TaggedStruct('REQUESTED', { + request: ReservationReleaseRequestSchema, + revision: Schema.Literal(1), +}); +export const ReleasedReservationEffectSchema = Schema.TaggedStruct('RELEASED', { + activeAllocations: Schema.Tuple([]), + authorityIssuer: ReservationEvidenceIssuerSchema, + ownerEvidenceRef: boundedIdentifier, + releasedAt: releaseInstant, + releaseOutcome: Schema.Literals(['RELEASED', 'ALREADY_RELEASED']), + request: ReservationReleaseRequestSchema, + revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(2)), + safelyReusable: Schema.Literal(true), + safeReleaseProof: Schema.Struct({ + order: Schema.TaggedStruct('NOT_COMMITTED_CLOSED', { + closureEvidenceRef: boundedIdentifier, + nonCommitEvidenceRef: boundedIdentifier, + observedAt: releaseInstant, + }), + protection: Schema.TaggedStruct('ABSENT_PROVEN', { + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, + }), + }), +}); +export const NotReleasableReservationEffectSchema = Schema.TaggedStruct('NOT_RELEASABLE', { + evidenceRef: boundedIdentifier, + observedAt: releaseInstant, + reason: Schema.Literals(['COMMITTED', 'PROTECTION_ESTABLISHED']), + request: ReservationReleaseRequestSchema, + revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(2)), + safelyReusable: Schema.Literal(false), +}); +export const IndeterminateReservationReleaseEffectSchema = Schema.TaggedStruct('INDETERMINATE', { + observedAt: releaseInstant, + reason: Schema.Literals(['ORDER_OUTCOME_UNKNOWN', 'PROTECTION_OUTCOME_UNKNOWN', 'AUTHORITY_OUTCOME_UNKNOWN']), + request: ReservationReleaseRequestSchema, + revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(2)), + safelyReusable: Schema.Literal(false), +}); + +export const ReservationReleaseEffectSchema = Schema.Union([ + RequestedReleaseEffectSchema, + ReleasedReservationEffectSchema, + NotReleasableReservationEffectSchema, + IndeterminateReservationReleaseEffectSchema, +]); +export type ReservationReleaseEffect = typeof ReservationReleaseEffectSchema.Type; + +export const ReleaseInventoryReservationResultSchema = Schema.Union([ + Schema.Struct({ effect: RequestedReleaseEffectSchema, outcome: Schema.Literal('PENDING') }), + Schema.Struct({ effect: ReleasedReservationEffectSchema, outcome: Schema.Literal('RELEASED') }), + Schema.Struct({ effect: ReleasedReservationEffectSchema, outcome: Schema.Literal('ALREADY_RELEASED') }), + Schema.Struct({ effect: NotReleasableReservationEffectSchema, outcome: Schema.Literal('NOT_RELEASABLE') }), + Schema.Struct({ effect: IndeterminateReservationReleaseEffectSchema, outcome: Schema.Literal('INDETERMINATE') }), +]); +export type ReleaseInventoryReservationResult = typeof ReleaseInventoryReservationResultSchema.Type; + +export class InventoryReservationReleaseRejected extends Schema.TaggedError()( + 'InventoryReservationReleaseRejected', + { + code: Schema.Literal('inventory_reservation_release_rejected'), + effectId: Schema.optionalKey(ReservationReleaseEffectIdSchema), + reason: Schema.Literals([ + 'PARTIAL_RELEASE_UNSUPPORTED', + 'TENANT_SCOPE_MISMATCH', + 'RESERVATION_NOT_FOUND', + 'RESERVATION_NOT_PROVISIONAL', + 'ATTEMPT_SCOPE_MISMATCH', + 'EFFECT_ID_CONFLICT', + 'SIBLING_RELEASE_EFFECT_FORBIDDEN', + 'INVALID_BACKEND_OBSERVATION', + 'REVISION_CONFLICT', + ]), + }, +) {} + +export const ReleaseInventoryReservationErrorSchema = Schema.Union([ + InventoryReservationReleaseRejected, + InventoryReservationReleaseUnavailable, +]); +export type InventoryReservationReleaseError = typeof ReleaseInventoryReservationErrorSchema.Type; + +export { InventoryReservationReleaseUnavailable } from './inventory-reservation-release-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/inventory-source-assertion-rejected.ts b/app/verticals/inventory/shared/domain/inventory-source-assertion-rejected.ts new file mode 100644 index 000000000..0ac84af65 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-assertion-rejected.ts @@ -0,0 +1,24 @@ +import { Schema } from 'effect'; + +const InventorySourceAssertionIdSchema = Schema.String.check(Schema.isUUID()).pipe( + Schema.brand('InventorySourceAssertionId'), +); + +export class InventorySourceAssertionRejected extends Schema.TaggedError()( + 'InventorySourceAssertionRejected', + { + assertionId: InventorySourceAssertionIdSchema, + code: Schema.Literal('inventory_source_assertion_rejected'), + reason: Schema.Literals([ + 'ASSERTION_ID_CONFLICT', + 'AUTHORITY_SCOPE_MISMATCH', + 'CORRELATION_AMBIGUOUS', + 'CORRELATION_AUTHORITY_MISMATCH', + 'CORRELATION_NOT_FOUND', + 'COVERAGE_EFFECT_NOT_FOUND', + 'INVALID_ASSERTION', + 'POSITION_NOT_FOUND', + 'POSITION_SCOPE_MISMATCH', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-source-assertion-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-source-assertion-unavailable.ts new file mode 100644 index 000000000..29e57b659 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-assertion-unavailable.ts @@ -0,0 +1,15 @@ +import { Schema } from 'effect'; + +const InventorySourceAssertionIdSchema = Schema.String.check(Schema.isUUID()).pipe( + Schema.brand('InventorySourceAssertionId'), +); + +export class InventorySourceAssertionUnavailable extends Schema.TaggedError()( + 'InventorySourceAssertionUnavailable', + { + assertionId: Schema.optionalKey(InventorySourceAssertionIdSchema), + code: Schema.Literal('inventory_source_assertion_unavailable'), + reason: Schema.Literal('Inventory Source Assertion dependency is temporarily unavailable'), + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-source-assertion.ts b/app/verticals/inventory/shared/domain/inventory-source-assertion.ts new file mode 100644 index 000000000..2bb369f5c --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-assertion.ts @@ -0,0 +1,203 @@ +import type { Effect as EffectType, Option } from 'effect'; +import { DateTime, Schema } from 'effect'; + +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockLocationRefSchema } from '../resources/stock-location.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { ExternalStockKeySchema, InventoryBackendOriginSchema } from './external-stock-correlation.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { PhysicalStockEffectIdSchema } from './physical-stock-effect.ts'; +import { StockQuantitySchema } from './stock-position.ts'; +import type { InventorySourceAssertionRejected } from './inventory-source-assertion-rejected.ts'; +import type { InventorySourceAssertionUnavailable } from './inventory-source-assertion-unavailable.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const uuid = Schema.String.check(Schema.isUUID()); + +export const InventorySourceAssertionIdSchema = uuid.pipe(Schema.brand('InventorySourceAssertionId')); +export type InventorySourceAssertionId = typeof InventorySourceAssertionIdSchema.Type; + +export const sourceAssertionBusinessTimeAtOrAfterSelection = ( + businessObservedAt: string, + selectedAt: string, +): boolean => + DateTime.toEpochMillis(DateTime.makeUnsafe(businessObservedAt)) >= + DateTime.toEpochMillis(DateTime.makeUnsafe(selectedAt)); + +export const SourceRevisionOrderingEvidenceSchema = Schema.TaggedStruct('SOURCE_REVISION', { + revision: boundedText, +}); +export const OwnerOrderKeyEvidenceSchema = Schema.TaggedStruct('OWNER_ORDER_KEY', { key: boundedText }); +export const InventorySourceOrderingEvidenceSchema = Schema.Union([ + SourceRevisionOrderingEvidenceSchema, + OwnerOrderKeyEvidenceSchema, +]); +export type InventorySourceOrderingEvidence = typeof InventorySourceOrderingEvidenceSchema.Type; + +export const SourceCoverageRelationSchema = Schema.Literals(['INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN']); + +/** Owner evidence binds one assertion to one already-known authoritative physical effect. */ +export const SourceCoverageEvidenceSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + effectId: PhysicalStockEffectIdSchema, + ownerEvidenceRef: boundedText, + relation: SourceCoverageRelationSchema, +}); +export type SourceCoverageEvidence = typeof SourceCoverageEvidenceSchema.Type; + +const sourceAssertionCommon = { + assertionId: InventorySourceAssertionIdSchema, + businessObservedAt: instant, + coverage: Schema.Array(SourceCoverageEvidenceSchema), + customerConfigurationId: CustomerConfigurationIdSchema, + factMeaning: Schema.Literal('ABSOLUTE_PHYSICAL_ON_HAND'), + issuer: InventoryBackendOriginSchema, + itemExternalKey: ExternalStockKeySchema, + locationExternalKey: ExternalStockKeySchema, + orderingEvidence: InventorySourceOrderingEvidenceSchema, + ownerEvidenceRef: boundedText, + positionRef: StockPositionRefSchema, + quantity: StockQuantitySchema, + receivedAt: instant, + sourceReference: boundedText, +} as const; + +const proposalInvariant = (proposal: { + readonly assertionId: InventorySourceAssertionId; + readonly coverage: readonly SourceCoverageEvidence[]; + readonly customerConfigurationId: string; + readonly issuer: { readonly backendId: string; readonly backendKind: string }; + readonly itemExternalKey: typeof ExternalStockKeySchema.Type; + readonly locationExternalKey: typeof ExternalStockKeySchema.Type; + readonly positionRef: typeof StockPositionRefSchema.Type; + readonly quantity: typeof StockQuantitySchema.Type; +}): string | undefined => { + if (proposal.issuer.backendKind !== 'external_business_system') { + return 'Inventory Source Assertions must retain an External Business System issuer'; + } + if ( + proposal.itemExternalKey.identifierKind !== 'ITEM' || + proposal.locationExternalKey.identifierKind !== 'LOCATION' + ) { + return 'Source assertion correlations must use exact Item and Location identifier kinds'; + } + const keys = [proposal.itemExternalKey, proposal.locationExternalKey]; + if ( + keys.some( + (key) => + key.tenantId !== proposal.positionRef.tenantId || + key.tenantId !== proposal.quantity.unitRef.tenantId || + key.customerConfigurationId !== proposal.customerConfigurationId || + key.issuer.backendId !== proposal.issuer.backendId || + key.issuer.backendKind !== proposal.issuer.backendKind, + ) + ) { + return 'Source assertion issuer, Customer Configuration, Position, Unit, and correlation keys must share one exact scope'; + } + let coverageError: string | undefined; + if (proposal.coverage.some((coverage) => coverage.assertionId !== proposal.assertionId)) { + coverageError = 'Source Coverage Evidence must bind the exact source assertion identity'; + } else if (new Set(proposal.coverage.map(({ effectId }) => effectId)).size !== proposal.coverage.length) { + coverageError = 'Source Coverage Evidence must be unique for each exact physical effect'; + } + return coverageError; +}; + +export const InventorySourceAssertionProposalSchema = Schema.Struct(sourceAssertionCommon).check( + Schema.makeFilter(proposalInvariant), +); +export type InventorySourceAssertionProposal = typeof InventorySourceAssertionProposalSchema.Type; + +export const InventorySourceAssertionSchema = Schema.Struct({ + ...sourceAssertionCommon, + authorityConfiguration: InventoryBackendConfigurationSchema, + issuerAuthority: Schema.Literals(['SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER']), + itemCorrelationRef: ExternalStockCorrelationRefSchema, + locationCorrelationRef: ExternalStockCorrelationRefSchema, + stockItemRef: StockItemRefSchema, + stockLocationRef: StockLocationRefSchema, +}).check( + Schema.makeFilter((assertion) => { + const proposalError = proposalInvariant(assertion); + if (proposalError !== undefined) { + return proposalError; + } + if ( + assertion.authorityConfiguration.tenantId !== assertion.positionRef.tenantId || + assertion.authorityConfiguration.customerConfigurationId !== assertion.customerConfigurationId + ) { + return 'Source assertion authority configuration must belong to the exact Tenant and Customer Configuration'; + } + const selectedIssuer = + assertion.authorityConfiguration.selection.backend === assertion.issuer.backendKind && + assertion.authorityConfiguration.selection.backendId === assertion.issuer.backendId && + sourceAssertionBusinessTimeAtOrAfterSelection( + assertion.businessObservedAt, + assertion.authorityConfiguration.selectedAt, + ); + if ( + (assertion.issuerAuthority === 'SELECTED_BACKEND' && !selectedIssuer) || + (assertion.issuerAuthority === 'HISTORICAL_PRE_CUTOVER_ISSUER' && selectedIssuer) + ) { + return 'Source assertion issuer authority must match the evaluated backend configuration evidence'; + } + const { tenantId } = assertion.positionRef; + return assertion.itemCorrelationRef.tenantId === tenantId && + assertion.locationCorrelationRef.tenantId === tenantId && + assertion.stockItemRef.tenantId === tenantId && + assertion.stockLocationRef.tenantId === tenantId + ? undefined + : 'Resolved assertion correlations and stock scope must share one Tenant'; + }), +); +export type InventorySourceAssertion = typeof InventorySourceAssertionSchema.Type; + +const evaluationCommon = { + assertion: InventorySourceAssertionSchema, + postEffectOnHand: Schema.toEncoded(Schema.OptionFromNullOr(StockQuantitySchema)), + reconciliationRequired: Schema.Boolean, +} as const; + +export const DeterminateInventorySourceAssertionEvaluationSchema = Schema.TaggedStruct('DETERMINATE', { + ...evaluationCommon, + postEffectOnHand: StockQuantitySchema, + reconciliationRequired: Schema.Literal(false), +}); +export const HistoricalInventorySourceAssertionEvaluationSchema = Schema.TaggedStruct('HISTORICAL', { + ...evaluationCommon, + postEffectOnHand: Schema.Null, + reason: Schema.Literals(['ISSUER_OUTSIDE_SELECTED_BACKEND', 'MATERIAL_EFFECT_EXCLUDED_OR_PREDATED']), + reconciliationRequired: Schema.Literal(false), +}); +export const IndeterminateInventorySourceAssertionEvaluationSchema = Schema.TaggedStruct('INDETERMINATE', { + ...evaluationCommon, + materialEffectIds: Schema.Array(PhysicalStockEffectIdSchema), + postEffectOnHand: Schema.Null, + reason: Schema.Literals(['MATERIAL_EFFECT_COVERAGE_MISSING', 'MATERIAL_EFFECT_COVERAGE_UNKNOWN']), + reconciliationRequired: Schema.Literal(true), +}); +export const InventorySourceAssertionEvaluationSchema = Schema.Union([ + DeterminateInventorySourceAssertionEvaluationSchema, + HistoricalInventorySourceAssertionEvaluationSchema, + IndeterminateInventorySourceAssertionEvaluationSchema, +]); +export type InventorySourceAssertionEvaluation = typeof InventorySourceAssertionEvaluationSchema.Type; + +export type InventorySourceAssertionPersistenceError = + | InventorySourceAssertionRejected + | InventorySourceAssertionUnavailable; + +export interface InventorySourceAssertionPersistence { + readonly append: ( + assertion: InventorySourceAssertion, + ) => EffectType.Effect; + readonly findById: ( + assertionId: InventorySourceAssertionId, + ) => EffectType.Effect, InventorySourceAssertionPersistenceError>; +} + +export { InventorySourceAssertionRejected } from './inventory-source-assertion-rejected.ts'; +export { InventorySourceAssertionUnavailable } from './inventory-source-assertion-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/inventory-source-conflict-not-found.ts b/app/verticals/inventory/shared/domain/inventory-source-conflict-not-found.ts new file mode 100644 index 000000000..c02c2ae55 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-conflict-not-found.ts @@ -0,0 +1,11 @@ +import { Schema } from 'effect'; + +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; + +export class InventorySourceConflictNotFound extends Schema.TaggedError()( + 'InventorySourceConflictNotFound', + { + code: Schema.Literal('inventory_source_conflict_not_found'), + conflictRef: InventorySourceConflictRefSchema, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-source-conflict-rejected.ts b/app/verticals/inventory/shared/domain/inventory-source-conflict-rejected.ts new file mode 100644 index 000000000..ee0345cdc --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-conflict-rejected.ts @@ -0,0 +1,31 @@ +import { Schema } from 'effect'; + +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; + +export class InventorySourceConflictRejected extends Schema.TaggedError()( + 'InventorySourceConflictRejected', + { + code: Schema.Literal('inventory_source_conflict_rejected'), + conflictRef: InventorySourceConflictRefSchema, + reason: Schema.Literals([ + 'ALREADY_RESOLVED', + 'ASSERTION_AUTHORITY_MISMATCH', + 'ASSERTION_NOT_FOUND', + 'BACKEND_CONFIGURATION_NOT_FOUND', + 'BACKEND_CONFIGURATION_NOT_SINGULAR', + 'CONFLICT_ID_CONFLICT', + 'CONFLICT_REVISION_CONFLICT', + 'CURRENT_RESULT_NOT_ESTABLISHED', + 'INVALID_ASSERTION_INTEGRITY_CONFLICT', + 'INVALID_BACKEND_CONFIGURATION_CONFLICT', + 'INVALID_CORRELATION_CONFLICT', + 'INVALID_FACT_VALUE_CONFLICT', + 'POSITION_NOT_CURRENT', + 'POSITION_NOT_FOUND', + 'POSITION_REVISION_CONFLICT', + 'RESOLUTION_TIME_BEFORE_DETECTION', + 'RESOLUTION_TYPE_MISMATCH', + 'TENANT_SCOPE_MISMATCH', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-source-conflict-unavailable.ts b/app/verticals/inventory/shared/domain/inventory-source-conflict-unavailable.ts new file mode 100644 index 000000000..1e1fedc82 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-conflict-unavailable.ts @@ -0,0 +1,10 @@ +import { Schema } from 'effect'; + +export class InventorySourceConflictUnavailable extends Schema.TaggedError()( + 'InventorySourceConflictUnavailable', + { + code: Schema.Literal('inventory_source_conflict_unavailable'), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/inventory-source-conflict.ts b/app/verticals/inventory/shared/domain/inventory-source-conflict.ts new file mode 100644 index 000000000..b055ee73c --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-conflict.ts @@ -0,0 +1,482 @@ +import { Effect, Schema } from 'effect'; + +import { + InventorySourceAssertionIdSchema, + InventorySourceAssertionProposalSchema, + InventorySourceAssertionSchema, + sourceAssertionBusinessTimeAtOrAfterSelection, +} from './inventory-source-assertion.ts'; +import type { InventorySourceAssertionProposal } from './inventory-source-assertion.ts'; +import { + inventorySourceAssertionsClaimSameIdentityOrRevision, + compareInventorySourceOrdering, + inventorySourceAssertionsHaveSameMaterialContent, + inventorySourceAssertionsShareStream, +} from './inventory-source-ordering.ts'; +import { + InventoryBackendConfigurationSchema, + InventoryBackendSelectionSchema, +} from './inventory-backend-configuration.ts'; +import { ExternalStockKeySchema } from './external-stock-correlation.ts'; +import { InventorySourceConflictNotFound } from './inventory-source-conflict-not-found.ts'; +import { InventorySourceConflictRejected } from './inventory-source-conflict-rejected.ts'; +import { InventorySourceConflictUnavailable } from './inventory-source-conflict-unavailable.ts'; +import { StockQuantitySchema } from './stock-position.ts'; +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { ExternalStockCorrelationRefSchema } from '../resources/external-stock-correlation.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const positiveRevision = Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })); + +export const InventorySourceConflictTypeSchema = Schema.Literals([ + 'CORRELATION', + 'FACT_VALUE', + 'BACKEND_CONFIGURATION', + 'ASSERTION_INTEGRITY', +]); + +export const StockPositionFactConflictScopeSchema = Schema.TaggedStruct('STOCK_POSITION_FACT', { + customerConfigurationId: CustomerConfigurationIdSchema, + factMeaning: Schema.Literal('ABSOLUTE_PHYSICAL_ON_HAND'), + positionRef: StockPositionRefSchema, + unitRef: StockQuantitySchema.fields.unitRef, +}); +export const CustomerConfigurationConflictScopeSchema = Schema.TaggedStruct('CUSTOMER_CONFIGURATION', { + customerConfigurationId: CustomerConfigurationIdSchema, + tenantId: InventorySourceConflictRefSchema.fields.tenantId, +}); +export const ExternalCorrelationConflictScopeSchema = Schema.TaggedStruct('EXTERNAL_CORRELATION', { + ambiguousExternalKey: ExternalStockKeySchema, + customerConfigurationId: CustomerConfigurationIdSchema, + tenantId: InventorySourceConflictRefSchema.fields.tenantId, +}); +export const InventorySourceConflictScopeSchema = Schema.Union([ + StockPositionFactConflictScopeSchema, + CustomerConfigurationConflictScopeSchema, + ExternalCorrelationConflictScopeSchema, +]); + +const openCommon = { + authorityConfiguration: InventoryBackendConfigurationSchema, + conflictRef: InventorySourceConflictRefSchema, + currentTruth: Schema.Literal('INDETERMINATE'), + detectedAt: instant, + revision: Schema.Literal(1), + status: Schema.Literal('OPEN'), +} as const; + +export const CorrelationConflictEvidenceSchema = Schema.Struct({ + ambiguousExternalKey: ExternalStockKeySchema, + candidateCorrelationRefs: Schema.Array(ExternalStockCorrelationRefSchema).check(Schema.isMinLength(2)), + proposal: InventorySourceAssertionProposalSchema, +}); + +export const OpenCorrelationInventorySourceConflictSchema = Schema.Struct({ + ...openCommon, + conflictType: Schema.Literal('CORRELATION'), + evidence: CorrelationConflictEvidenceSchema, + scope: ExternalCorrelationConflictScopeSchema, +}); +export const OpenFactValueInventorySourceConflictSchema = Schema.Struct({ + ...openCommon, + conflictType: Schema.Literal('FACT_VALUE'), + evidence: Schema.Array(InventorySourceAssertionProposalSchema).check(Schema.isMinLength(2)), + scope: StockPositionFactConflictScopeSchema, +}); +export const OpenBackendConfigurationInventorySourceConflictSchema = Schema.Struct({ + ...openCommon, + conflictType: Schema.Literal('BACKEND_CONFIGURATION'), + currentTruth: Schema.Literal('INDETERMINATE'), + evidence: Schema.Struct({ + attemptedSelection: InventoryBackendSelectionSchema, + ownerEvidenceRef: boundedText, + selectedConfiguration: InventoryBackendConfigurationSchema, + }), + scope: CustomerConfigurationConflictScopeSchema, +}); +export const OpenAssertionIntegrityInventorySourceConflictSchema = Schema.Struct({ + ...openCommon, + conflictType: Schema.Literal('ASSERTION_INTEGRITY'), + evidence: Schema.Tuple([InventorySourceAssertionProposalSchema, InventorySourceAssertionProposalSchema]), + scope: StockPositionFactConflictScopeSchema, +}); +export const InventorySourceConflictOpenSchema = Schema.Union([ + OpenCorrelationInventorySourceConflictSchema, + OpenFactValueInventorySourceConflictSchema, + OpenBackendConfigurationInventorySourceConflictSchema, + OpenAssertionIntegrityInventorySourceConflictSchema, +]); +export type InventorySourceConflictOpen = typeof InventorySourceConflictOpenSchema.Type; + +export const CurrentAssertionConflictResolutionInputSchema = Schema.TaggedStruct('CURRENT_ASSERTION', { + assertionId: InventorySourceAssertionIdSchema, +}); +export const BackendConfigurationConflictResolutionInputSchema = Schema.TaggedStruct('BACKEND_CONFIGURATION', { + configurationId: InventoryBackendConfigurationSchema.fields.configurationId, +}); +export const InventorySourceConflictResolutionInputSchema = Schema.Struct({ + conflictRef: InventorySourceConflictRefSchema, + expectedRevision: positiveRevision, + ownerEvidenceRef: boundedText, + resolution: Schema.Union([ + CurrentAssertionConflictResolutionInputSchema, + BackendConfigurationConflictResolutionInputSchema, + ]), + resolvedAt: instant, +}); +export type InventorySourceConflictResolutionInput = typeof InventorySourceConflictResolutionInputSchema.Type; + +const resolutionCommon = { + ownerEvidenceRef: boundedText, + principalId: boundedText, + resolvedAt: instant, +} as const; +export const CurrentAssertionConflictResolutionSchema = Schema.TaggedStruct('CURRENT_ASSERTION', { + ...resolutionCommon, + assertion: InventorySourceAssertionSchema, +}); +export const BackendConfigurationConflictResolutionSchema = Schema.TaggedStruct('BACKEND_CONFIGURATION', { + ...resolutionCommon, + configuration: InventoryBackendConfigurationSchema, +}); +export const InventorySourceConflictResolutionSchema = Schema.Union([ + CurrentAssertionConflictResolutionSchema, + BackendConfigurationConflictResolutionSchema, +]); + +export const InventorySourceConflictResolvedSchema = Schema.Struct({ + authorityConfiguration: InventoryBackendConfigurationSchema, + conflictRef: InventorySourceConflictRefSchema, + conflictType: InventorySourceConflictTypeSchema, + currentTruth: Schema.Literals(['CURRENT', 'CONFIGURATION_SINGULAR']), + detectedAt: instant, + originalEvidence: Schema.Union([ + CorrelationConflictEvidenceSchema, + Schema.Array(InventorySourceAssertionProposalSchema).check(Schema.isMinLength(2)), + OpenBackendConfigurationInventorySourceConflictSchema.fields.evidence, + OpenAssertionIntegrityInventorySourceConflictSchema.fields.evidence, + ]), + resolution: InventorySourceConflictResolutionSchema, + revision: Schema.Literal(2), + scope: InventorySourceConflictScopeSchema, + status: Schema.Literal('RESOLVED'), +}); +export type InventorySourceConflictResolved = typeof InventorySourceConflictResolvedSchema.Type; + +export const InventorySourceConflictSchema = Schema.Union([ + InventorySourceConflictOpenSchema, + InventorySourceConflictResolvedSchema, +]); +export type InventorySourceConflict = typeof InventorySourceConflictSchema.Type; + +export const externalStockKeysAreEqual = ( + left: typeof ExternalStockKeySchema.Type, + right: typeof ExternalStockKeySchema.Type, +) => + left.identifierKind === right.identifierKind && + left.tenantId === right.tenantId && + left.customerConfigurationId === right.customerConfigurationId && + left.externalValue === right.externalValue && + left.namespace === right.namespace && + left.externalScope === right.externalScope && + left.issuer.backendId === right.issuer.backendId && + left.issuer.backendKind === right.issuer.backendKind; + +const replayProposalsAreEquivalent = ( + left: readonly InventorySourceAssertionProposal[], + right: readonly InventorySourceAssertionProposal[], +) => + left.length === right.length && + left.every((proposal) => + right.some( + (candidate) => + candidate.assertionId === proposal.assertionId && + inventorySourceAssertionsHaveSameMaterialContent(candidate, proposal), + ), + ); + +/** Exact replay ignores transport arrival/detection representation but retains all owner material evidence. */ +export const inventorySourceConflictsHaveSameOpenEvidence = ( + left: InventorySourceConflictOpen, + right: InventorySourceConflictOpen, +): boolean => { + if ( + left.conflictType !== right.conflictType || + !Schema.toEquivalence(InventoryBackendConfigurationSchema)( + left.authorityConfiguration, + right.authorityConfiguration, + ) || + !Schema.toEquivalence(InventorySourceConflictScopeSchema)(left.scope, right.scope) + ) { + return false; + } + if ( + Schema.is(OpenCorrelationInventorySourceConflictSchema)(left) && + Schema.is(OpenCorrelationInventorySourceConflictSchema)(right) + ) { + const leftRefs = left.evidence.candidateCorrelationRefs + .map((reference) => `${reference.tenantId}:${reference.resourceId}`) + .toSorted(); + const rightRefs = right.evidence.candidateCorrelationRefs + .map((reference) => `${reference.tenantId}:${reference.resourceId}`) + .toSorted(); + return ( + externalStockKeysAreEqual(left.evidence.ambiguousExternalKey, right.evidence.ambiguousExternalKey) && + leftRefs.length === rightRefs.length && + leftRefs.every((reference, index) => reference === rightRefs[index]) && + left.evidence.proposal.assertionId === right.evidence.proposal.assertionId && + inventorySourceAssertionsHaveSameMaterialContent(left.evidence.proposal, right.evidence.proposal) + ); + } + if ( + Schema.is(OpenFactValueInventorySourceConflictSchema)(left) && + Schema.is(OpenFactValueInventorySourceConflictSchema)(right) + ) { + return replayProposalsAreEquivalent(left.evidence, right.evidence); + } + if ( + Schema.is(OpenAssertionIntegrityInventorySourceConflictSchema)(left) && + Schema.is(OpenAssertionIntegrityInventorySourceConflictSchema)(right) + ) { + return replayProposalsAreEquivalent(left.evidence, right.evidence); + } + return ( + Schema.is(OpenBackendConfigurationInventorySourceConflictSchema)(left) && + Schema.is(OpenBackendConfigurationInventorySourceConflictSchema)(right) && + Schema.toEquivalence(OpenBackendConfigurationInventorySourceConflictSchema.fields.evidence)( + left.evidence, + right.evidence, + ) + ); +}; + +export const CorrelationConflictCandidateSchema = Schema.TaggedStruct('CORRELATION', { + ambiguousExternalKey: ExternalStockKeySchema, + candidateCorrelationRefs: Schema.Array(ExternalStockCorrelationRefSchema).check(Schema.isMinLength(2)), + conflictRef: InventorySourceConflictRefSchema, + detectedAt: instant, + proposal: InventorySourceAssertionProposalSchema, + selectedConfiguration: InventoryBackendConfigurationSchema, +}); +export const FactValueConflictCandidateSchema = Schema.TaggedStruct('FACT_VALUE', { + conflictRef: InventorySourceConflictRefSchema, + detectedAt: instant, + evidence: Schema.Array(InventorySourceAssertionProposalSchema).check(Schema.isMinLength(2)), + selectedConfiguration: InventoryBackendConfigurationSchema, +}); +export const BackendConfigurationConflictCandidateSchema = Schema.TaggedStruct('BACKEND_CONFIGURATION', { + attemptedSelection: InventoryBackendSelectionSchema, + conflictRef: InventorySourceConflictRefSchema, + detectedAt: instant, + ownerEvidenceRef: boundedText, + selectedConfiguration: InventoryBackendConfigurationSchema, +}); +export const AssertionIntegrityConflictCandidateSchema = Schema.TaggedStruct('ASSERTION_INTEGRITY', { + accepted: InventorySourceAssertionProposalSchema, + conflictRef: InventorySourceConflictRefSchema, + detectedAt: instant, + incoming: InventorySourceAssertionProposalSchema, + selectedConfiguration: InventoryBackendConfigurationSchema, +}); +export const InventorySourceConflictCandidateSchema = Schema.Union([ + CorrelationConflictCandidateSchema, + FactValueConflictCandidateSchema, + BackendConfigurationConflictCandidateSchema, + AssertionIntegrityConflictCandidateSchema, +]); +export type InventorySourceConflictCandidate = typeof InventorySourceConflictCandidateSchema.Type; + +const sameUnit = ( + left: InventorySourceAssertionProposal['quantity']['unitRef'], + right: InventorySourceAssertionProposal['quantity']['unitRef'], +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const exactFactScope = (proposal: InventorySourceAssertionProposal) => ({ + _tag: 'STOCK_POSITION_FACT' as const, + customerConfigurationId: proposal.customerConfigurationId, + factMeaning: proposal.factMeaning, + positionRef: proposal.positionRef, + unitRef: proposal.quantity.unitRef, +}); + +const candidatesShareExactScope = (evidence: readonly InventorySourceAssertionProposal[]) => { + const [first, ...rest] = evidence; + return ( + first !== undefined && + rest.every( + (candidate) => + inventorySourceAssertionsShareStream(candidate, first) && + sameUnit(candidate.quantity.unitRef, first.quantity.unitRef), + ) + ); +}; + +const selectedConfigurationAuthorizes = ( + configuration: typeof InventoryBackendConfigurationSchema.Type, + proposal: InventorySourceAssertionProposal, +) => + configuration.tenantId === proposal.positionRef.tenantId && + configuration.customerConfigurationId === proposal.customerConfigurationId && + configuration.selection.backend === proposal.issuer.backendKind && + configuration.selection.backendId === proposal.issuer.backendId && + sourceAssertionBusinessTimeAtOrAfterSelection(proposal.businessObservedAt, configuration.selectedAt); + +export const InventorySourceConflictErrorSchema = Schema.Union([ + InventorySourceConflictNotFound, + InventorySourceConflictRejected, + InventorySourceConflictUnavailable, +]); +export type InventorySourceConflictError = typeof InventorySourceConflictErrorSchema.Type; + +const invalidCandidate = ( + candidate: InventorySourceConflictCandidate, + reason: InventorySourceConflictRejected['reason'], +): InventorySourceConflictRejected => + new InventorySourceConflictRejected({ + code: 'inventory_source_conflict_rejected', + conflictRef: candidate.conflictRef, + reason, + }); + +/** Pure classification retains source owner evidence while transport arrival never selects Current truth. */ +/* oxlint-disable eslint/complexity, effect-native/no-manual-tag-comparison -- Classification keeps the four fail-closed schema variants and exact evidence checks together; expires: 2027-03-31. */ +export const classifyInventorySourceConflict = ( + candidate: InventorySourceConflictCandidate, +): Effect.Effect => { + if (candidate._tag === 'FACT_VALUE') { + const [first] = candidate.evidence; + if ( + first === undefined || + !candidatesShareExactScope(candidate.evidence) || + candidate.evidence.some( + (proposal) => !selectedConfigurationAuthorizes(candidate.selectedConfiguration, proposal), + ) || + candidate.evidence.some((proposal, index) => + candidate.evidence + .slice(index + 1) + .some( + (other) => + compareInventorySourceOrdering(proposal.orderingEvidence, other.orderingEvidence) !== 'INCOMPARABLE', + ), + ) || + new Set(candidate.evidence.map(({ quantity }) => quantity.amount)).size < 2 + ) { + return Effect.fail(invalidCandidate(candidate, 'INVALID_FACT_VALUE_CONFLICT')); + } + return Effect.succeed({ + authorityConfiguration: candidate.selectedConfiguration, + conflictRef: candidate.conflictRef, + conflictType: 'FACT_VALUE', + currentTruth: 'INDETERMINATE', + detectedAt: candidate.detectedAt, + evidence: candidate.evidence, + revision: 1, + scope: exactFactScope(first), + status: 'OPEN', + }); + } + if (candidate._tag === 'ASSERTION_INTEGRITY') { + if ( + !inventorySourceAssertionsClaimSameIdentityOrRevision(candidate.incoming, candidate.accepted) || + inventorySourceAssertionsHaveSameMaterialContent(candidate.incoming, candidate.accepted) || + !candidatesShareExactScope([candidate.accepted, candidate.incoming]) || + !selectedConfigurationAuthorizes(candidate.selectedConfiguration, candidate.accepted) || + !selectedConfigurationAuthorizes(candidate.selectedConfiguration, candidate.incoming) + ) { + return Effect.fail(invalidCandidate(candidate, 'INVALID_ASSERTION_INTEGRITY_CONFLICT')); + } + return Effect.succeed({ + authorityConfiguration: candidate.selectedConfiguration, + conflictRef: candidate.conflictRef, + conflictType: 'ASSERTION_INTEGRITY', + currentTruth: 'INDETERMINATE', + detectedAt: candidate.detectedAt, + evidence: [candidate.accepted, candidate.incoming], + revision: 1, + scope: exactFactScope(candidate.accepted), + status: 'OPEN', + }); + } + if (candidate._tag === 'CORRELATION') { + const exactKey = + candidate.ambiguousExternalKey.identifierKind === 'ITEM' + ? candidate.proposal.itemExternalKey + : candidate.proposal.locationExternalKey; + const candidateIdentities = candidate.candidateCorrelationRefs.map( + (reference) => `${reference.tenantId}:${reference.resourceId}`, + ); + if ( + !externalStockKeysAreEqual(exactKey, candidate.ambiguousExternalKey) || + String(candidate.ambiguousExternalKey.tenantId) !== String(candidate.conflictRef.tenantId) || + candidate.ambiguousExternalKey.customerConfigurationId !== + candidate.selectedConfiguration.customerConfigurationId || + candidate.candidateCorrelationRefs.some( + (reference) => String(reference.tenantId) !== String(candidate.conflictRef.tenantId), + ) || + new Set(candidateIdentities).size !== candidateIdentities.length || + !selectedConfigurationAuthorizes(candidate.selectedConfiguration, candidate.proposal) + ) { + return Effect.fail(invalidCandidate(candidate, 'INVALID_CORRELATION_CONFLICT')); + } + return Effect.succeed({ + authorityConfiguration: candidate.selectedConfiguration, + conflictRef: candidate.conflictRef, + conflictType: 'CORRELATION', + currentTruth: 'INDETERMINATE', + detectedAt: candidate.detectedAt, + evidence: { + ambiguousExternalKey: candidate.ambiguousExternalKey, + candidateCorrelationRefs: candidate.candidateCorrelationRefs, + proposal: candidate.proposal, + }, + revision: 1, + scope: { + _tag: 'EXTERNAL_CORRELATION', + ambiguousExternalKey: candidate.ambiguousExternalKey, + customerConfigurationId: candidate.ambiguousExternalKey.customerConfigurationId, + tenantId: candidate.conflictRef.tenantId, + }, + status: 'OPEN', + }); + } + const selected = candidate.selectedConfiguration; + const attempted = candidate.attemptedSelection; + if ( + String(selected.tenantId) !== String(candidate.conflictRef.tenantId) || + selected.selection.backend === attempted.backend || + new Set([selected.selection.backend, attempted.backend]).size !== 2 + ) { + return Effect.fail(invalidCandidate(candidate, 'INVALID_BACKEND_CONFIGURATION_CONFLICT')); + } + return Effect.succeed({ + authorityConfiguration: selected, + conflictRef: candidate.conflictRef, + conflictType: 'BACKEND_CONFIGURATION', + currentTruth: 'INDETERMINATE', + detectedAt: candidate.detectedAt, + evidence: { + attemptedSelection: attempted, + ownerEvidenceRef: candidate.ownerEvidenceRef, + selectedConfiguration: selected, + }, + revision: 1, + scope: { + _tag: 'CUSTOMER_CONFIGURATION', + customerConfigurationId: selected.customerConfigurationId, + tenantId: candidate.conflictRef.tenantId, + }, + status: 'OPEN', + }); +}; +/* oxlint-enable eslint/complexity, effect-native/no-manual-tag-comparison */ + +export { InventorySourceConflictNotFound } from './inventory-source-conflict-not-found.ts'; +export { InventorySourceConflictRejected } from './inventory-source-conflict-rejected.ts'; +export { InventorySourceConflictUnavailable } from './inventory-source-conflict-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/inventory-source-import-outcome.ts b/app/verticals/inventory/shared/domain/inventory-source-import-outcome.ts new file mode 100644 index 000000000..3b5f74a4d --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-import-outcome.ts @@ -0,0 +1,167 @@ +import type { Effect as EffectType, Option } from 'effect'; +import { Schema } from 'effect'; + +import { + InventorySourceAssertionIdSchema, + InventorySourceAssertionProposalSchema, +} from './inventory-source-assertion.ts'; +import type { InventorySourceAssertionProposal } from './inventory-source-assertion.ts'; +import { + compareInventorySourceOrdering, + inventorySourceAssertionsClaimSameIdentityOrRevision, + inventorySourceAssertionsHaveSameMaterialContent, + inventorySourceAssertionsShareStream, +} from './inventory-source-ordering.ts'; +import { StockQuantitySchema } from './stock-position.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; + +const reason = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +export const InventorySourceImportActionInvocationIdSchema = Schema.String.check(Schema.isUUID()).pipe( + Schema.brand('ActionInvocationId'), +); +export type InventorySourceImportActionInvocationId = typeof InventorySourceImportActionInvocationIdSchema.Type; + +export const AcceptedInventorySourceImportOutcomeSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + postEffectOnHand: StockQuantitySchema, + status: Schema.Literal('ACCEPTED'), +}); +export const DuplicateInventorySourceImportOutcomeSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + duplicateOfAssertionId: InventorySourceAssertionIdSchema, + reason, + status: Schema.Literal('DUPLICATE'), +}); +export const StaleInventorySourceImportOutcomeSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + currentAssertionId: Schema.optionalKey(InventorySourceAssertionIdSchema), + reason, + status: Schema.Literal('STALE'), +}); +export const RejectedInventorySourceImportOutcomeSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + reason, + status: Schema.Literal('REJECTED'), +}); +export const ReconciliationIndeterminateInventorySourceImportOutcomeSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + reason: reason.check( + Schema.makeFilter((value) => + value === 'INVENTORY_SOURCE_CONFLICT' + ? 'Inventory Source Conflict outcomes require exact conflict refs' + : undefined, + ), + ), + reconciliationRequired: Schema.Literal(true), + status: Schema.Literal('INDETERMINATE'), +}); +export const ConflictIndeterminateInventorySourceImportOutcomeSchema = Schema.Struct({ + assertionId: InventorySourceAssertionIdSchema, + conflictRefs: Schema.Array(InventorySourceConflictRefSchema).check(Schema.isMinLength(1)), + reason: Schema.Literal('INVENTORY_SOURCE_CONFLICT'), + reconciliationRequired: Schema.Literal(true), + status: Schema.Literal('INDETERMINATE'), +}); +export const IndeterminateInventorySourceImportOutcomeSchema = Schema.Union([ + ReconciliationIndeterminateInventorySourceImportOutcomeSchema, + ConflictIndeterminateInventorySourceImportOutcomeSchema, +]); + +export const InventorySourceImportOutcomeSchema = Schema.Union([ + AcceptedInventorySourceImportOutcomeSchema, + DuplicateInventorySourceImportOutcomeSchema, + StaleInventorySourceImportOutcomeSchema, + RejectedInventorySourceImportOutcomeSchema, + IndeterminateInventorySourceImportOutcomeSchema, +]); +export type InventorySourceImportOutcome = typeof InventorySourceImportOutcomeSchema.Type; + +export const InventorySourceImportLedgerEntrySchema = Schema.Struct({ + actionInvocationId: InventorySourceImportActionInvocationIdSchema, + itemIndex: Schema.Number.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)), + outcome: InventorySourceImportOutcomeSchema, + proposal: InventorySourceAssertionProposalSchema, +}); +export type InventorySourceImportLedgerEntry = typeof InventorySourceImportLedgerEntrySchema.Type; + +export class InventorySourceImportUnavailable extends Schema.TaggedError()( + 'InventorySourceImportUnavailable', + { + code: Schema.Literal('inventory_source_import_unavailable'), + reason: Schema.Literal('Inventory Source Import persistence is temporarily unavailable'), + retryable: Schema.Literal(true), + }, +) {} + +export interface InventorySourceImportLedgerPersistence { + readonly append: ( + entry: InventorySourceImportLedgerEntry, + ) => EffectType.Effect; + readonly findByInvocationItem: ( + actionInvocationId: InventorySourceImportActionInvocationId, + itemIndex: number, + ) => EffectType.Effect, InventorySourceImportUnavailable>; + readonly lockAndReadAcceptedHistory: ( + proposal: InventorySourceAssertionProposal, + ) => EffectType.Effect; +} + +export const InventorySourceImportPreflightDecisionSchema = Schema.Union([ + Schema.Struct({ status: Schema.Literal('CANDIDATE') }), + DuplicateInventorySourceImportOutcomeSchema, + StaleInventorySourceImportOutcomeSchema, + IndeterminateInventorySourceImportOutcomeSchema, +]); +export type InventorySourceImportPreflightDecision = typeof InventorySourceImportPreflightDecisionSchema.Type; + +/** + * Classifies against durable accepted evidence. Non-accepted history is explanatory evidence only + * and never becomes the ordering head. + */ +export const classifyInventorySourceImport = (input: { + readonly acceptedHistory: readonly InventorySourceImportLedgerEntry[]; + readonly proposal: InventorySourceAssertionProposal; +}): InventorySourceImportPreflightDecision => { + const accepted = input.acceptedHistory.filter( + (entry) => + entry.outcome.status === 'ACCEPTED' && inventorySourceAssertionsShareStream(input.proposal, entry.proposal), + ); + for (const entry of accepted) { + if (!inventorySourceAssertionsClaimSameIdentityOrRevision(input.proposal, entry.proposal)) { + continue; + } + return inventorySourceAssertionsHaveSameMaterialContent(input.proposal, entry.proposal) + ? { + assertionId: input.proposal.assertionId, + duplicateOfAssertionId: entry.proposal.assertionId, + reason: 'The same source identity or revision with identical material content was already accepted', + status: 'DUPLICATE', + } + : { + assertionId: input.proposal.assertionId, + reason: 'The same source identity or revision carries different material business content', + reconciliationRequired: true, + status: 'INDETERMINATE', + }; + } + for (const entry of accepted) { + const relation = compareInventorySourceOrdering(input.proposal.orderingEvidence, entry.proposal.orderingEvidence); + if (relation === 'INCOMPARABLE') { + return { + assertionId: input.proposal.assertionId, + reason: 'Owner evidence cannot establish an order relative to accepted source evidence', + reconciliationRequired: true, + status: 'INDETERMINATE', + }; + } + if (relation === 'OLDER') { + return { + assertionId: input.proposal.assertionId, + currentAssertionId: entry.proposal.assertionId, + reason: 'Owner ordering evidence proves that a newer source assertion is already accepted', + status: 'STALE', + }; + } + } + return { status: 'CANDIDATE' }; +}; diff --git a/app/verticals/inventory/shared/domain/inventory-source-obligation-reconciliation.ts b/app/verticals/inventory/shared/domain/inventory-source-obligation-reconciliation.ts new file mode 100644 index 000000000..d24b80bb3 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-obligation-reconciliation.ts @@ -0,0 +1,85 @@ +import { Schema } from 'effect'; + +import { ImportedCommittedObligationRefSchema } from '../resources/imported-committed-obligation.ts'; +import { InventoryReservationRefSchema } from '../resources/inventory-reservation.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { + InventorySourceAssertionEvaluationSchema, + InventorySourceAssertionSchema, +} from './inventory-source-assertion.ts'; +import { PhysicalStockEffectRecordSchema } from './physical-stock-effect.ts'; +import { StockQuantitySchema } from './stock-position.ts'; + +const boundedEvidenceRef = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const observedInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const CommittedInventoryObligationRefSchema = Schema.Union([ + InventoryReservationRefSchema, + ImportedCommittedObligationRefSchema, +]); + +/** + * An immutable owner observation of committed quantity. A history may contain several observations + * for one obligation identity; none of them is a physical stock effect or a source of ON_HAND. + */ +export const InventoryCommittedObligationStateEvidenceSchema = Schema.Struct({ + obligationRef: CommittedInventoryObligationRefSchema, + observedAt: observedInstant, + ownerEvidenceRef: boundedEvidenceRef, + positionRef: StockPositionRefSchema, + remainingQuantity: StockQuantitySchema, + stockItemRef: StockItemRefSchema, +}).check( + Schema.makeFilter(({ obligationRef, positionRef, remainingQuantity, stockItemRef }) => { + const { tenantId } = obligationRef; + return positionRef.tenantId === tenantId && + remainingQuantity.unitRef.tenantId === tenantId && + stockItemRef.tenantId === tenantId + ? undefined + : 'Committed obligation evidence must preserve one exact Tenant scope'; + }), +); + +export const InventorySourceObligationReconciliationInputSchema = Schema.Struct({ + assertion: InventorySourceAssertionSchema, + committedObligationEvidence: Schema.Array(InventoryCommittedObligationStateEvidenceSchema), + physicalEffects: Schema.Array(PhysicalStockEffectRecordSchema), +}).check( + Schema.makeFilter(({ assertion, committedObligationEvidence }) => + committedObligationEvidence.every( + ({ positionRef, remainingQuantity, stockItemRef }) => + positionRef.resourceId === assertion.positionRef.resourceId && + positionRef.tenantId === assertion.positionRef.tenantId && + stockItemRef.resourceId === assertion.stockItemRef.resourceId && + stockItemRef.tenantId === assertion.stockItemRef.tenantId && + remainingQuantity.unitRef.moduleId === assertion.quantity.unitRef.moduleId && + remainingQuantity.unitRef.resourceId === assertion.quantity.unitRef.resourceId && + remainingQuantity.unitRef.resourceType === assertion.quantity.unitRef.resourceType && + remainingQuantity.unitRef.tenantId === assertion.quantity.unitRef.tenantId, + ) + ? undefined + : 'Committed obligation evidence must match the exact source assertion stock scope', + ), +); +export type InventorySourceObligationReconciliationInput = + typeof InventorySourceObligationReconciliationInputSchema.Type; + +export const InventorySourceObligationReconciliationSchema = Schema.Struct({ + committedObligationEvidence: Schema.Array(InventoryCommittedObligationStateEvidenceSchema), + committedObligationMeaning: Schema.Literal('SEPARATE_FROM_PHYSICAL_ON_HAND'), + customerFacingAvailabilityPublished: Schema.Literal(false), + evaluation: InventorySourceAssertionEvaluationSchema, + obligationAdjustmentAppliedToOnHand: Schema.Literal(false), + physicalEffects: Schema.Array(PhysicalStockEffectRecordSchema), + physicalEffectsExecuted: Schema.Literal(false), + physicalQuantityMeaning: Schema.Literal('ABSOLUTE_PHYSICAL_ON_HAND'), + reservedQuantityMeaning: Schema.Literal('DERIVED_PROVISIONAL_RESERVATION_AGGREGATE'), + sourceAssertion: InventorySourceAssertionSchema, +}).check( + Schema.makeFilter(({ evaluation, sourceAssertion }) => + evaluation.assertion.assertionId === sourceAssertion.assertionId + ? undefined + : 'Reconciliation evaluation must preserve the exact source assertion identity', + ), +); diff --git a/app/verticals/inventory/shared/domain/inventory-source-ordering.ts b/app/verticals/inventory/shared/domain/inventory-source-ordering.ts new file mode 100644 index 000000000..f7a762afa --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-source-ordering.ts @@ -0,0 +1,162 @@ +import { DateTime, Schema } from 'effect'; + +import type { + InventorySourceAssertion, + InventorySourceAssertionProposal, + InventorySourceOrderingEvidence, +} from './inventory-source-assertion.ts'; +import { + InventorySourceAssertionProposalSchema, + OwnerOrderKeyEvidenceSchema, + SourceCoverageEvidenceSchema, + SourceRevisionOrderingEvidenceSchema, +} from './inventory-source-assertion.ts'; + +export const InventorySourceOrderRelationSchema = Schema.Literals(['OLDER', 'SAME', 'NEWER', 'INCOMPARABLE']); +export type InventorySourceOrderRelation = typeof InventorySourceOrderRelationSchema.Type; + +const compareText = (left: string, right: string): Exclude => { + if (left === right) { + return 'SAME'; + } + return left < right ? 'OLDER' : 'NEWER'; +}; + +/** + * Compares only ordering evidence supplied by the source owner. Transport arrival and batch order + * deliberately never participate. Decimal source revisions compare numerically; non-decimal + * revisions are comparable only for equality. Owner order keys are defined as lexicographically + * sortable keys by their owner. + */ +export const compareInventorySourceOrdering = ( + left: InventorySourceOrderingEvidence, + right: InventorySourceOrderingEvidence, +): InventorySourceOrderRelation => { + if (Schema.is(SourceRevisionOrderingEvidenceSchema)(left)) { + if (!Schema.is(SourceRevisionOrderingEvidenceSchema)(right)) { + return 'INCOMPARABLE'; + } + if (left.revision === right.revision) { + return 'SAME'; + } + if (!/^\d+$/u.test(left.revision) || !/^\d+$/u.test(right.revision)) { + return 'INCOMPARABLE'; + } + const leftRevision = BigInt(left.revision); + const rightRevision = BigInt(right.revision); + if (leftRevision === rightRevision) { + return 'SAME'; + } + return leftRevision < rightRevision ? 'OLDER' : 'NEWER'; + } + if (!Schema.is(OwnerOrderKeyEvidenceSchema)(right)) { + return 'INCOMPARABLE'; + } + return compareText(left.key, right.key); +}; + +type SourceAssertionMaterial = Pick< + InventorySourceAssertionProposal, + | 'businessObservedAt' + | 'coverage' + | 'customerConfigurationId' + | 'factMeaning' + | 'issuer' + | 'itemExternalKey' + | 'locationExternalKey' + | 'orderingEvidence' + | 'ownerEvidenceRef' + | 'positionRef' + | 'quantity' + | 'sourceReference' +>; + +const canonicalCoverage = (coverage: InventorySourceAssertionProposal['coverage']) => + coverage + .map(({ assertionId: _assertionId, ...evidence }) => evidence) + .toSorted((left, right) => { + if (left.effectId === right.effectId) { + return 0; + } + return left.effectId < right.effectId ? -1 : 1; + }); + +const canonicalOrderingEvidence = (evidence: InventorySourceOrderingEvidence) => { + if (Schema.is(SourceRevisionOrderingEvidenceSchema)(evidence)) { + return { + _tag: 'SOURCE_REVISION' as const, + value: /^\d+$/u.test(evidence.revision) ? BigInt(evidence.revision).toString() : evidence.revision, + }; + } + return { _tag: 'OWNER_ORDER_KEY' as const, value: evidence.key }; +}; + +export const canonicalInventorySourceAssertionMaterial = (assertion: SourceAssertionMaterial) => ({ + businessObservedAt: DateTime.toEpochMillis(DateTime.makeUnsafe(assertion.businessObservedAt)), + coverage: canonicalCoverage(assertion.coverage), + customerConfigurationId: assertion.customerConfigurationId, + factMeaning: assertion.factMeaning, + issuer: assertion.issuer, + itemExternalKey: assertion.itemExternalKey, + locationExternalKey: assertion.locationExternalKey, + orderingEvidence: canonicalOrderingEvidence(assertion.orderingEvidence), + ownerEvidenceRef: assertion.ownerEvidenceRef, + positionRef: assertion.positionRef, + quantity: assertion.quantity, + sourceReference: assertion.sourceReference, +}); + +const SourceAssertionMaterialSchema = Schema.Struct({ + businessObservedAt: Schema.Finite, + coverage: Schema.Array( + Schema.Struct({ + effectId: SourceCoverageEvidenceSchema.fields.effectId, + ownerEvidenceRef: SourceCoverageEvidenceSchema.fields.ownerEvidenceRef, + relation: SourceCoverageEvidenceSchema.fields.relation, + }), + ), + customerConfigurationId: InventorySourceAssertionProposalSchema.fields.customerConfigurationId, + factMeaning: InventorySourceAssertionProposalSchema.fields.factMeaning, + issuer: InventorySourceAssertionProposalSchema.fields.issuer, + itemExternalKey: InventorySourceAssertionProposalSchema.fields.itemExternalKey, + locationExternalKey: InventorySourceAssertionProposalSchema.fields.locationExternalKey, + orderingEvidence: Schema.Union([ + Schema.TaggedStruct('SOURCE_REVISION', { value: Schema.String }), + Schema.TaggedStruct('OWNER_ORDER_KEY', { value: Schema.String }), + ]), + ownerEvidenceRef: InventorySourceAssertionProposalSchema.fields.ownerEvidenceRef, + positionRef: InventorySourceAssertionProposalSchema.fields.positionRef, + quantity: InventorySourceAssertionProposalSchema.fields.quantity, + sourceReference: InventorySourceAssertionProposalSchema.fields.sourceReference, +}); +const materialContentEquivalent = Schema.toEquivalence(SourceAssertionMaterialSchema); + +/** Equality is over decoded business fields, never a caller-provided or persisted fingerprint. */ +export const inventorySourceAssertionsHaveSameMaterialContent = ( + left: SourceAssertionMaterial, + right: SourceAssertionMaterial, +): boolean => + materialContentEquivalent( + canonicalInventorySourceAssertionMaterial(left), + canonicalInventorySourceAssertionMaterial(right), + ); + +export const inventorySourceAssertionsShareStream = ( + left: InventorySourceAssertionProposal, + right: InventorySourceAssertion | InventorySourceAssertionProposal, +): boolean => + left.positionRef.tenantId === right.positionRef.tenantId && + left.customerConfigurationId === right.customerConfigurationId && + left.factMeaning === right.factMeaning && + left.issuer.backendKind === right.issuer.backendKind && + left.issuer.backendId === right.issuer.backendId && + left.positionRef.resourceId === right.positionRef.resourceId; + +export const inventorySourceAssertionsClaimSameIdentityOrRevision = ( + left: InventorySourceAssertionProposal, + right: InventorySourceAssertion | InventorySourceAssertionProposal, +): boolean => + left.assertionId === right.assertionId || + (inventorySourceAssertionsShareStream(left, right) && + (left.sourceReference === right.sourceReference || + compareInventorySourceOrdering(left.orderingEvidence, right.orderingEvidence) === 'SAME')); diff --git a/app/verticals/inventory/shared/domain/inventory-typed-outcomes.ts b/app/verticals/inventory/shared/domain/inventory-typed-outcomes.ts new file mode 100644 index 000000000..c428df551 --- /dev/null +++ b/app/verticals/inventory/shared/domain/inventory-typed-outcomes.ts @@ -0,0 +1,398 @@ +import { ActionPermissionDenied } from '@app/core-runtime'; +import { Match, Schema } from 'effect'; + +import { CatalogToStockBindingResolutionFailure } from './catalog-to-stock-binding-resolution.ts'; +import { CatalogStockDemandSchema, CatalogToStockBindingSchema } from './catalog-to-stock-binding.ts'; +import { + EstablishCommitmentProtectionErrorSchema, + EstablishCommitmentProtectionResultSchema, +} from './commitment-protection.ts'; +import { + CompensateInventoryPreCommitErrorSchema, + CompensateInventoryPreCommitResultSchema, +} from './inventory-pre-commit-compensation.ts'; +import { + SelectInventoryBackendErrorSchema, + SelectInventoryBackendResultSchema, +} from './inventory-backend-configuration.ts'; +import { + CreateInventoryReservationErrorSchema, + CreateInventoryReservationResultSchema, +} from './inventory-reservation-create.ts'; +import { + ReleaseInventoryReservationErrorSchema, + ReleaseInventoryReservationResultSchema, +} from './inventory-reservation-release.ts'; +import { RuntimeCommittedInventoryObligationSchema } from './inventory-obligation.ts'; +import { + ReservationConfirmationRejected, + ReservationConfirmationSchema, + ReservationConfirmationUnavailable, +} from './reservation-confirmation.ts'; +import { ReservationAuthorityUnavailable } from './reservation-authority-unavailable.ts'; +import { ReservationEffectIndeterminate } from './reservation-effect-indeterminate.ts'; +import { ReservationShortageImpactEvaluationSchema } from './reservation-shortage-impact.ts'; +import { InventorySourceAssertionEvaluationSchema } from './inventory-source-assertion.ts'; +import { + CurrentOnHandEvidenceSchema, + IndeterminateOnHandEvidenceSchema, + MissingOnHandEvidenceSchema, + StaleOnHandEvidenceSchema, + StockQuantitySchema, + UnknownOnHandEvidenceSchema, + compareExactStockQuantityAmounts, +} from './stock-position.ts'; +import { InventorySourceConflictRefSchema } from '../resources/inventory-source-conflict.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +export { UnresolvedReservationEffectConstraintSchema as InventoryUnresolvedReservationEffectConstraintOutcomeSchema } from './current-stock-evidence-for-availability.ts'; + +const sameResourceRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +/** Binding resolution is its own capability; its MISSING outcome is not Stock Evidence MISSING. */ +export const CatalogBindingCapabilityOutcomeSchema = Schema.Union([ + Schema.Struct({ binding: CatalogToStockBindingSchema, outcome: Schema.Literal('RESOLVED') }), + CatalogToStockBindingResolutionFailure, +]); + +export const inventoryBindingResolutionNextStep = ( + outcome: 'RESOLVED' | CatalogToStockBindingResolutionFailure['outcome'], +) => (outcome === 'RESOLVED' ? ('CONTINUE' as const) : ('REPAIR_BINDING' as const)); + +/** Structural decoding failures stay outside this business result; these are exact semantic input outcomes. */ +export const InventoryReservationDemandInputOutcomeSchema = Schema.Union([ + Schema.TaggedStruct('VALID', { + purchaseDemandOccurrenceId: CatalogStockDemandSchema.fields.purchaseDemandOccurrenceId, + requestedQuantity: StockQuantitySchema, + }), + Schema.TaggedStruct('REJECTED', { + purchaseDemandOccurrenceId: CatalogStockDemandSchema.fields.purchaseDemandOccurrenceId, + reason: Schema.Literals(['INVALID_REQUESTED_QUANTITY', 'INCOMPATIBLE_REQUESTED_UNIT']), + }), +]); + +export const inventoryReservationDemandInputNextStep = (outcome: 'VALID' | 'REJECTED') => + outcome === 'VALID' ? ('CONTINUE' as const) : ('REPAIR_INPUT' as const); + +/** A known shortage is numeric owner evidence, never an alias for missing or uncertain evidence. */ +export const KnownInsufficientConstrainedStockSchema = Schema.TaggedStruct('INSUFFICIENT', { + availableQuantity: StockQuantitySchema, + positionRef: StockPositionRefSchema, + requestedQuantity: StockQuantitySchema, +}).check( + Schema.makeFilter(({ availableQuantity, positionRef, requestedQuantity }) => { + if ( + !sameResourceRef(availableQuantity.unitRef, requestedQuantity.unitRef) || + positionRef.tenantId !== availableQuantity.unitRef.tenantId + ) { + return 'Known constrained insufficiency must preserve one exact Position Tenant and unchanged Unit'; + } + return compareExactStockQuantityAmounts(availableQuantity.amount, requestedQuantity.amount) < 0 + ? undefined + : 'Known constrained insufficiency requires available Quantity to be lower than requested Quantity'; + }), +); + +export const ConflictingStockEvidenceSchema = Schema.TaggedStruct('CONFLICTING', { + conflictRef: InventorySourceConflictRefSchema, + positionRef: StockPositionRefSchema, + reconciliationRequired: Schema.Literal(true), +}).check( + Schema.makeFilter(({ conflictRef, positionRef }) => + conflictRef.tenantId === positionRef.tenantId + ? undefined + : 'Conflicting Stock Evidence and its constrained Position must share one Tenant', + ), +); + +export const InventoryStockEvidenceCapabilityOutcomeSchema = Schema.Union([ + CurrentOnHandEvidenceSchema, + KnownInsufficientConstrainedStockSchema, + UnknownOnHandEvidenceSchema, + MissingOnHandEvidenceSchema, + StaleOnHandEvidenceSchema, + IndeterminateOnHandEvidenceSchema, + ConflictingStockEvidenceSchema, +]); +export type InventoryStockEvidenceCapabilityOutcome = typeof InventoryStockEvidenceCapabilityOutcomeSchema.Type; + +type InventoryStockEvidenceTag = InventoryStockEvidenceCapabilityOutcome['_tag']; + +export const inventoryStockEvidenceNextStep = (outcome: InventoryStockEvidenceTag) => { + if (outcome === 'CURRENT') { + return 'CONTINUE' as const; + } + if (outcome === 'INSUFFICIENT') { + return 'STOP' as const; + } + if (outcome === 'CONFLICTING' || outcome === 'INDETERMINATE') { + return 'RECONCILE' as const; + } + return 'ACQUIRE_OWNER_EVIDENCE' as const; +}; + +/** Source Coverage uses its own outcome vocabulary instead of reusing Stock Evidence tags. */ +const InventorySourceCoverageCapabilityOutcomeSchema = InventorySourceAssertionEvaluationSchema; +type InventorySourceCoverageCapabilityOutcome = typeof InventorySourceCoverageCapabilityOutcomeSchema.Type; + +export const inventorySourceCoverageNextStep = (outcome: InventorySourceCoverageCapabilityOutcome['_tag']) => { + if (outcome === 'DETERMINATE') { + return 'CONTINUE' as const; + } + return outcome === 'INDETERMINATE' ? ('RECONCILE' as const) : ('STOP' as const); +}; + +/** Backend selection never turns a conflict or outage into an implicit fallback. */ +const InventoryBackendSelectionCapabilityOutcomeSchema = Schema.Union([ + SelectInventoryBackendResultSchema, + SelectInventoryBackendErrorSchema, + ActionPermissionDenied, +]); +type InventoryBackendSelectionCapabilityOutcome = typeof InventoryBackendSelectionCapabilityOutcomeSchema.Type; + +export const inventoryBackendSelectionNextStep = ( + outcome: Extract['outcome'], +) => (outcome === 'BACKEND_CONFIGURATION_CONFLICT' ? ('REPAIR_CONFIGURATION' as const) : ('CONTINUE' as const)); + +/** + * Reservation establishment retains domain, runtime permission, authority availability, and effect-truth + * distinctions. There is deliberately no global Inventory outcome enum. + */ +export const InventoryReservationCreateCapabilityOutcomeSchema = Schema.Union([ + CreateInventoryReservationResultSchema, + CreateInventoryReservationErrorSchema, + ReservationAuthorityUnavailable, + ReservationEffectIndeterminate, + ActionPermissionDenied, +]); + +const ReservationCreateNextStepInputSchema = Schema.Union([ + Schema.Struct({ + outcome: Schema.Literals([ + 'PENDING', + 'ESTABLISHED', + 'EXACT_REPLAY', + 'RECONCILIATION_REQUIRED', + 'INDETERMINATE', + 'RESOLVED_NO_RESERVATION', + ]), + }), + Schema.TaggedStruct('ActionPermissionDenied', {}), + Schema.TaggedStruct('CatalogToStockBindingResolutionFailure', {}), + Schema.TaggedStruct('InventoryReservationCreateRejected', { reason: Schema.String }), + Schema.TaggedStruct('InventoryReservationCreateUnavailable', {}), + Schema.TaggedStruct('InventoryReservationGuaranteeUnsupported', {}), + Schema.TaggedStruct('ReservationAuthorityUnavailable', {}), + Schema.TaggedStruct('ReservationEffectIndeterminate', {}), +]); +type ReservationCreateNextStepInput = typeof ReservationCreateNextStepInputSchema.Type; + +const inventoryReservationCreateRejectionNextStep = (reason: string) => { + if (reason === 'AUTHORITY_NOT_SELECTED') { + return 'REPAIR_CONFIGURATION' as const; + } + if (reason === 'TENANT_SCOPE_MISMATCH' || reason === 'COMMERCE_CONTEXT_NOT_ELIGIBLE') { + return 'REPAIR_INPUT' as const; + } + if (reason === 'ATTEMPT_HAS_UNRESOLVED_EFFECT') { + return 'RECOVER_ORIGINAL_EFFECT' as const; + } + if (reason === 'INVALID_BACKEND_OBSERVATION') { + return 'RECONCILE' as const; + } + return reason === 'EFFECT_ID_CONFLICT' || reason === 'ATTEMPT_ALREADY_BOUND' + ? ('STOP_CONFLICT' as const) + : ('STOP' as const); +}; + +export const inventoryReservationCreateNextStep = (outcome: ReservationCreateNextStepInput) => + Match.value(outcome).pipe( + Match.when({ outcome: 'ESTABLISHED' }, () => 'CONTINUE' as const), + Match.when({ outcome: 'EXACT_REPLAY' }, () => 'CONTINUE' as const), + Match.when({ outcome: 'PENDING' }, () => 'RECOVER_ORIGINAL_EFFECT' as const), + Match.when({ outcome: 'INDETERMINATE' }, () => 'RECOVER_ORIGINAL_EFFECT' as const), + Match.when({ outcome: 'RECONCILIATION_REQUIRED' }, () => 'RECONCILE' as const), + Match.when({ outcome: 'RESOLVED_NO_RESERVATION' }, () => 'STOP' as const), + Match.when({ _tag: 'CatalogToStockBindingResolutionFailure' }, () => 'REPAIR_BINDING' as const), + Match.when({ _tag: 'ReservationAuthorityUnavailable' }, () => 'WAIT_FOR_OWNER' as const), + Match.when({ _tag: 'InventoryReservationCreateUnavailable' }, () => 'WAIT_FOR_OWNER' as const), + Match.when({ _tag: 'ReservationEffectIndeterminate' }, () => 'RECOVER_ORIGINAL_EFFECT' as const), + Match.when({ _tag: 'InventoryReservationCreateRejected' }, ({ reason }) => + inventoryReservationCreateRejectionNextStep(reason), + ), + Match.when({ _tag: 'ActionPermissionDenied' }, () => 'STOP' as const), + Match.when({ _tag: 'InventoryReservationGuaranteeUnsupported' }, () => 'STOP' as const), + Match.exhaustive, + ); + +const InventoryReservationConfirmationCapabilityOutcomeSchema = Schema.Union([ + ReservationConfirmationSchema, + ReservationConfirmationRejected, + ReservationConfirmationUnavailable, + ActionPermissionDenied, +]); +type InventoryReservationConfirmationCapabilityOutcome = + typeof InventoryReservationConfirmationCapabilityOutcomeSchema.Type; +type ConfirmedReservation = Extract; + +export const inventoryReservationConfirmationNextStep = (health: ConfirmedReservation['health']['state']) => { + if (health === 'VALID') { + return 'CONTINUE_TO_PROTECTION' as const; + } + if (health === 'AT_RISK') { + return 'RECONCILE' as const; + } + return health === 'UNVERIFIABLE' ? ('ACQUIRE_OWNER_EVIDENCE' as const) : ('STOP' as const); +}; + +const InventoryReservationShortageCapabilityOutcomeSchema = ReservationShortageImpactEvaluationSchema; +type InventoryReservationShortageCapabilityOutcome = typeof InventoryReservationShortageCapabilityOutcomeSchema.Type; + +const ReservationShortageNextStepInputSchema = Schema.Union([ + Schema.TaggedStruct('DETERMINATE', { + decisions: Schema.Array(Schema.Struct({ capacity: Schema.Literals(['HONORABLE', 'SHORTAGE']) })), + }), + Schema.TaggedStruct('INDETERMINATE', {}), +]); +type ReservationShortageNextStepInput = typeof ReservationShortageNextStepInputSchema.Type & + Pick; + +export const inventoryReservationShortageNextStep = (outcome: ReservationShortageNextStepInput) => + Match.value(outcome).pipe( + Match.tag('DETERMINATE', ({ decisions }) => + decisions.some(({ capacity }) => capacity === 'SHORTAGE') ? ('STOP' as const) : ('CONTINUE' as const), + ), + Match.tag('INDETERMINATE', () => 'RECONCILE' as const), + Match.exhaustive, + ); + +export const inventoryUnresolvedReservationEffectConstraintNextStep = (outcome: 'EXACT' | 'INDETERMINATE') => + outcome === 'EXACT' ? ('EVALUATE_COMPENSATION' as const) : ('ACQUIRE_OWNER_EVIDENCE' as const); + +export const InventoryCommitmentProtectionCapabilityOutcomeSchema = Schema.Union([ + EstablishCommitmentProtectionResultSchema, + EstablishCommitmentProtectionErrorSchema, + ActionPermissionDenied, +]); +const CommitmentProtectionNextStepInputSchema = Schema.Union([ + Schema.TaggedStruct('PROTECTED', {}), + Schema.TaggedStruct('AT_RISK', {}), + Schema.TaggedStruct('PENDING', {}), + Schema.TaggedStruct('INDETERMINATE', {}), + Schema.TaggedStruct('NOT_PROTECTABLE', {}), + Schema.TaggedStruct('CommitmentProtectionRejected', {}), + Schema.TaggedStruct('CommitmentProtectionConflict', {}), + Schema.TaggedStruct('CommitmentProtectionUnavailable', {}), + Schema.TaggedStruct('ActionPermissionDenied', {}), +]); +type CommitmentProtectionNextStepInput = typeof CommitmentProtectionNextStepInputSchema.Type; + +export const inventoryCommitmentProtectionNextStep = (outcome: CommitmentProtectionNextStepInput) => + Match.value(outcome).pipe( + Match.tag('PROTECTED', () => 'CONTINUE' as const), + Match.tag('AT_RISK', () => 'RECONCILE' as const), + Match.tag('PENDING', () => 'RECOVER_ORIGINAL_EFFECT' as const), + Match.tag('INDETERMINATE', () => 'RECOVER_ORIGINAL_EFFECT' as const), + Match.tag('NOT_PROTECTABLE', () => 'STOP' as const), + Match.tag('CommitmentProtectionRejected', () => 'STOP' as const), + Match.tag('CommitmentProtectionConflict', () => 'STOP_CONFLICT' as const), + Match.tag('CommitmentProtectionUnavailable', () => 'WAIT_FOR_OWNER' as const), + Match.tag('ActionPermissionDenied', () => 'STOP' as const), + Match.exhaustive, + ); + +const InventoryReservationReleaseCapabilityOutcomeSchema = Schema.Union([ + ReleaseInventoryReservationResultSchema, + ReleaseInventoryReservationErrorSchema, + ActionPermissionDenied, +]); +type InventoryReservationReleaseCapabilityOutcome = typeof InventoryReservationReleaseCapabilityOutcomeSchema.Type; + +interface ReservationReleaseDiscriminant { + readonly outcome: Extract['outcome']; +} + +export const inventoryReservationReleaseNextStep = (outcome: ReservationReleaseDiscriminant) => { + if (outcome.outcome === 'RELEASED' || outcome.outcome === 'ALREADY_RELEASED') { + return 'CONTINUE' as const; + } + return outcome.outcome === 'PENDING' || outcome.outcome === 'INDETERMINATE' + ? ('RECOVER_ORIGINAL_EFFECT' as const) + : ('STOP' as const); +}; + +const InventoryPreCommitCompensationCapabilityOutcomeSchema = Schema.Union([ + CompensateInventoryPreCommitResultSchema, + CompensateInventoryPreCommitErrorSchema, + ActionPermissionDenied, +]); +type InventoryPreCommitCompensationCapabilityOutcome = + typeof InventoryPreCommitCompensationCapabilityOutcomeSchema.Type; +type InventoryPreCommitCompensationResultOutcome = Extract< + InventoryPreCommitCompensationCapabilityOutcome, + { readonly outcome: string } +>['outcome']; + +type PreCommitCompensationDiscriminant = ( + | { + readonly outcome: + | 'CREATE_EFFECT_COMPENSATED' + | 'ALREADY_COMPENSATED' + | 'NO_COMPENSATION_REQUIRED' + | 'RECONCILIATION_REQUIRED'; + } + | { + readonly outcome: 'RESERVATION_RELEASE'; + readonly release: ReservationReleaseDiscriminant; + } + | { + readonly outcome: 'BLOCKED'; + readonly reason: 'ORDER_COMMITTED' | 'ATTEMPT_NOT_CLOSED' | 'ORDER_TRUTH_UNKNOWN'; + } +) & { readonly outcome: InventoryPreCommitCompensationResultOutcome }; + +export const inventoryPreCommitCompensationNextStep = (outcome: PreCommitCompensationDiscriminant) => { + if (outcome.outcome === 'RECONCILIATION_REQUIRED') { + return 'RECONCILE' as const; + } + if (outcome.outcome === 'RESERVATION_RELEASE') { + return inventoryReservationReleaseNextStep(outcome.release); + } + if (outcome.outcome !== 'BLOCKED') { + return 'CONTINUE' as const; + } + if (outcome.reason === 'ATTEMPT_NOT_CLOSED') { + return 'WAIT_FOR_CLOSURE' as const; + } + return outcome.reason === 'ORDER_TRUTH_UNKNOWN' ? ('ACQUIRE_OWNER_EVIDENCE' as const) : ('STOP' as const); +}; + +export const InventoryCommittedObligationCapabilityOutcomeSchema = Schema.Union([ + Schema.TaggedStruct('COMMITTED_OBLIGATION', { + obligation: RuntimeCommittedInventoryObligationSchema, + }), + Schema.TaggedStruct('POST_COMMIT_RECONCILIATION', { + obligation: RuntimeCommittedInventoryObligationSchema, + reason: Schema.Literal('POST_COMMIT_BINDING_MISMATCH'), + reconciliationRequired: Schema.Literal(true), + }), +]); +export const inventoryCommittedObligationNextStep = (outcome: 'COMMITTED_OBLIGATION' | 'POST_COMMIT_RECONCILIATION') => + outcome === 'COMMITTED_OBLIGATION' ? ('CONTINUE' as const) : ('RECONCILE' as const); diff --git a/app/verticals/inventory/shared/domain/package-stock-item-binding.ts b/app/verticals/inventory/shared/domain/package-stock-item-binding.ts new file mode 100644 index 000000000..40eeb1e86 --- /dev/null +++ b/app/verticals/inventory/shared/domain/package-stock-item-binding.ts @@ -0,0 +1,56 @@ +import { PackageDefinitionSelectionRevisionSchema } from '@app/catalog/domain/catalog-selection-evidence'; +import type { Effect as EffectType } from 'effect'; +import { Effect, Schema } from 'effect'; + +import { ResolvedCatalogStockDemandSchema } from './catalog-to-stock-binding.ts'; +import type { ResolvedCatalogStockDemand } from './catalog-to-stock-binding.ts'; + +export const PackageStockRequirementSchema = Schema.Struct({ + ...ResolvedCatalogStockDemandSchema.fields, + contentDecomposition: Schema.Literal('PROHIBITED'), + packageContentRevision: PackageDefinitionSelectionRevisionSchema, + stockRepresentation: Schema.Literal('ONE_EXACT_PACKAGE_STOCK_ITEM'), +}); +export type PackageStockRequirement = typeof PackageStockRequirementSchema.Type; + +export class PackageStockItemBindingRejected extends Schema.TaggedError()( + 'PackageStockItemBindingRejected', + { + code: Schema.Literal('package_stock_item_binding_rejected'), + exactSelectionMeaningId: ResolvedCatalogStockDemandSchema.fields.exactSelectionMeaning.fields.id, + reason: Schema.Literals(['EXACT_SELECTION_IS_NOT_A_PACKAGE', 'PACKAGE_CONTENT_REVISION_MISSING']), + }, +) {} + +const rejected = ( + demand: ResolvedCatalogStockDemand, + reason: PackageStockItemBindingRejected['reason'], +): PackageStockItemBindingRejected => + new PackageStockItemBindingRejected({ + code: 'package_stock_item_binding_rejected', + exactSelectionMeaningId: demand.exactSelectionMeaning.id, + reason, + }); + +/** + * Specializes one already-resolved exact Catalog-to-Stock demand as a Package requirement. + * The Package Content revision is retained only as Catalog definition evidence: contents are + * never expanded, multiplied, substituted, converted, or allocated as loose component stock. + */ +export const resolvePackageStockRequirement = ( + resolved: ResolvedCatalogStockDemand, +): EffectType.Effect => { + if (resolved.exactSelectionMeaning.kind !== 'PACKAGE_OPTION') { + return Effect.fail(rejected(resolved, 'EXACT_SELECTION_IS_NOT_A_PACKAGE')); + } + const packageContentRevision = resolved.catalogSelection.packageOption?.contentRevision; + if (packageContentRevision === undefined) { + return Effect.fail(rejected(resolved, 'PACKAGE_CONTENT_REVISION_MISSING')); + } + return Effect.succeed({ + ...resolved, + contentDecomposition: 'PROHIBITED', + packageContentRevision, + stockRepresentation: 'ONE_EXACT_PACKAGE_STOCK_ITEM', + }); +}; diff --git a/app/verticals/inventory/shared/domain/physical-stock-effect-conflict.ts b/app/verticals/inventory/shared/domain/physical-stock-effect-conflict.ts new file mode 100644 index 000000000..cce70b0c5 --- /dev/null +++ b/app/verticals/inventory/shared/domain/physical-stock-effect-conflict.ts @@ -0,0 +1,12 @@ +import { Schema } from 'effect'; + +const PhysicalStockEffectIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PhysicalStockEffectId')); + +export class PhysicalStockEffectConflict extends Schema.TaggedError()( + 'PhysicalStockEffectConflict', + { + code: Schema.Literal('physical_stock_effect_conflict'), + effectId: PhysicalStockEffectIdSchema, + reason: Schema.Literal('EFFECT_ID_CONFLICT'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/physical-stock-effect-indeterminate.ts b/app/verticals/inventory/shared/domain/physical-stock-effect-indeterminate.ts new file mode 100644 index 000000000..6ac6f2355 --- /dev/null +++ b/app/verticals/inventory/shared/domain/physical-stock-effect-indeterminate.ts @@ -0,0 +1,18 @@ +import { Schema } from 'effect'; + +const PhysicalStockEffectIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PhysicalStockEffectId')); + +export const PhysicalStockEffectIndeterminateReasonSchema = Schema.Literals([ + 'BACKEND_OUTCOME_UNKNOWN', + 'EVIDENCE_UNVERIFIABLE', +]); + +export class PhysicalStockEffectIndeterminate extends Schema.TaggedError()( + 'PhysicalStockEffectIndeterminate', + { + code: Schema.Literal('physical_stock_effect_indeterminate'), + effectId: PhysicalStockEffectIdSchema, + reason: PhysicalStockEffectIndeterminateReasonSchema, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/physical-stock-effect-unavailable.ts b/app/verticals/inventory/shared/domain/physical-stock-effect-unavailable.ts new file mode 100644 index 000000000..5d645fc10 --- /dev/null +++ b/app/verticals/inventory/shared/domain/physical-stock-effect-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +const PhysicalStockEffectIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('PhysicalStockEffectId')); + +export class PhysicalStockEffectUnavailable extends Schema.TaggedError()( + 'PhysicalStockEffectUnavailable', + { + code: Schema.Literal('physical_stock_effect_unavailable'), + effectId: Schema.optionalKey(PhysicalStockEffectIdSchema), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/physical-stock-effect.ts b/app/verticals/inventory/shared/domain/physical-stock-effect.ts new file mode 100644 index 000000000..01fc044b0 --- /dev/null +++ b/app/verticals/inventory/shared/domain/physical-stock-effect.ts @@ -0,0 +1,145 @@ +import { Schema } from 'effect'; + +import { CustomerConfigurationIdSchema, InventoryBackendSchema } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockLocationRefSchema } from '../resources/stock-location.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; +import { PhysicalStockEffectConflict } from './physical-stock-effect-conflict.ts'; +import { + PhysicalStockEffectIndeterminate, + PhysicalStockEffectIndeterminateReasonSchema, +} from './physical-stock-effect-indeterminate.ts'; +import { PhysicalStockEffectUnavailable } from './physical-stock-effect-unavailable.ts'; +import { StockQuantitySchema } from './stock-position.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const uuid = Schema.String.check(Schema.isUUID()); +export const ActionInvocationIdSchema = uuid.pipe(Schema.brand('ActionInvocationId')); +export const LegalEntityIdSchema = uuid.pipe(Schema.brand('LegalEntityId')); + +export const PhysicalStockEffectIdSchema = uuid.pipe(Schema.brand('PhysicalStockEffectId')); +export type PhysicalStockEffectId = typeof PhysicalStockEffectIdSchema.Type; + +export const PhysicalStockEffectKindSchema = Schema.Literals(['RECEIPT', 'ISSUE']); +export type PhysicalStockEffectKind = typeof PhysicalStockEffectKindSchema.Type; + +export const PhysicalStockBusinessReasonSchema = Schema.Struct({ + code: boundedText, + reference: boundedText, +}); + +export const PositiveExactStockQuantityAmountSchema = StockQuantitySchema.fields.amount.check( + Schema.makeFilter((amount) => + amount === '0' ? 'Physical Stock Receipt/Issue Quantity must be greater than zero' : undefined, + ), +); +export const PhysicalStockEffectQuantitySchema = Schema.Struct({ + amount: PositiveExactStockQuantityAmountSchema, + unitRef: StockQuantitySchema.fields.unitRef, +}); + +export const PhysicalStockEffectPayloadSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + effectId: PhysicalStockEffectIdSchema, + positionRef: StockPositionRefSchema, + quantity: PhysicalStockEffectQuantitySchema, + reason: PhysicalStockBusinessReasonSchema, + stockItemRef: StockItemRefSchema, +}); +export type PhysicalStockEffectPayload = typeof PhysicalStockEffectPayloadSchema.Type; + +export const PhysicalStockEffectRequestSchema = Schema.Struct({ + actionInvocationId: ActionInvocationIdSchema, + backend: InventoryBackendSchema, + backendConfigurationRef: InventoryBackendConfigurationRefSchema, + backendId: InventoryBackendIdSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + effectId: PhysicalStockEffectIdSchema, + kind: PhysicalStockEffectKindSchema, + legalEntityId: LegalEntityIdSchema, + positionRef: StockPositionRefSchema, + quantity: PhysicalStockEffectQuantitySchema, + reason: PhysicalStockBusinessReasonSchema, + requestedAt: instant, + stockItemRef: StockItemRefSchema, + stockLocationRef: StockLocationRefSchema, +}); +export type PhysicalStockEffectRequest = typeof PhysicalStockEffectRequestSchema.Type; + +export const PhysicalStockEffectEvidenceSchema = Schema.Struct({ + appliedAt: instant, + backend: InventoryBackendSchema, + backendConfigurationRef: InventoryBackendConfigurationRefSchema, + backendEvidenceRef: boundedText, + backendId: InventoryBackendIdSchema, + effectId: PhysicalStockEffectIdSchema, + issuer: boundedText, + kind: PhysicalStockEffectKindSchema, + positionRef: StockPositionRefSchema, + quantity: PhysicalStockEffectQuantitySchema, +}); +export type PhysicalStockEffectEvidence = typeof PhysicalStockEffectEvidenceSchema.Type; + +export const RequestedPhysicalStockEffectSchema = Schema.TaggedStruct('REQUESTED', { + request: PhysicalStockEffectRequestSchema, +}); +export const AppliedPhysicalStockEffectSchema = Schema.TaggedStruct('APPLIED', { + evidence: PhysicalStockEffectEvidenceSchema, + request: PhysicalStockEffectRequestSchema, +}); +export const RejectedPhysicalStockEffectSchema = Schema.TaggedStruct('REJECTED', { + reason: Schema.Literals(['INSUFFICIENT_ON_HAND', 'POSITION_REJECTED', 'BACKEND_REJECTED']), + request: PhysicalStockEffectRequestSchema, +}); +export const IndeterminatePhysicalStockEffectSchema = Schema.TaggedStruct('INDETERMINATE', { + reason: PhysicalStockEffectIndeterminateReasonSchema, + request: PhysicalStockEffectRequestSchema, +}); +export const PhysicalStockEffectRecordSchema = Schema.Union([ + RequestedPhysicalStockEffectSchema, + AppliedPhysicalStockEffectSchema, + RejectedPhysicalStockEffectSchema, + IndeterminatePhysicalStockEffectSchema, +]); +export type PhysicalStockEffectRecord = typeof PhysicalStockEffectRecordSchema.Type; + +export const RequestPhysicalStockEffectResultSchema = Schema.Struct({ + effect: PhysicalStockEffectRecordSchema, + outcome: Schema.Literals(['REQUESTED', 'EXACT_REPLAY']), +}); +export type RequestPhysicalStockEffectResult = typeof RequestPhysicalStockEffectResultSchema.Type; + +export class PhysicalStockEffectRejected extends Schema.TaggedError()( + 'PhysicalStockEffectRejected', + { + code: Schema.Literal('physical_stock_effect_rejected'), + effectId: PhysicalStockEffectIdSchema, + reason: Schema.Literals([ + 'BACKEND_CONFIGURATION_MISSING', + 'BACKEND_CONFIGURATION_MISMATCH', + 'BACKEND_REJECTED', + 'INSUFFICIENT_ON_HAND', + 'POSITION_NOT_CURRENT', + 'POSITION_NOT_FOUND', + 'POSITION_REJECTED', + 'STOCK_ITEM_MISMATCH', + 'TENANT_SCOPE_MISMATCH', + 'UNIT_MISMATCH', + 'WORKER_CONTEXT_MISMATCH', + ]), + }, +) {} + +export const PhysicalStockEffectErrorSchema = Schema.Union([ + PhysicalStockEffectConflict, + PhysicalStockEffectRejected, + PhysicalStockEffectUnavailable, + PhysicalStockEffectIndeterminate, +]); + +export { PhysicalStockEffectConflict } from './physical-stock-effect-conflict.ts'; +export { PhysicalStockEffectIndeterminate } from './physical-stock-effect-indeterminate.ts'; +export { PhysicalStockEffectUnavailable } from './physical-stock-effect-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/reservation-authority-unavailable.ts b/app/verticals/inventory/shared/domain/reservation-authority-unavailable.ts new file mode 100644 index 000000000..75cf88231 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-authority-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { reservationIssuerCommonFailureFields } from './reservation-issuer-failure-fields.ts'; + +export class ReservationAuthorityUnavailable extends Schema.TaggedError()( + 'ReservationAuthorityUnavailable', + { + ...reservationIssuerCommonFailureFields, + effectAbsenceProven: Schema.Literal(false), + reason: Schema.Literal('SELECTED_RESERVATION_AUTHORITY_UNAVAILABLE'), + recovery: Schema.Literal('VERIFY_OR_RECOVER_ORIGINAL_EFFECT'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/reservation-authority.ts b/app/verticals/inventory/shared/domain/reservation-authority.ts new file mode 100644 index 000000000..d05d1f382 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-authority.ts @@ -0,0 +1,132 @@ +import { Schema } from 'effect'; + +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; +import { ReservationAuthorityEffectIdSchema } from './reservation-issuer-failure-fields.ts'; +import { StockQuantitySchema } from './stock-position.ts'; +import { InventoryReservationAuthorityDecisionSchema } from './inventory-authority.ts'; +import { InventoryBackendSchema } from '../inventory-launch-scope.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; + +const boundedIdentifier = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const ReservationInstantSchema = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export { ReservationAuthorityUnavailable } from './reservation-authority-unavailable.ts'; +export { ReservationEffectIndeterminate } from './reservation-effect-indeterminate.ts'; +export { ReservationIssuerEvidenceRejected } from './reservation-issuer-evidence-rejected.ts'; +export const ReservationAuthorityOperationSchema = Schema.Literals([ + 'RESERVATION_CONFIRMATION', + 'COMMITMENT_PROTECTION', +]); + +export const ReservationAuthorityAllocationSchema = Schema.Struct({ + allocationId: boundedIdentifier.pipe(Schema.brand('ReservationAuthorityAllocationId')), + quantity: StockQuantitySchema, + stockItemRef: StockItemRefSchema, + stockPositionRef: StockPositionRefSchema, +}).check( + Schema.makeFilter(({ quantity, stockItemRef, stockPositionRef }) => + stockItemRef.tenantId === stockPositionRef.tenantId && stockItemRef.tenantId === quantity.unitRef.tenantId + ? undefined + : 'Reservation Allocation references and Quantity Unit must share one Tenant', + ), +); +export type ReservationAuthorityAllocation = typeof ReservationAuthorityAllocationSchema.Type; + +export const ReservationAuthorityAllocationsSchema = Schema.Array(ReservationAuthorityAllocationSchema).check( + Schema.isMinLength(1), + Schema.makeFilter((allocations) => + new Set(allocations.map(({ allocationId }) => allocationId)).size === allocations.length + ? undefined + : 'Reservation Allocation identities must be unique within one exact Reservation scope', + ), +); + +export const ReservationAuthorityExactScopeSchema = Schema.Struct({ + allocations: ReservationAuthorityAllocationsSchema, + attemptId: InventoryReservationAuthorityDecisionSchema.fields.attemptId, + reservationId: InventoryReservationAuthorityDecisionSchema.fields.reservationId, + tenantId: InventoryBackendConfigurationSchema.fields.tenantId, +}).check( + Schema.makeFilter(({ allocations, tenantId }) => + allocations.every( + ({ quantity, stockItemRef, stockPositionRef }) => + String(stockItemRef.tenantId) === String(tenantId) && + stockPositionRef.tenantId === tenantId && + quantity.unitRef.tenantId === tenantId, + ) + ? undefined + : 'Every Reservation Allocation must belong to the Reservation Tenant', + ), +); +export type ReservationAuthorityExactScope = typeof ReservationAuthorityExactScopeSchema.Type; + +export const ReservationAuthorityIssueRequestSchema = Schema.Struct({ + configuration: InventoryBackendConfigurationSchema, + effectId: ReservationAuthorityEffectIdSchema, + operation: ReservationAuthorityOperationSchema, + reservation: ReservationAuthorityExactScopeSchema, +}).check( + Schema.makeFilter(({ configuration, reservation }) => + configuration.tenantId === reservation.tenantId + ? undefined + : 'Reservation and selected Inventory Backend configuration must share one Tenant', + ), +); +export type ReservationAuthorityIssueRequest = typeof ReservationAuthorityIssueRequestSchema.Type; + +export const ReservationEvidenceIssuerSchema = Schema.Struct({ + backend: InventoryBackendSchema, + backendId: InventoryBackendIdSchema, + origin: Schema.Literals(['EXTERNAL_BUSINESS_SYSTEM', 'ONTOS_WMS']), +}); + +export const ReservationAuthorityProofSchema = Schema.Struct({ + allocations: ReservationAuthorityAllocationsSchema, + attemptId: ReservationAuthorityExactScopeSchema.fields.attemptId, + customerConfigurationId: InventoryBackendConfigurationSchema.fields.customerConfigurationId, + ownerEvidenceRef: boundedIdentifier.pipe(Schema.brand('ReservationAuthorityOwnerEvidenceRef')), + reservationId: ReservationAuthorityExactScopeSchema.fields.reservationId, + tenantId: ReservationAuthorityExactScopeSchema.fields.tenantId, + validFrom: ReservationInstantSchema, + validUntil: ReservationInstantSchema, +}); + +export const ReservationAuthorityConfirmedObservationSchema = Schema.Struct({ + effectId: ReservationAuthorityEffectIdSchema, + evidence: ReservationAuthorityProofSchema, + issuer: ReservationEvidenceIssuerSchema, + kind: Schema.Literal('CONFIRMED'), + operation: ReservationAuthorityOperationSchema, +}); + +export const ReservationAuthorityObservationSchema = Schema.Union([ + ReservationAuthorityConfirmedObservationSchema, + Schema.Struct({ + effectId: ReservationAuthorityEffectIdSchema, + kind: Schema.Literal('UNSUPPORTED'), + }), + Schema.Struct({ + effectAbsenceProven: Schema.Literal(false), + effectId: ReservationAuthorityEffectIdSchema, + kind: Schema.Literal('UNAVAILABLE'), + recovery: Schema.Literal('VERIFY_OR_RECOVER_ORIGINAL_EFFECT'), + }), + Schema.Struct({ + competingFreshEffectAllowed: Schema.Literal(false), + effectId: ReservationAuthorityEffectIdSchema, + kind: Schema.Literal('INDETERMINATE'), + recovery: Schema.Literal('RECOVER_ORIGINAL_EFFECT'), + }), +]); +export type ReservationAuthorityObservation = typeof ReservationAuthorityObservationSchema.Type; + +export const AuthoritativeReservationEvidenceSchema = Schema.Struct({ + effectId: ReservationAuthorityEffectIdSchema, + evidence: ReservationAuthorityProofSchema, + issuer: ReservationEvidenceIssuerSchema, + kind: Schema.Literal('AUTHORITATIVE_RESERVATION_EVIDENCE'), + operation: ReservationAuthorityOperationSchema, +}); +export type AuthoritativeReservationEvidence = typeof AuthoritativeReservationEvidenceSchema.Type; diff --git a/app/verticals/inventory/shared/domain/reservation-confirmation-unavailable.ts b/app/verticals/inventory/shared/domain/reservation-confirmation-unavailable.ts new file mode 100644 index 000000000..79edb4c34 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-confirmation-unavailable.ts @@ -0,0 +1,10 @@ +import { Schema } from 'effect'; + +export class ReservationConfirmationUnavailable extends Schema.TaggedError()( + 'ReservationConfirmationUnavailable', + { + code: Schema.Literal('reservation_confirmation_unavailable'), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/reservation-confirmation.ts b/app/verticals/inventory/shared/domain/reservation-confirmation.ts new file mode 100644 index 000000000..f84c521c0 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-confirmation.ts @@ -0,0 +1,499 @@ +import type { Effect as EffectType, Option } from 'effect'; +import { DateTime, Effect, Match, Result, Schema } from 'effect'; + +import type { ProvisionalInventoryReservation } from './inventory-obligation.ts'; +import { ProvisionalInventoryReservationSchema } from './inventory-obligation.ts'; +import type { AuthoritativeReservationEvidence, ReservationAuthorityAllocation } from './reservation-authority.ts'; +import { AuthoritativeReservationEvidenceSchema } from './reservation-authority.ts'; +import type { ReservationConfirmationRef } from '../resources/reservation-confirmation.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; +import type { ReservationConfirmationUnavailable } from './reservation-confirmation-unavailable.ts'; + +export { ReservationConfirmationUnavailable } from './reservation-confirmation-unavailable.ts'; + +const boundedEvidenceRef = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const confirmationInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const ReservationConfirmationHealthStateSchema = Schema.Literals([ + 'VALID', + 'AT_RISK', + 'REVOKED', + 'EXPIRED', + 'UNVERIFIABLE', +]); +export type ReservationConfirmationHealthState = typeof ReservationConfirmationHealthStateSchema.Type; + +const ReservationConfirmationIssuedObservationSchema = Schema.TaggedStruct('ISSUED', { + effectiveAt: confirmationInstant, + ownerEvidenceRef: boundedEvidenceRef, +}); +const ReservationConfirmationOwnerHealthyObservationSchema = Schema.TaggedStruct('OWNER_HEALTHY', { + effectiveAt: confirmationInstant, + ownerEvidenceRef: boundedEvidenceRef, +}); +const ReservationConfirmationMaterialImpairmentObservationSchema = Schema.TaggedStruct('MATERIAL_IMPAIRMENT', { + effectiveAt: confirmationInstant, + ownerEvidenceRef: boundedEvidenceRef, +}); +const ReservationConfirmationBindingCorrectionObservationSchema = Schema.TaggedStruct('BINDING_CORRECTION', { + correctionEvidenceRef: boundedEvidenceRef, + effectiveAt: confirmationInstant, +}); +const ReservationConfirmationDefinitiveRevocationObservationSchema = Schema.TaggedStruct('DEFINITIVE_REVOCATION', { + decision: Schema.Literal('DEFINITIVE'), + effectiveAt: confirmationInstant, + ownerEvidenceRef: boundedEvidenceRef, +}); +const ReservationConfirmationOwnerUnverifiableObservationSchema = Schema.TaggedStruct('OWNER_UNVERIFIABLE', { + effectiveAt: confirmationInstant, + reason: Schema.Literals([ + 'OWNER_EVIDENCE_MISSING', + 'OWNER_EVIDENCE_STALE', + 'OWNER_EVIDENCE_UNAVAILABLE', + 'OWNER_EVIDENCE_INDETERMINATE', + ]), +}); +const ReservationConfirmationValidityElapsedObservationSchema = Schema.TaggedStruct('VALIDITY_ELAPSED', { + effectiveAt: confirmationInstant, +}); + +export const ReservationConfirmationHealthObservationSchema = Schema.Union([ + ReservationConfirmationIssuedObservationSchema, + ReservationConfirmationOwnerHealthyObservationSchema, + ReservationConfirmationMaterialImpairmentObservationSchema, + ReservationConfirmationBindingCorrectionObservationSchema, + ReservationConfirmationDefinitiveRevocationObservationSchema, + ReservationConfirmationOwnerUnverifiableObservationSchema, + ReservationConfirmationValidityElapsedObservationSchema, +]); +export type ReservationConfirmationHealthObservation = typeof ReservationConfirmationHealthObservationSchema.Type; + +export const ReservationConfirmationHealthSchema = Schema.Struct({ + observation: ReservationConfirmationHealthObservationSchema, + state: ReservationConfirmationHealthStateSchema, +}); + +export const ReservationConfirmationIssuanceRankSchema = Schema.Struct({ + issuedAt: confirmationInstant, + ownerEvidenceRef: boundedEvidenceRef, + source: Schema.Literal('RESERVATION_AUTHORITY_EVIDENCE'), +}); + +const sameRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameAllocation = ( + expected: ProvisionalInventoryReservation['requirements'][number]['allocations'][number], + actual: ReservationAuthorityAllocation, +) => + String(expected.allocationId) === String(actual.allocationId) && + expected.quantity.amount === actual.quantity.amount && + sameRef(expected.quantity.unitRef, actual.quantity.unitRef) && + sameRef(expected.stockItemRef, actual.stockItemRef) && + sameRef(expected.positionRef, actual.stockPositionRef); + +const proofMatchesReservation = ( + reservation: ProvisionalInventoryReservation, + evidence: AuthoritativeReservationEvidence, + operation: AuthoritativeReservationEvidence['operation'] = 'RESERVATION_CONFIRMATION', +) => { + const expectedAllocations = reservation.requirements.flatMap(({ allocations }) => allocations); + const actualAllocations = evidence.evidence.allocations; + return ( + evidence.operation === operation && + evidence.evidence.attemptId === reservation.origin.attemptId && + evidence.evidence.reservationId === reservation.ref.resourceId && + String(evidence.evidence.tenantId) === String(reservation.ref.tenantId) && + evidence.evidence.customerConfigurationId === reservation.authority.customerConfigurationId && + expectedAllocations.length === actualAllocations.length && + expectedAllocations.every((expected) => actualAllocations.some((actual) => sameAllocation(expected, actual))) + ); +}; + +const healthStateFor = ( + observation: Exclude, +): ReservationConfirmationHealthState => + Match.value(observation).pipe( + Match.tag('OWNER_HEALTHY', () => 'VALID' as const), + Match.tag('MATERIAL_IMPAIRMENT', () => 'AT_RISK' as const), + Match.tag('BINDING_CORRECTION', () => 'AT_RISK' as const), + Match.tag('DEFINITIVE_REVOCATION', () => 'REVOKED' as const), + Match.tag('VALIDITY_ELAPSED', () => 'EXPIRED' as const), + Match.tag('OWNER_UNVERIFIABLE', () => 'UNVERIFIABLE' as const), + Match.exhaustive, + ); + +const ReservationConfirmationBaseSchema = Schema.Struct({ + authorityEvidence: AuthoritativeReservationEvidenceSchema, + expiresAt: confirmationInstant, + health: ReservationConfirmationHealthSchema, + issuanceRank: ReservationConfirmationIssuanceRankSchema, + issuedAt: confirmationInstant, + ref: ReservationConfirmationRefSchema, + reservation: ProvisionalInventoryReservationSchema, + revision: Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })), +}); +type ReservationConfirmationCandidate = typeof ReservationConfirmationBaseSchema.Type; + +const confirmationProofInvariant = (confirmation: ReservationConfirmationCandidate): string | undefined => { + const { authorityEvidence, expiresAt, issuanceRank, issuedAt, ref, reservation } = confirmation; + if ( + String(ref.tenantId) !== String(reservation.ref.tenantId) || + String(ref.tenantId) !== String(authorityEvidence.evidence.tenantId) + ) { + return 'Confirmation, Reservation, and authority evidence must share one Tenant'; + } + if ( + issuedAt !== authorityEvidence.evidence.validFrom || + expiresAt !== authorityEvidence.evidence.validUntil || + issuanceRank.issuedAt !== issuedAt || + issuanceRank.ownerEvidenceRef !== authorityEvidence.evidence.ownerEvidenceRef + ) { + return 'Confirmation issuance, expiry, and rank must preserve the original authority evidence'; + } + if (issuedAt >= expiresAt) { + return 'Reservation Confirmation validity interval must be non-empty'; + } + const expectedOrigin = + reservation.authority.selection.backend === 'external_business_system' ? 'EXTERNAL_BUSINESS_SYSTEM' : 'ONTOS_WMS'; + return authorityEvidence.issuer.backend !== reservation.authority.selection.backend || + authorityEvidence.issuer.backendId !== reservation.authority.selection.backendId || + authorityEvidence.issuer.origin !== expectedOrigin || + !proofMatchesReservation(reservation, authorityEvidence) + ? 'Confirmation must preserve the exact selected authority and Reservation proof scope' + : undefined; +}; + +const confirmationHealthInvariant = (confirmation: ReservationConfirmationCandidate): string | undefined => { + const { expiresAt, health, issuedAt, revision } = confirmation; + const issued = Schema.is(ReservationConfirmationIssuedObservationSchema)(health.observation); + const validityElapsed = Schema.is(ReservationConfirmationValidityElapsedObservationSchema)(health.observation); + const expectedHealthState = issued ? 'VALID' : healthStateFor(health.observation); + if (health.state !== expectedHealthState) { + return 'Confirmation health state must match its exact observation evidence'; + } + if ((revision === 1) !== issued || health.observation.effectiveAt < issuedAt) { + return 'Initial issuance and later health revisions must preserve monotonic proof time'; + } + return (validityElapsed && health.observation.effectiveAt < expiresAt) || + (!validityElapsed && health.observation.effectiveAt >= expiresAt) + ? 'Confirmation health evidence must respect the original expiry boundary' + : undefined; +}; + +export const ReservationConfirmationSchema = ReservationConfirmationBaseSchema.check( + Schema.makeFilter( + (confirmation) => confirmationProofInvariant(confirmation) ?? confirmationHealthInvariant(confirmation), + ), +); +export type ReservationConfirmation = typeof ReservationConfirmationSchema.Type; + +export class ReservationConfirmationRejected extends Schema.TaggedError()( + 'ReservationConfirmationRejected', + { + code: Schema.Literal('reservation_confirmation_rejected'), + confirmationRef: Schema.optionalKey(ReservationConfirmationRefSchema), + reason: Schema.Literals([ + 'INVALID_CONFIRMATION', + 'TENANT_SCOPE_MISMATCH', + 'RESERVATION_SCOPE_MISMATCH', + 'AUTHORITY_SCOPE_MISMATCH', + 'PROOF_SCOPE_MISMATCH', + 'INVALID_PROOF_VALIDITY', + 'IDENTITY_NAMESPACE_COLLISION', + 'SIBLING_CONFIRMATION_FORBIDDEN', + 'CONFIRMATION_IDENTITY_CONFLICT', + 'CONFIRMATION_NOT_FOUND', + 'TERMINAL_HEALTH_STATE', + 'INVALID_HEALTH_TRANSITION', + 'HEALTH_OBSERVATION_BEFORE_ISSUANCE', + 'PROTECTION_ESTABLISHMENT_AFTER_EVALUATION', + 'PROTECTION_ESTABLISHMENT_OUTSIDE_VALID_INTERVAL', + 'REVISION_CONFLICT', + ]), + }, +) {} + +export type ReservationConfirmationError = ReservationConfirmationRejected | ReservationConfirmationUnavailable; + +export interface ReservationConfirmationPersistence { + readonly createOrRead: ( + candidate: ReservationConfirmation, + ) => EffectType.Effect< + { readonly confirmation: ReservationConfirmation; readonly outcome: 'INSERTED' | 'EXISTING' }, + ReservationConfirmationError + >; + readonly findByRef: ( + ref: ReservationConfirmationRef, + ) => EffectType.Effect, ReservationConfirmationError>; + readonly findByReservationAttempt: ( + reservationRef: ProvisionalInventoryReservation['ref'], + attemptId: ProvisionalInventoryReservation['origin']['attemptId'], + ) => EffectType.Effect, ReservationConfirmationError>; + readonly readHistory: ( + ref: ReservationConfirmationRef, + ) => EffectType.Effect; + readonly saveRevision: (input: { + readonly current: ReservationConfirmation; + readonly next: ReservationConfirmation; + }) => EffectType.Effect; +} + +export interface ReservationConfirmationProtectionObservation { + readonly evidence: AuthoritativeReservationEvidence; + /** + * A prospective establishment is a new owner effect requested while the Confirmation is currently usable. + * Original-effect recovery only proves when an already-requested effect actually happened. + */ + readonly kind: 'ORIGINAL_EFFECT_RECOVERY' | 'PROSPECTIVE_ESTABLISHMENT'; +} + +export interface ReservationConfirmationCommitmentEvaluationInput { + readonly evaluatedAt: typeof confirmationInstant.Type; + readonly protection?: ReservationConfirmationProtectionObservation; +} + +const rejected = (reason: ReservationConfirmationRejected['reason'], confirmationRef?: ReservationConfirmationRef) => + confirmationRef === undefined + ? new ReservationConfirmationRejected({ code: 'reservation_confirmation_rejected', reason }) + : new ReservationConfirmationRejected({ code: 'reservation_confirmation_rejected', confirmationRef, reason }); + +export const establishReservationConfirmation = Effect.fn('establishReservationConfirmation')( + function* establishConfirmation(input: { + readonly authorityEvidence: AuthoritativeReservationEvidence; + readonly confirmationRef: ReservationConfirmationRef; + readonly reservation: ProvisionalInventoryReservation; + }) { + const { authorityEvidence, confirmationRef, reservation } = input; + if (confirmationRef.tenantId !== reservation.ref.tenantId) { + return yield* rejected('TENANT_SCOPE_MISMATCH', confirmationRef); + } + if ( + String(confirmationRef.resourceId) === String(reservation.ref.resourceId) || + String(confirmationRef.resourceId) === String(reservation.origin.attemptId) + ) { + return yield* rejected('IDENTITY_NAMESPACE_COLLISION', confirmationRef); + } + if ( + authorityEvidence.issuer.backend !== reservation.authority.selection.backend || + authorityEvidence.issuer.backendId !== reservation.authority.selection.backendId || + authorityEvidence.issuer.origin !== + (reservation.authority.selection.backend === 'external_business_system' + ? 'EXTERNAL_BUSINESS_SYSTEM' + : 'ONTOS_WMS') + ) { + return yield* rejected('AUTHORITY_SCOPE_MISMATCH', confirmationRef); + } + if (!proofMatchesReservation(reservation, authorityEvidence)) { + return yield* rejected('PROOF_SCOPE_MISMATCH', confirmationRef); + } + const { ownerEvidenceRef, validFrom, validUntil } = authorityEvidence.evidence; + if ( + DateTime.toEpochMillis(DateTime.makeUnsafe(validUntil)) <= DateTime.toEpochMillis(DateTime.makeUnsafe(validFrom)) + ) { + return yield* rejected('INVALID_PROOF_VALIDITY', confirmationRef); + } + return yield* Schema.decodeEffect(ReservationConfirmationSchema)({ + authorityEvidence, + expiresAt: validUntil, + health: { + observation: { _tag: 'ISSUED', effectiveAt: validFrom, ownerEvidenceRef }, + state: 'VALID', + }, + issuanceRank: { issuedAt: validFrom, ownerEvidenceRef, source: 'RESERVATION_AUTHORITY_EVIDENCE' }, + issuedAt: validFrom, + ref: confirmationRef, + reservation, + revision: 1, + }).pipe(Effect.mapError((cause) => Object.assign(rejected('INVALID_CONFIRMATION', confirmationRef), { cause }))); + }, +); + +export const advanceReservationConfirmationHealth = Effect.fn('advanceReservationConfirmationHealth')( + function* advanceHealth( + confirmation: ReservationConfirmation, + observation: Exclude, + ) { + if (confirmation.health.state === 'REVOKED' || confirmation.health.state === 'EXPIRED') { + return yield* rejected('TERMINAL_HEALTH_STATE', confirmation.ref); + } + if (observation.effectiveAt < confirmation.issuedAt) { + return yield* rejected('HEALTH_OBSERVATION_BEFORE_ISSUANCE', confirmation.ref); + } + if (observation.effectiveAt < confirmation.health.observation.effectiveAt) { + return yield* rejected('INVALID_HEALTH_TRANSITION', confirmation.ref); + } + const nextState = healthStateFor(observation); + const validityElapsed = Schema.is(ReservationConfirmationValidityElapsedObservationSchema)(observation); + if (validityElapsed && observation.effectiveAt < confirmation.expiresAt) { + return yield* rejected('INVALID_HEALTH_TRANSITION', confirmation.ref); + } + if (!validityElapsed && observation.effectiveAt >= confirmation.expiresAt) { + return yield* rejected('INVALID_HEALTH_TRANSITION', confirmation.ref); + } + if ( + confirmation.health.state === 'VALID' && + Schema.is(ReservationConfirmationOwnerHealthyObservationSchema)(observation) + ) { + return yield* rejected('INVALID_HEALTH_TRANSITION', confirmation.ref); + } + return yield* Schema.decodeEffect(ReservationConfirmationSchema)({ + ...confirmation, + health: { observation, state: nextState }, + revision: confirmation.revision + 1, + }).pipe(Effect.mapError((cause) => Object.assign(rejected('INVALID_CONFIRMATION', confirmation.ref), { cause }))); + }, +); + +export const reservationConfirmationCanEstablishProtection = ( + confirmation: ReservationConfirmation, + establishmentAt: string, +): boolean => + confirmation.health.state === 'VALID' && + establishmentAt >= confirmation.issuedAt && + establishmentAt < confirmation.expiresAt; + +const instantMillis = (instant: string) => DateTime.toEpochMillis(DateTime.makeUnsafe(instant)); + +export const reservationConfirmationValidityHasElapsed = ( + confirmation: ReservationConfirmation, + evaluatedAt: string, +): boolean => instantMillis(evaluatedAt) >= instantMillis(confirmation.expiresAt); + +const protectionMatchesConfirmation = ( + confirmation: ReservationConfirmation, + protection: AuthoritativeReservationEvidence, +): boolean => + protection.issuer.backend === confirmation.authorityEvidence.issuer.backend && + protection.issuer.backendId === confirmation.authorityEvidence.issuer.backendId && + protection.issuer.origin === confirmation.authorityEvidence.issuer.origin && + proofMatchesReservation(confirmation.reservation, protection, 'COMMITMENT_PROTECTION'); + +const sameConfirmationTimeline = (current: ReservationConfirmation, revision: ReservationConfirmation): boolean => + sameRef(current.ref, revision.ref) && + current.issuedAt === revision.issuedAt && + current.expiresAt === revision.expiresAt && + current.issuanceRank.issuedAt === revision.issuanceRank.issuedAt && + current.issuanceRank.ownerEvidenceRef === revision.issuanceRank.ownerEvidenceRef && + current.reservation.origin.attemptId === revision.reservation.origin.attemptId && + sameRef(current.reservation.ref, revision.reservation.ref); + +const confirmationWasValidAt = ( + confirmation: ReservationConfirmation, + healthHistory: readonly ReservationConfirmation[], + establishedAtMillis: number, +): boolean => { + let effectiveRevision: ReservationConfirmation | undefined; + for (const revision of healthHistory) { + if (!sameConfirmationTimeline(confirmation, revision)) { + return false; + } + if ( + instantMillis(revision.health.observation.effectiveAt) <= establishedAtMillis && + (effectiveRevision === undefined || revision.revision > effectiveRevision.revision) + ) { + effectiveRevision = revision; + } + } + return effectiveRevision?.health.state === 'VALID'; +}; + +/** + * Evaluates the authoritative establishment time, not evidence arrival time. A new prospective effect is never + * allowed after expiry; recovery may only prove that the already-requested original effect happened in time. + */ +export const evaluateReservationConfirmationCommitment = Effect.fn('ReservationConfirmation.evaluateCommitment')( + function* evaluateCommitment( + confirmation: ReservationConfirmation, + input: ReservationConfirmationCommitmentEvaluationInput, + healthHistory: readonly ReservationConfirmation[] = [confirmation], + ) { + const evaluatedAt = yield* Schema.decodeEffect(confirmationInstant)(input.evaluatedAt).pipe( + Effect.mapError((cause) => Object.assign(rejected('INVALID_HEALTH_TRANSITION', confirmation.ref), { cause })), + ); + const evaluatedAtMillis = instantMillis(evaluatedAt); + const issuedAtMillis = instantMillis(confirmation.issuedAt); + const expiresAtMillis = instantMillis(confirmation.expiresAt); + + if (input.protection !== undefined) { + const { evidence, kind } = input.protection; + if (!protectionMatchesConfirmation(confirmation, evidence)) { + return yield* rejected('PROOF_SCOPE_MISMATCH', confirmation.ref); + } + const establishedAtMillis = instantMillis(evidence.evidence.validFrom); + if (establishedAtMillis > evaluatedAtMillis) { + return yield* rejected('PROTECTION_ESTABLISHMENT_AFTER_EVALUATION', confirmation.ref); + } + const establishedInTime = establishedAtMillis >= issuedAtMillis && establishedAtMillis < expiresAtMillis; + const establishedDuringValidInterval = confirmationWasValidAt(confirmation, healthHistory, establishedAtMillis); + if (establishedInTime && !establishedDuringValidInterval) { + return yield* rejected('PROTECTION_ESTABLISHMENT_OUTSIDE_VALID_INTERVAL', confirmation.ref); + } + const prospectiveAllowed = + kind === 'PROSPECTIVE_ESTABLISHMENT' && + confirmation.health.state === 'VALID' && + evaluatedAtMillis < expiresAtMillis && + establishedDuringValidInterval; + if (establishedInTime && (kind === 'ORIGINAL_EFFECT_RECOVERY' || prospectiveAllowed)) { + return { + confirmation, + fence: 'PRESERVED' as const, + outcome: 'PROTECTION_ESTABLISHED_IN_TIME' as const, + protectionEvidence: evidence, + }; + } + } + + if ( + confirmation.health.state === 'EXPIRED' || + confirmation.health.state === 'REVOKED' || + evaluatedAtMillis >= expiresAtMillis + ) { + return { + confirmation, + outcome: 'TERMINAL_READINESS_LOSS' as const, + replacement: 'BLOCKED_UNTIL_PREDECESSOR_RESOLVED' as const, + }; + } + if (confirmation.health.state === 'VALID') { + return { confirmation, outcome: 'READY_TO_ESTABLISH_PROTECTION' as const }; + } + return { + confirmation, + health: confirmation.health.state, + outcome: 'NOT_READY' as const, + }; + }, +); + +const canonicalReservationSchema = Schema.fromJsonString(ProvisionalInventoryReservationSchema); +const canonicalReservation = (reservation: ProvisionalInventoryReservation) => + Result.getOrThrow(Schema.encodeResult(canonicalReservationSchema)(reservation)); + +export const sameReservationConfirmationIssuance = ( + left: ReservationConfirmation, + input: { + readonly confirmationRef: ReservationConfirmationRef; + readonly effectId: AuthoritativeReservationEvidence['effectId']; + readonly reservation: ProvisionalInventoryReservation; + }, +): boolean => + sameRef(left.ref, input.confirmationRef) && + left.authorityEvidence.effectId === input.effectId && + canonicalReservation(left.reservation) === canonicalReservation(input.reservation); diff --git a/app/verticals/inventory/shared/domain/reservation-effect-indeterminate.ts b/app/verticals/inventory/shared/domain/reservation-effect-indeterminate.ts new file mode 100644 index 000000000..ba4d97aef --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-effect-indeterminate.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { reservationIssuerCommonFailureFields } from './reservation-issuer-failure-fields.ts'; + +export class ReservationEffectIndeterminate extends Schema.TaggedError()( + 'ReservationEffectIndeterminate', + { + ...reservationIssuerCommonFailureFields, + competingFreshEffectAllowed: Schema.Literal(false), + reason: Schema.Literal('RESERVATION_EFFECT_INDETERMINATE'), + recovery: Schema.Literal('RECOVER_ORIGINAL_EFFECT'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/reservation-issuer-evidence-rejected.ts b/app/verticals/inventory/shared/domain/reservation-issuer-evidence-rejected.ts new file mode 100644 index 000000000..3374f1f32 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-issuer-evidence-rejected.ts @@ -0,0 +1,17 @@ +import { Schema } from 'effect'; + +import { reservationIssuerCommonFailureFields } from './reservation-issuer-failure-fields.ts'; + +export class ReservationIssuerEvidenceRejected extends Schema.TaggedError()( + 'ReservationIssuerEvidenceRejected', + { + ...reservationIssuerCommonFailureFields, + reason: Schema.Literals([ + 'EFFECT_IDENTITY_MISMATCH', + 'ISSUER_IDENTITY_MISMATCH', + 'OPERATION_MISMATCH', + 'EXACT_RESERVATION_SCOPE_MISMATCH', + 'INVALID_PROOF_VALIDITY', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/reservation-issuer-failure-fields.ts b/app/verticals/inventory/shared/domain/reservation-issuer-failure-fields.ts new file mode 100644 index 000000000..12d507770 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-issuer-failure-fields.ts @@ -0,0 +1,18 @@ +import { Schema } from 'effect'; + +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; +import { InventoryBackendSchema } from '../inventory-launch-scope.ts'; + +export const ReservationAuthorityEffectIdSchema = Schema.String.check( + Schema.isTrimmed(), + Schema.isMinLength(1), + Schema.isMaxLength(300), +).pipe(Schema.brand('ReservationAuthorityEffectId')); + +export const reservationIssuerCommonFailureFields = { + fallbackApplied: Schema.Literal(false), + originalEffectId: ReservationAuthorityEffectIdSchema, + proofIssued: Schema.Literal(false), + selectedBackend: InventoryBackendSchema, + selectedBackendId: InventoryBackendIdSchema, +} as const; diff --git a/app/verticals/inventory/shared/domain/reservation-shortage-impact.ts b/app/verticals/inventory/shared/domain/reservation-shortage-impact.ts new file mode 100644 index 000000000..7ddd97ec8 --- /dev/null +++ b/app/verticals/inventory/shared/domain/reservation-shortage-impact.ts @@ -0,0 +1,331 @@ +import { DateTime, Effect, Result, Schema } from 'effect'; + +import { InventoryStockAllocationSchema } from './inventory-obligation.ts'; +import type { InventoryStockAllocation } from './inventory-obligation.ts'; +import { + ReservationConfirmationHealthStateSchema, + ReservationConfirmationIssuanceRankSchema, + ReservationConfirmationSchema, +} from './reservation-confirmation.ts'; +import { + ExactStockQuantityAmountSchema, + StockQuantitySchema, + addExactStockQuantityAmounts, + compareExactStockQuantityAmounts, + subtractExactStockQuantityAmounts, +} from './stock-position.ts'; +import type { StockQuantity } from './stock-position.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import type { StockPositionRef } from '../resources/stock-position.ts'; + +export const ReservationShortagePoolBoundarySchema = Schema.Literals([ + 'NONE', + 'COMMITMENT_PROTECTED', + 'RELEASED', + 'COMMITTED_OBLIGATION', +]); +export type ReservationShortagePoolBoundary = typeof ReservationShortagePoolBoundarySchema.Type; + +export const ReservationShortageCandidateSchema = Schema.Struct({ + allocations: Schema.Array(InventoryStockAllocationSchema).check(Schema.isMinLength(1)), + confirmation: ReservationConfirmationSchema, + poolBoundary: ReservationShortagePoolBoundarySchema, +}); +export type ReservationShortageCandidate = typeof ReservationShortageCandidateSchema.Type; + +export const ReservationShortageImpactInputSchema = Schema.Struct({ + affectedPositionRef: StockPositionRefSchema, + availableQuantity: StockQuantitySchema, + candidates: Schema.Array(ReservationShortageCandidateSchema), +}); +export type ReservationShortageImpactInput = typeof ReservationShortageImpactInputSchema.Type; + +const ReservationShortageDecisionSchema = Schema.Struct({ + affectedQuantity: StockQuantitySchema, + capacity: Schema.Literals(['HONORABLE', 'SHORTAGE']), + confirmationRef: ReservationConfirmationRefSchema, + currentHealth: ReservationConfirmationHealthStateSchema, + issuanceRank: ReservationConfirmationIssuanceRankSchema, +}); +type ReservationShortageDecision = typeof ReservationShortageDecisionSchema.Type; + +const DeterminateReservationShortageImpactSchema = Schema.TaggedStruct('DETERMINATE', { + affectedPositionRef: StockPositionRefSchema, + decisions: Schema.Array(ReservationShortageDecisionSchema), + fencedAmount: ExactStockQuantityAmountSchema, +}); + +const IndeterminateReservationShortageImpactSchema = Schema.TaggedStruct('INDETERMINATE', { + affectedPositionRef: StockPositionRefSchema, + candidateRefs: Schema.Array(ReservationConfirmationRefSchema).check(Schema.isMinLength(2)), + fencedAmount: ExactStockQuantityAmountSchema, + reason: Schema.Literal('AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE'), + reconciliationRequired: Schema.Literal(true), +}); + +export const ReservationShortageImpactEvaluationSchema = Schema.Union([ + DeterminateReservationShortageImpactSchema, + IndeterminateReservationShortageImpactSchema, +]); +export type ReservationShortageImpactEvaluation = typeof ReservationShortageImpactEvaluationSchema.Type; + +export class ReservationShortageImpactRejected extends Schema.TaggedError()( + 'ReservationShortageImpactRejected', + { + affectedPositionRef: StockPositionRefSchema, + code: Schema.Literal('inventory_reservation_shortage_impact_rejected'), + confirmationRef: Schema.optionalKey(ReservationConfirmationRefSchema), + reason: Schema.Literals([ + 'TENANT_SCOPE_MISMATCH', + 'AVAILABLE_QUANTITY_UNIT_MISMATCH', + 'DUPLICATE_CONFIRMATION', + 'CANDIDATE_ALLOCATION_MISMATCH', + 'CANDIDATE_ALLOCATION_UNIT_MISMATCH', + 'INVALID_AFFECTED_QUANTITY', + ]), + }, +) {} + +interface EligibleCandidate { + readonly affectedQuantity: StockQuantity; + readonly candidate: ReservationShortageCandidate; +} + +interface CollectedCandidates { + readonly eligible: readonly EligibleCandidate[]; + readonly fencedAmount: StockQuantity['amount']; +} + +const sameRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const sameAllocation = (left: InventoryStockAllocation, right: InventoryStockAllocation) => + String(left.allocationId) === String(right.allocationId) && + left.quantity.amount === right.quantity.amount && + sameRef(left.positionRef, right.positionRef) && + sameRef(left.quantity.unitRef, right.quantity.unitRef) && + sameRef(left.stockItemRef, right.stockItemRef); + +const rejection = ( + affectedPositionRef: StockPositionRef, + reason: ReservationShortageImpactRejected['reason'], + confirmationRef?: typeof ReservationConfirmationRefSchema.Type, +) => + confirmationRef === undefined + ? new ReservationShortageImpactRejected({ + affectedPositionRef, + code: 'inventory_reservation_shortage_impact_rejected', + reason, + }) + : new ReservationShortageImpactRejected({ + affectedPositionRef, + code: 'inventory_reservation_shortage_impact_rejected', + confirmationRef, + reason, + }); + +const isInPriorityPool = ({ confirmation, poolBoundary }: ReservationShortageCandidate) => + poolBoundary === 'NONE' && + (confirmation.health.state === 'VALID' || + confirmation.health.state === 'AT_RISK' || + confirmation.health.state === 'UNVERIFIABLE'); + +const fencesCapacity = ({ confirmation, poolBoundary }: ReservationShortageCandidate) => + poolBoundary === 'COMMITMENT_PROTECTED' || + poolBoundary === 'COMMITTED_OBLIGATION' || + (poolBoundary === 'NONE' && (confirmation.health.state === 'EXPIRED' || confirmation.health.state === 'REVOKED')); + +const candidateRefKey = ({ confirmation: { ref } }: ReservationShortageCandidate) => + `${ref.tenantId}:${ref.resourceId}`; + +const issuanceEpoch = (candidate: ReservationShortageCandidate) => + DateTime.toEpochMillis(DateTime.makeUnsafe(candidate.confirmation.issuanceRank.issuedAt)); + +const compareAuthoritativeRank = (left: EligibleCandidate, right: EligibleCandidate) => { + const issuedAtOrder = issuanceEpoch(left.candidate) - issuanceEpoch(right.candidate); + return issuedAtOrder === 0 + ? String(left.candidate.confirmation.ref.resourceId).localeCompare( + String(right.candidate.confirmation.ref.resourceId), + ) + : issuedAtOrder; +}; + +const invalidAffectedQuantity = ( + affectedPositionRef: StockPositionRef, + confirmationRef: typeof ReservationConfirmationRefSchema.Type | undefined, + cause: unknown, +) => { + const failure = rejection(affectedPositionRef, 'INVALID_AFFECTED_QUANTITY', confirmationRef); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +const collectEligibleCandidates = ( + input: ReservationShortageImpactInput, +): Result.Result => { + const { affectedPositionRef, availableQuantity, candidates } = input; + if ( + availableQuantity.unitRef.tenantId !== affectedPositionRef.tenantId || + candidates.some(({ confirmation }) => confirmation.ref.tenantId !== affectedPositionRef.tenantId) + ) { + return Result.fail(rejection(affectedPositionRef, 'TENANT_SCOPE_MISMATCH')); + } + const seenConfirmationRefs = new Set(); + const eligible: EligibleCandidate[] = []; + let fencedAmount = ExactStockQuantityAmountSchema.make('0'); + for (const candidate of candidates) { + const confirmationRef = candidate.confirmation.ref; + const confirmationRefKey = candidateRefKey(candidate); + if (seenConfirmationRefs.has(confirmationRefKey)) { + return Result.fail(rejection(affectedPositionRef, 'DUPLICATE_CONFIRMATION', confirmationRef)); + } + seenConfirmationRefs.add(confirmationRefKey); + + const persistedAllocations = candidate.confirmation.reservation.requirements.flatMap( + ({ allocations }) => allocations, + ); + if ( + persistedAllocations.length !== candidate.allocations.length || + persistedAllocations.some( + (persisted) => + !candidate.allocations.some((candidateAllocation) => sameAllocation(persisted, candidateAllocation)), + ) + ) { + return Result.fail(rejection(affectedPositionRef, 'CANDIDATE_ALLOCATION_MISMATCH', confirmationRef)); + } + + const participatesInCapacity = isInPriorityPool(candidate) || fencesCapacity(candidate); + const affectedAllocations = participatesInCapacity + ? candidate.allocations.filter(({ positionRef }) => sameRef(positionRef, affectedPositionRef)) + : []; + if (affectedAllocations.length > 0) { + if (affectedAllocations.some(({ quantity }) => !sameRef(quantity.unitRef, availableQuantity.unitRef))) { + return Result.fail(rejection(affectedPositionRef, 'CANDIDATE_ALLOCATION_UNIT_MISMATCH', confirmationRef)); + } + + const [firstAffectedAllocation, ...remainingAffectedAllocations] = affectedAllocations; + if (firstAffectedAllocation !== undefined) { + let affectedAmount = firstAffectedAllocation.quantity.amount; + for (const { quantity } of remainingAffectedAllocations) { + const sum = addExactStockQuantityAmounts(affectedAmount, quantity.amount); + if (Result.isFailure(sum)) { + return Result.fail(invalidAffectedQuantity(affectedPositionRef, confirmationRef, sum.failure)); + } + affectedAmount = sum.success; + } + if (affectedAmount !== '0' && isInPriorityPool(candidate)) { + eligible.push({ + affectedQuantity: { amount: affectedAmount, unitRef: availableQuantity.unitRef }, + candidate, + }); + } else if (affectedAmount !== '0' && fencesCapacity(candidate)) { + const sum = addExactStockQuantityAmounts(fencedAmount, affectedAmount); + if (Result.isFailure(sum)) { + return Result.fail(invalidAffectedQuantity(affectedPositionRef, confirmationRef, sum.failure)); + } + fencedAmount = sum.success; + } + } + } + } + return Result.succeed({ eligible, fencedAmount }); +}; + +const evaluateImpact = ( + input: ReservationShortageImpactInput, +): Result.Result => { + const { affectedPositionRef, availableQuantity } = input; + + const collected = collectEligibleCandidates(input); + if (Result.isFailure(collected)) { + return Result.fail(collected.failure); + } + const { eligible: collectedEligible, fencedAmount } = collected.success; + const eligible = [...collectedEligible]; + eligible.sort(compareAuthoritativeRank); + for (let index = 1; index < eligible.length; index += 1) { + const previous = eligible[index - 1]; + const current = eligible[index]; + if ( + previous !== undefined && + current !== undefined && + issuanceEpoch(previous.candidate) === issuanceEpoch(current.candidate) + ) { + return Result.succeed({ + _tag: 'INDETERMINATE', + affectedPositionRef, + candidateRefs: eligible.map(({ candidate }) => candidate.confirmation.ref), + fencedAmount, + reason: 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE', + reconciliationRequired: true, + }); + } + } + + let remaining = availableQuantity.amount; + if (fencedAmount !== '0') { + const unfenced = subtractExactStockQuantityAmounts( + remaining, + compareExactStockQuantityAmounts(remaining, fencedAmount) >= 0 ? fencedAmount : remaining, + ); + if (Result.isFailure(unfenced)) { + return Result.fail(invalidAffectedQuantity(affectedPositionRef, undefined, unfenced.failure)); + } + remaining = unfenced.success; + } + let shortageStarted = false; + const decisions: ReservationShortageDecision[] = []; + for (const { affectedQuantity, candidate } of eligible) { + const honorable = !shortageStarted && compareExactStockQuantityAmounts(remaining, affectedQuantity.amount) >= 0; + if (honorable) { + const nextRemaining = subtractExactStockQuantityAmounts(remaining, affectedQuantity.amount); + if (Result.isFailure(nextRemaining)) { + return Result.fail( + invalidAffectedQuantity(affectedPositionRef, candidate.confirmation.ref, nextRemaining.failure), + ); + } + remaining = nextRemaining.success; + } else { + shortageStarted = true; + } + decisions.push({ + affectedQuantity, + capacity: honorable ? 'HONORABLE' : 'SHORTAGE', + confirmationRef: candidate.confirmation.ref, + currentHealth: candidate.confirmation.health.state, + issuanceRank: candidate.confirmation.issuanceRank, + }); + } + + return Result.succeed({ _tag: 'DETERMINATE', affectedPositionRef, decisions, fencedAmount }); +}; + +export const deriveReservationShortageFencedAmount = Effect.fn('deriveReservationShortageFencedAmount')( + (input: ReservationShortageImpactInput) => + Effect.fromResult(collectEligibleCandidates(input)).pipe(Effect.map(({ fencedAmount }) => fencedAmount)), +); + +/** + * Evaluates only the affected constrained Position. Exiting this priority pool never implies that + * a backend Reservation has been released or that its Quantity is reusable. + */ +export const evaluateReservationShortageImpact = Effect.fn('evaluateReservationShortageImpact')( + (input: ReservationShortageImpactInput) => Effect.fromResult(evaluateImpact(input)), +); diff --git a/app/verticals/inventory/shared/domain/runtime-order-commit-proof-rejected.ts b/app/verticals/inventory/shared/domain/runtime-order-commit-proof-rejected.ts new file mode 100644 index 000000000..d89fbb373 --- /dev/null +++ b/app/verticals/inventory/shared/domain/runtime-order-commit-proof-rejected.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class RuntimeOrderCommitProofRejected extends Schema.TaggedError()( + 'RuntimeOrderCommitProofRejected', + { + code: Schema.Literal('runtime_order_commit_proof_rejected'), + reason: Schema.Literal('ORDER_NOT_PROVEN_COMMITTED'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/runtime-order-commit-proof-unavailable.ts b/app/verticals/inventory/shared/domain/runtime-order-commit-proof-unavailable.ts new file mode 100644 index 000000000..4dc43b6bb --- /dev/null +++ b/app/verticals/inventory/shared/domain/runtime-order-commit-proof-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class RuntimeOrderCommitProofUnavailable extends Schema.TaggedError()( + 'RuntimeOrderCommitProofUnavailable', + { + code: Schema.Literal('runtime_order_commit_proof_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/shared/domain/stock-correction-conflict.ts b/app/verticals/inventory/shared/domain/stock-correction-conflict.ts new file mode 100644 index 000000000..be96c408e --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-correction-conflict.ts @@ -0,0 +1,15 @@ +import { Schema } from 'effect'; + +import { StockCorrectionIdSchema } from './stock-correction-identifiers.ts'; + +export class StockCorrectionConflict extends Schema.TaggedError()('StockCorrectionConflict', { + code: Schema.Literal('stock_correction_conflict'), + correctionId: StockCorrectionIdSchema, + reason: Schema.Literals([ + 'ASSERTION_ALREADY_USED', + 'EVIDENCE_ALREADY_USED', + 'CORRECTION_ID_CONFLICT', + 'OPEN_RECONCILIATION_MISMATCH', + 'POSITION_REVISION_CONFLICT', + ]), +}) {} diff --git a/app/verticals/inventory/shared/domain/stock-correction-identifiers.ts b/app/verticals/inventory/shared/domain/stock-correction-identifiers.ts new file mode 100644 index 000000000..5e5913561 --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-correction-identifiers.ts @@ -0,0 +1,4 @@ +import { Schema } from 'effect'; + +export const StockCorrectionIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('StockCorrectionId')); +export type StockCorrectionId = typeof StockCorrectionIdSchema.Type; diff --git a/app/verticals/inventory/shared/domain/stock-correction-rejected.ts b/app/verticals/inventory/shared/domain/stock-correction-rejected.ts new file mode 100644 index 000000000..870323c4e --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-correction-rejected.ts @@ -0,0 +1,21 @@ +import { Schema } from 'effect'; + +import { StockCorrectionIdSchema } from './stock-correction-identifiers.ts'; + +export class StockCorrectionRejected extends Schema.TaggedError()('StockCorrectionRejected', { + code: Schema.Literal('stock_correction_rejected'), + correctionId: StockCorrectionIdSchema, + reason: Schema.Literals([ + 'AUTHORITY_NOT_SELECTED', + 'CORRECTION_NOT_PERMITTED', + 'CUSTOMER_CONFIGURATION_MISMATCH', + 'POSITION_NOT_CURRENT', + 'POSITION_NOT_FOUND', + 'SOURCE_ASSERTION_NOT_FOUND', + 'SOURCE_ASSERTION_NOT_CURRENT', + 'SOURCE_ASSERTION_SCOPE_MISMATCH', + 'SOURCE_EVIDENCE_NOT_FOUND', + 'TENANT_SCOPE_MISMATCH', + 'UNIT_MISMATCH', + ]), +}) {} diff --git a/app/verticals/inventory/shared/domain/stock-correction-unavailable.ts b/app/verticals/inventory/shared/domain/stock-correction-unavailable.ts new file mode 100644 index 000000000..98781f7bf --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-correction-unavailable.ts @@ -0,0 +1,13 @@ +import { Schema } from 'effect'; + +import { StockCorrectionIdSchema } from './stock-correction-identifiers.ts'; + +export class StockCorrectionUnavailable extends Schema.TaggedError()( + 'StockCorrectionUnavailable', + { + code: Schema.Literal('stock_correction_unavailable'), + correctionId: Schema.optionalKey(StockCorrectionIdSchema), + reason: Schema.String, + retryable: Schema.Literal(true), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/stock-correction.ts b/app/verticals/inventory/shared/domain/stock-correction.ts new file mode 100644 index 000000000..dce43b95b --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-correction.ts @@ -0,0 +1,253 @@ +import type { Effect as EffectType } from 'effect'; +import { DateTime, Schema } from 'effect'; + +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockLocationRefSchema } from '../resources/stock-location.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { + InventorySourceAssertionIdSchema, + InventorySourceOrderingEvidenceSchema, + SourceCoverageEvidenceSchema, +} from './inventory-source-assertion.ts'; +import { InventoryBackendConfigurationSchema } from './inventory-backend-configuration.ts'; +import { InventoryBackendIdSchema } from './inventory-backend-identifiers.ts'; +import { InventoryBackendOriginSchema } from './external-stock-correlation.ts'; +import { PhysicalStockBusinessReasonSchema, PhysicalStockEffectIdSchema } from './physical-stock-effect.ts'; +import { + StockPositionOnHandEvidenceSchema, + StockPositionRevisionSchema, + StockPositionSchema, + StockQuantitySchema, +} from './stock-position.ts'; +import type { ExactStockQuantityAmount } from './stock-position.ts'; +import { StockCorrectionConflict } from './stock-correction-conflict.ts'; +import { StockCorrectionIdSchema } from './stock-correction-identifiers.ts'; +import { StockCorrectionRejected } from './stock-correction-rejected.ts'; +import { StockCorrectionUnavailable } from './stock-correction-unavailable.ts'; + +const instant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const signedCanonicalDecimal = /^(?:0|-?[1-9][0-9]*)(?:\.[0-9]*[1-9])?$/u; +const boundedEvidenceText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); + +export const SignedStockQuantityDeltaSchema = Schema.String.check( + Schema.makeFilter((value) => + signedCanonicalDecimal.test(value) + ? undefined + : 'Stock Correction delta must be a canonical signed decimal without exponent, leading zero, or trailing fractional zero', + ), +).pipe(Schema.brand('SignedStockQuantityDelta')); + +/** + * External owners point at their immutable Source Assertion. OntOS WMS owns the correction + * boundary directly, so it supplies only the absolute observation and bounded provenance; the + * service derives observation time and material-effect coverage under the selected owner. + */ +export const ExternalSourceAssertionCorrectionEvidenceSchema = Schema.TaggedStruct('EXTERNAL_SOURCE_ASSERTION', { + sourceAssertionId: InventorySourceAssertionIdSchema, +}); +export const StockCorrectionSourceEvidenceIdSchema = Schema.String.check(Schema.isUUID()).pipe( + Schema.brand('StockCorrectionSourceEvidenceId'), +); +export type StockCorrectionSourceEvidenceId = typeof StockCorrectionSourceEvidenceIdSchema.Type; +export const OntosWmsCorrectionCoverageEvidenceSchema = Schema.Struct({ + effectId: PhysicalStockEffectIdSchema, + evidenceId: StockCorrectionSourceEvidenceIdSchema, + ownerEvidenceRef: boundedEvidenceText, + relation: Schema.Literals(['INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN']), +}); +export const OntosWmsCorrectionEvidenceSchema = Schema.TaggedStruct('ONTOS_WMS_OWNER_EVIDENCE', { + evidenceId: StockCorrectionSourceEvidenceIdSchema, +}); +export const StockCorrectionEvidenceSchema = Schema.Union([ + ExternalSourceAssertionCorrectionEvidenceSchema, + OntosWmsCorrectionEvidenceSchema, +]); + +/** Trusted, append-only evidence authored behind the selected OntOS WMS owner boundary. */ +export const OntosWmsStockCorrectionSourceEvidenceSchema = Schema.Struct({ + authorityConfiguration: InventoryBackendConfigurationSchema, + businessObservedAt: instant, + coverage: Schema.Array(OntosWmsCorrectionCoverageEvidenceSchema), + customerConfigurationId: CustomerConfigurationIdSchema, + evidenceId: StockCorrectionSourceEvidenceIdSchema, + factMeaning: Schema.Literal('ABSOLUTE_PHYSICAL_ON_HAND'), + issuer: Schema.Struct({ backendId: InventoryBackendIdSchema, backendKind: Schema.Literal('ontos_wms') }), + orderingEvidence: InventorySourceOrderingEvidenceSchema, + ownerEvidenceRef: boundedEvidenceText, + positionRef: StockPositionRefSchema, + quantity: StockQuantitySchema, + receivedAt: instant, + sourceReference: boundedEvidenceText, + stockItemRef: StockItemRefSchema, + stockLocationRef: StockLocationRefSchema, +}).check( + Schema.makeFilter((evidence) => { + const { tenantId } = evidence.positionRef; + if ( + evidence.authorityConfiguration.tenantId !== tenantId || + evidence.authorityConfiguration.customerConfigurationId !== evidence.customerConfigurationId || + evidence.authorityConfiguration.selection.backend !== 'ontos_wms' || + evidence.authorityConfiguration.selection.backendId !== evidence.issuer.backendId || + evidence.issuer.backendKind !== 'ontos_wms' || + evidence.stockItemRef.tenantId !== tenantId || + evidence.stockLocationRef.tenantId !== tenantId || + evidence.quantity.unitRef.tenantId !== tenantId + ) { + return 'OntOS WMS correction evidence must match one exact selected owner and stock scope'; + } + if ( + DateTime.toEpochMillis(DateTime.makeUnsafe(evidence.businessObservedAt)) < + DateTime.toEpochMillis(DateTime.makeUnsafe(evidence.authorityConfiguration.selectedAt)) + ) { + return 'OntOS WMS correction evidence must be observed at or after the selected owner cutover'; + } + if (evidence.coverage.some((entry) => entry.evidenceId !== evidence.evidenceId)) { + return 'OntOS WMS coverage must bind the exact correction source evidence identity'; + } + return new Set(evidence.coverage.map(({ effectId }) => effectId)).size === evidence.coverage.length + ? undefined + : 'OntOS WMS coverage must be unique for each exact physical effect'; + }), +); +export type OntosWmsStockCorrectionSourceEvidence = typeof OntosWmsStockCorrectionSourceEvidenceSchema.Type; + +export const StockCorrectionPayloadSchema = Schema.Struct({ + correctionId: StockCorrectionIdSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + evidence: StockCorrectionEvidenceSchema, + expectedPositionRevision: StockPositionRevisionSchema, + positionRef: StockPositionRefSchema, + reason: PhysicalStockBusinessReasonSchema, + reconcilesCorrectionId: Schema.optionalKey(StockCorrectionIdSchema), +}); +export type StockCorrectionPayload = typeof StockCorrectionPayloadSchema.Type; + +const correctionCommon = { + actionInvocationId: Schema.String.check(Schema.isUUID()), + appliedAt: instant, + authorityConfigurationRef: InventoryBackendConfigurationRefSchema, + businessObservedAt: instant, + correctionId: StockCorrectionIdSchema, + coverageEvidence: Schema.Array( + Schema.Union([SourceCoverageEvidenceSchema, OntosWmsCorrectionCoverageEvidenceSchema]), + ), + customerConfigurationId: CustomerConfigurationIdSchema, + evaluatedMaterialEffectIds: Schema.Array(PhysicalStockEffectIdSchema), + evidenceKind: Schema.Literals(['EXTERNAL_SOURCE_ASSERTION', 'ONTOS_WMS_OWNER_EVIDENCE']), + expectedPositionRevision: StockPositionRevisionSchema, + issuer: InventoryBackendOriginSchema, + ownerEvidenceRef: boundedEvidenceText, + positionRef: StockPositionRefSchema, + positionRevisionAfter: StockPositionRevisionSchema, + previousOnHand: StockPositionOnHandEvidenceSchema, + principalId: Schema.String.check(Schema.isUUID()), + reason: PhysicalStockBusinessReasonSchema, + // oxlint-disable-next-line effect-native/no-nullable-schema-field -- Persisted Action evidence uses explicit JSON null for the absent reconciliation identity; expires: 2027-03-31. + reconcilesCorrectionId: Schema.NullOr(StockCorrectionIdSchema), + // oxlint-disable-next-line effect-native/no-nullable-schema-field -- The two evidence identity columns form a database-enforced JSON-null XOR; expires: 2027-03-31. + sourceAssertionId: Schema.NullOr(InventorySourceAssertionIdSchema), + // oxlint-disable-next-line effect-native/no-nullable-schema-field -- The two evidence identity columns form a database-enforced JSON-null XOR; expires: 2027-03-31. + sourceEvidenceId: Schema.NullOr(StockCorrectionSourceEvidenceIdSchema), + sourceOrderingEvidence: InventorySourceOrderingEvidenceSchema, + sourceReference: boundedEvidenceText, +} as const; + +export const AppliedStockCorrectionSchema = Schema.TaggedStruct('APPLIED', { + ...correctionCommon, + correctedQuantity: StockQuantitySchema, + explanatoryDelta: Schema.toEncoded(Schema.OptionFromNullOr(SignedStockQuantityDeltaSchema)), + materialChange: Schema.Literals(['DECREASE', 'INCREASE', 'UNCHANGED', 'UNRESOLVED_BASELINE']), +}); + +export const IndeterminateStockCorrectionSchema = Schema.TaggedStruct('INDETERMINATE', { + ...correctionCommon, + materialEffectIds: Schema.Array(PhysicalStockEffectIdSchema), + reasonCode: Schema.Literals([ + 'MATERIAL_EFFECT_COVERAGE_MISSING', + 'MATERIAL_EFFECT_COVERAGE_UNKNOWN', + 'MATERIAL_EFFECT_EXCLUDED_OR_PREDATED', + ]), +}); + +export const StockCorrectionRecordSchema = Schema.Union([ + AppliedStockCorrectionSchema, + IndeterminateStockCorrectionSchema, +]).check( + Schema.makeFilter((record) => { + const external = + record.evidenceKind === 'EXTERNAL_SOURCE_ASSERTION' && + record.issuer.backendKind === 'external_business_system' && + record.sourceAssertionId !== null && + record.sourceEvidenceId === null; + const wms = + record.evidenceKind === 'ONTOS_WMS_OWNER_EVIDENCE' && + record.issuer.backendKind === 'ontos_wms' && + record.sourceAssertionId === null && + record.sourceEvidenceId !== null; + return external || wms + ? undefined + : 'Stock Correction must bind exactly one owner-valid evidence identity for its issuer kind'; + }), +); +export type StockCorrectionRecord = typeof StockCorrectionRecordSchema.Type; + +export const StockCorrectionResultSchema = Schema.Struct({ + correction: StockCorrectionRecordSchema, + outcome: Schema.Literals(['APPLIED', 'EXACT_REPLAY', 'RECONCILIATION_REQUIRED']), + position: StockPositionSchema, +}); +export type StockCorrectionResult = typeof StockCorrectionResultSchema.Type; + +export const StockCorrectionErrorSchema = Schema.Union([ + StockCorrectionConflict, + StockCorrectionRejected, + StockCorrectionUnavailable, +]); +export type StockCorrectionError = typeof StockCorrectionErrorSchema.Type; + +interface DecimalParts { + readonly coefficient: bigint; + readonly scale: number; +} + +const decimalParts = (amount: string): DecimalParts => { + const negative = amount.startsWith('-'); + const unsigned = negative ? amount.slice(1) : amount; + const [integer = '0', fraction = ''] = unsigned.split('.'); + const coefficient = BigInt(`${integer}${fraction}`) * (negative ? -1n : 1n); + return { coefficient, scale: fraction.length }; +}; + +const formatDecimal = (coefficient: bigint, scale: number): string => { + const negative = coefficient < 0n; + const unsigned = negative ? -coefficient : coefficient; + if (scale === 0) { + return coefficient.toString(); + } + const padded = unsigned.toString().padStart(scale + 1, '0'); + const integer = padded.slice(0, -scale); + const fraction = padded.slice(-scale).replace(/0+$/u, ''); + const value = fraction.length === 0 ? integer : `${integer}.${fraction}`; + return value === '0' ? value : `${negative ? '-' : ''}${value}`; +}; + +/** The correction meaning is absolute; this signed delta is explanatory evidence only. */ +export const deriveStockCorrectionDelta = ( + previous: ExactStockQuantityAmount, + corrected: ExactStockQuantityAmount, +): EffectType.Effect => { + const left = decimalParts(previous); + const right = decimalParts(corrected); + const scale = Math.max(left.scale, right.scale); + const coefficient = + right.coefficient * 10n ** BigInt(scale - right.scale) - left.coefficient * 10n ** BigInt(scale - left.scale); + return Schema.decodeEffect(SignedStockQuantityDeltaSchema)(formatDecimal(coefficient, scale)); +}; + +export { StockCorrectionConflict } from './stock-correction-conflict.ts'; +export { StockCorrectionIdSchema } from './stock-correction-identifiers.ts'; +export type { StockCorrectionId } from './stock-correction-identifiers.ts'; +export { StockCorrectionRejected } from './stock-correction-rejected.ts'; +export { StockCorrectionUnavailable } from './stock-correction-unavailable.ts'; diff --git a/app/verticals/inventory/shared/domain/stock-item.ts b/app/verticals/inventory/shared/domain/stock-item.ts new file mode 100644 index 000000000..ab1f225b1 --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-item.ts @@ -0,0 +1,91 @@ +import { Schema } from 'effect'; +import { ProductUnitRefSchema } from '@app/catalog/resources/product-unit'; + +import { StockItemIdSchema, StockItemRefSchema } from '../resources/stock-item.ts'; + +const BoundedIdentifierSchema = Schema.Trim.check(Schema.isMinLength(1), Schema.isMaxLength(300)); + +export const ExactCatalogSelectionMeaningIdSchema = BoundedIdentifierSchema.pipe( + Schema.brand('ExactCatalogSelectionMeaningId'), +); +export type ExactCatalogSelectionMeaningId = typeof ExactCatalogSelectionMeaningIdSchema.Type; + +export const ExactCatalogSelectionKindSchema = Schema.Literals([ + 'PRODUCT_VARIANT', + 'PACKAGE_OPTION', + 'SET_VARIANT', + 'CONFIGURED_SELECTION', +]); +export type ExactCatalogSelectionKind = typeof ExactCatalogSelectionKindSchema.Type; + +/** + * An opaque Catalog-owned meaning identity. Inventory retains it exactly and + * deliberately cannot derive it from Product, SKU, labels, package contents, + * Set components, or configuration attributes. + */ +export const ExactCatalogSelectionMeaningSchema = Schema.Struct({ + id: ExactCatalogSelectionMeaningIdSchema, + kind: ExactCatalogSelectionKindSchema, +}); +export type ExactCatalogSelectionMeaning = typeof ExactCatalogSelectionMeaningSchema.Type; + +export const StockItemLifecycleSchema = Schema.Literals(['CURRENT', 'RETIRED']); + +export const StockItemInstantSchema = Schema.toEncoded(Schema.DateTimeUtcFromString); +export type StockItemInstant = typeof StockItemInstantSchema.Type; + +export const StockItemRevisionSchema = Schema.Finite.check( + Schema.isInt(), + Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 }), +); + +export const CreateStockItemInputSchema = Schema.Struct({ + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + tenantId: StockItemRefSchema.fields.tenantId, + unitRef: ProductUnitRefSchema, +}).check( + Schema.makeFilter(({ tenantId, unitRef }) => + tenantId === unitRef.tenantId ? undefined : 'Stock Item and exact Catalog Unit must share one Tenant', + ), +); +export type CreateStockItemInput = typeof CreateStockItemInputSchema.Type; + +export const StockItemCompatibilityInputSchema = Schema.Struct({ + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + unitRef: ProductUnitRefSchema, +}); +export type StockItemCompatibilityInput = typeof StockItemCompatibilityInputSchema.Type; + +export const StockItemSchema = Schema.Struct({ + createdAt: StockItemInstantSchema, + exactSelectionMeaning: ExactCatalogSelectionMeaningSchema, + lifecycle: StockItemLifecycleSchema, + retiredAt: Schema.toEncoded(Schema.OptionFromNullOr(StockItemInstantSchema)), + revision: StockItemRevisionSchema, + stockItemRef: StockItemRefSchema, + unitRef: ProductUnitRefSchema, +}).check( + Schema.makeFilter((item) => { + if (item.stockItemRef.tenantId !== item.unitRef.tenantId) { + return 'Stock Item and exact Catalog Unit must share one Tenant'; + } + return (item.lifecycle === 'CURRENT' && item.retiredAt === null) || + (item.lifecycle === 'RETIRED' && item.retiredAt !== null) + ? undefined + : 'Stock Item retirement timestamp must match its lifecycle'; + }), +); +export type StockItem = typeof StockItemSchema.Type; + +export class StockItemRejected extends Schema.TaggedError()('StockItemRejected', { + code: Schema.Literal('stock_item_rejected'), + exactSelectionMeaningId: Schema.optionalKey(ExactCatalogSelectionMeaningIdSchema), + reason: Schema.Literals([ + 'exact_selection_meaning_already_registered', + 'exact_selection_meaning_mismatch', + 'stock_item_not_found', + 'stock_item_retired', + 'stock_unit_mismatch', + ]), + stockItemId: Schema.optionalKey(StockItemIdSchema), +}) {} diff --git a/app/verticals/inventory/shared/domain/stock-location.ts b/app/verticals/inventory/shared/domain/stock-location.ts new file mode 100644 index 000000000..71b31520e --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-location.ts @@ -0,0 +1,209 @@ +import { Effect, Match, Schema } from 'effect'; + +import { StockLocationRefSchema } from '../resources/stock-location.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const reason = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(1000)); +const timestamp = Schema.toEncoded(Schema.DateTimeUtcFromString); +const PhysicalSiteEvidenceKeySchema = boundedText.pipe( + Schema.brand('InventoryPhysicalSiteEvidenceKey'), + Schema.decodeTo(boundedText), +); +const ExternalStockLocationIssuerIdSchema = boundedText.pipe( + Schema.brand('ExternalStockLocationIssuerId'), + Schema.decodeTo(boundedText), +); +const ExternalStockLocationCorrelationIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('ExternalStockLocationCorrelationId'), + Schema.decodeTo(Schema.String.check(Schema.isUUID(), Schema.isTrimmed())), +); +const physicalSiteKeys = Schema.Array(PhysicalSiteEvidenceKeySchema).check( + Schema.isMaxLength(100), + Schema.makeFilter((keys) => new Set(keys).size === keys.length || 'Physical-site evidence keys must be distinct'), +); + +export const StockLocationAddressEvidenceSchema = Schema.Struct({ + countryCode: Schema.String.check(Schema.isPattern(/^[A-Z]{2}$/u)), + lines: Schema.Array(boundedText).check(Schema.isMinLength(1), Schema.isMaxLength(4)), + locality: Schema.optionalKey(boundedText), + postalCode: Schema.optionalKey(boundedText), +}); +export type StockLocationAddressEvidence = typeof StockLocationAddressEvidenceSchema.Type; + +const PhysicalSiteScopeSchema = Schema.TaggedStruct('PHYSICAL_SITE', { + physicalSiteKeys, +}).check( + Schema.makeFilter( + ({ physicalSiteKeys: keys }) => + keys.length === 1 || 'A physical-site Stock Location must declare exactly one physical site', + ), +); + +export const LogicalAggregateScopeSchema = Schema.TaggedStruct('LOGICAL_AGGREGATE', { + physicalSiteKeys, +}); + +/** Site keys are descriptive owner evidence. They never become Stock Location identity. */ +export const StockLocationOperationalScopeSchema = Schema.Union([PhysicalSiteScopeSchema, LogicalAggregateScopeSchema]); + +export const ActiveLifecycleSchema = Schema.TaggedStruct('ACTIVE', {}); +const RetiredLifecycleSchema = Schema.TaggedStruct('RETIRED', { + reason, + transitionedAt: timestamp, +}); +export const ReplacedLifecycleSchema = Schema.TaggedStruct('REPLACED', { + reason, + successorRef: StockLocationRefSchema, + transitionedAt: timestamp, +}); +export const MergedLifecycleSchema = Schema.TaggedStruct('MERGED', { + reason, + successorRef: StockLocationRefSchema, + transitionedAt: timestamp, +}); + +export const StockLocationLifecycleSchema = Schema.Union([ + ActiveLifecycleSchema, + RetiredLifecycleSchema, + ReplacedLifecycleSchema, + MergedLifecycleSchema, +]); +export type StockLocationLifecycle = typeof StockLocationLifecycleSchema.Type; + +export const StockLocationSchema = Schema.Struct({ + addressEvidence: Schema.optionalKey(StockLocationAddressEvidenceSchema), + displayName: boundedText, + lifecycle: StockLocationLifecycleSchema, + operationalScope: StockLocationOperationalScopeSchema, + ref: StockLocationRefSchema, + revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)), +}).check( + Schema.makeFilter(({ lifecycle, ref }) => { + if (!('successorRef' in lifecycle)) { + return true; + } + if (lifecycle.successorRef.tenantId !== ref.tenantId) { + return 'A Stock Location successor must belong to the same Tenant'; + } + if (lifecycle.successorRef.resourceId === ref.resourceId) { + return 'A Stock Location cannot replace or merge into itself'; + } + return true; + }), +); +export type StockLocation = typeof StockLocationSchema.Type; + +export const StockLocationTransitionSchema = Schema.Union([ + Schema.TaggedStruct('RETIRE', { reason, transitionedAt: timestamp }), + Schema.TaggedStruct('REPLACE', { + reason, + successorRef: StockLocationRefSchema, + transitionedAt: timestamp, + }), + Schema.TaggedStruct('MERGE', { + reason, + successorRef: StockLocationRefSchema, + transitionedAt: timestamp, + }), +]); +export type StockLocationTransition = typeof StockLocationTransitionSchema.Type; + +export class StockLocationTransitionRejected extends Schema.TaggedError()( + 'StockLocationTransitionRejected', + { + locationRef: StockLocationRefSchema, + reason: Schema.Literals(['CROSS_TENANT_SUCCESSOR', 'INVALID_TRANSITION', 'SELF_SUCCESSOR', 'TERMINAL_LIFECYCLE']), + }, +) {} + +/** + * End one Current location without rotating or erasing its Resource identity. A replacement or + * merge records a forward relation; historical stock facts continue to carry the original ref. + */ +export const transitionStockLocation = ( + current: StockLocation, + transition: StockLocationTransition, +): Effect.Effect => { + if (!Schema.is(ActiveLifecycleSchema)(current.lifecycle)) { + return Effect.fail(new StockLocationTransitionRejected({ locationRef: current.ref, reason: 'TERMINAL_LIFECYCLE' })); + } + if ('successorRef' in transition) { + if (transition.successorRef.tenantId !== current.ref.tenantId) { + return Effect.fail( + new StockLocationTransitionRejected({ locationRef: current.ref, reason: 'CROSS_TENANT_SUCCESSOR' }), + ); + } + if (transition.successorRef.resourceId === current.ref.resourceId) { + return Effect.fail(new StockLocationTransitionRejected({ locationRef: current.ref, reason: 'SELF_SUCCESSOR' })); + } + } + + const lifecycle: StockLocationLifecycle = Match.value(transition).pipe( + Match.tag('RETIRE', ({ reason: transitionReason, transitionedAt }) => ({ + _tag: 'RETIRED' as const, + reason: transitionReason, + transitionedAt, + })), + Match.tag('REPLACE', ({ reason: transitionReason, successorRef, transitionedAt }) => ({ + _tag: 'REPLACED' as const, + reason: transitionReason, + successorRef, + transitionedAt, + })), + Match.tag('MERGE', ({ reason: transitionReason, successorRef, transitionedAt }) => ({ + _tag: 'MERGED' as const, + reason: transitionReason, + successorRef, + transitionedAt, + })), + Match.exhaustive, + ); + + return Schema.decodeEffect(StockLocationSchema)({ + ...current, + lifecycle, + revision: current.revision + 1, + }).pipe( + Effect.mapError((cause) => { + const failure = new StockLocationTransitionRejected({ + locationRef: current.ref, + reason: 'INVALID_TRANSITION', + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; + }), + ); +}; + +export const ExternalStockLocationKeySchema = Schema.Struct({ + externalValue: boundedText, + identifierKind: boundedText, + issuerId: ExternalStockLocationIssuerIdSchema, + issuerKind: Schema.Literals(['EXTERNAL_BUSINESS_SYSTEM', 'ONTOS_WMS']), + namespace: boundedText, + tenantId: StockLocationRefSchema.fields.tenantId, +}); +export type ExternalStockLocationKey = typeof ExternalStockLocationKeySchema.Type; + +export const StockLocationCorrelationSchema = Schema.Struct({ + correlationId: ExternalStockLocationCorrelationIdSchema, + locationRef: StockLocationRefSchema, + source: ExternalStockLocationKeySchema, +}).check( + Schema.makeFilter( + ({ locationRef, source }) => + locationRef.tenantId === source.tenantId || 'A correlation target must belong to the source Tenant', + ), +); +export type StockLocationCorrelation = typeof StockLocationCorrelationSchema.Type; + +export const sameExternalStockLocationKey = ( + left: ExternalStockLocationKey, + right: ExternalStockLocationKey, +): boolean => + left.tenantId === right.tenantId && + left.issuerKind === right.issuerKind && + left.issuerId === right.issuerId && + left.namespace === right.namespace && + left.identifierKind === right.identifierKind && + left.externalValue === right.externalValue; diff --git a/app/verticals/inventory/shared/domain/stock-position.ts b/app/verticals/inventory/shared/domain/stock-position.ts new file mode 100644 index 000000000..7b6a68e90 --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-position.ts @@ -0,0 +1,419 @@ +import { ProductUnitRefSchema } from '@app/catalog/resources/product-unit'; +import { Effect, Match, Schema } from 'effect'; +import type { Result } from 'effect'; + +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { StockItemRefSchema } from '../resources/stock-item.ts'; +import { StockLocationRefSchema } from '../resources/stock-location.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import type { StockPositionRef } from '../resources/stock-position.ts'; + +const boundedIdentifier = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const stockPositionInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const STOCK_QUANTITY_PRECISION = 38; +const STOCK_QUANTITY_SCALE = 9; +const STOCK_QUANTITY_INTEGER_DIGITS = STOCK_QUANTITY_PRECISION - STOCK_QUANTITY_SCALE; +const canonicalDecimalPattern = /^(?:0|[1-9][0-9]*)(?:\.[0-9]*[1-9])?$/u; + +export const ExactStockQuantityAmountSchema = Schema.String.check( + Schema.makeFilter((value) => { + if (!canonicalDecimalPattern.test(value)) { + return 'Stock Quantity must be a canonical non-negative decimal without exponent, sign, leading zero, or trailing fractional zero'; + } + const [integer = '', fraction = ''] = value.split('.'); + return integer.length <= STOCK_QUANTITY_INTEGER_DIGITS && fraction.length <= STOCK_QUANTITY_SCALE + ? undefined + : `Stock Quantity must fit numeric(${STOCK_QUANTITY_PRECISION}, ${STOCK_QUANTITY_SCALE})`; + }), +).pipe(Schema.brand('ExactStockQuantityAmount')); +export type ExactStockQuantityAmount = typeof ExactStockQuantityAmountSchema.Type; + +export const StockQuantitySchema = Schema.Struct({ + amount: ExactStockQuantityAmountSchema, + unitRef: ProductUnitRefSchema, +}); +export type StockQuantity = typeof StockQuantitySchema.Type; + +export const CurrentOnHandEvidenceSchema = Schema.TaggedStruct('CURRENT', { + evidenceRef: boundedIdentifier, + meaning: Schema.Literal('ON_HAND'), + observedAt: stockPositionInstant, + ownerConfigurationRef: InventoryBackendConfigurationRefSchema, + quantity: StockQuantitySchema, +}); + +const unavailableOnHand = (tag: Tag) => + Schema.TaggedStruct(tag, { + meaning: Schema.Literal('ON_HAND'), + ownerConfigurationRef: InventoryBackendConfigurationRefSchema, + unitRef: ProductUnitRefSchema, + }); + +export const StaleOnHandEvidenceSchema = Schema.TaggedStruct('STALE', { + evidenceRef: boundedIdentifier, + lastKnownQuantity: StockQuantitySchema, + lastObservedAt: stockPositionInstant, + meaning: Schema.Literal('ON_HAND'), + ownerConfigurationRef: InventoryBackendConfigurationRefSchema, +}); + +export const UnknownOnHandEvidenceSchema = unavailableOnHand('UNKNOWN'); +export const MissingOnHandEvidenceSchema = unavailableOnHand('MISSING'); +export const IndeterminateOnHandEvidenceSchema = unavailableOnHand('INDETERMINATE'); + +export const StockPositionOnHandEvidenceSchema = Schema.Union([ + CurrentOnHandEvidenceSchema, + UnknownOnHandEvidenceSchema, + MissingOnHandEvidenceSchema, + StaleOnHandEvidenceSchema, + IndeterminateOnHandEvidenceSchema, +]); +export type StockPositionOnHandEvidence = typeof StockPositionOnHandEvidenceSchema.Type; + +export const StockPositionScopeSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + stockItemRef: StockItemRefSchema, + stockLocationRef: StockLocationRefSchema, + unitRef: ProductUnitRefSchema, +}).check( + Schema.makeFilter(({ stockItemRef, stockLocationRef, unitRef }) => + stockItemRef.tenantId === stockLocationRef.tenantId && stockItemRef.tenantId === unitRef.tenantId + ? undefined + : 'Stock Position scope references must share one Tenant', + ), +); +export type StockPositionScope = typeof StockPositionScopeSchema.Type; + +export const StockPositionRevisionSchema = Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })); + +const sameUnitRef = (left: StockQuantity['unitRef'], right: StockQuantity['unitRef']): boolean => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const evidenceUnitRef = (evidence: StockPositionOnHandEvidence): StockQuantity['unitRef'] => + Match.value(evidence).pipe( + Match.tag('CURRENT', ({ quantity }) => quantity.unitRef), + Match.tag('STALE', ({ lastKnownQuantity }) => lastKnownQuantity.unitRef), + Match.tag('UNKNOWN', ({ unitRef }) => unitRef), + Match.tag('MISSING', ({ unitRef }) => unitRef), + Match.tag('INDETERMINATE', ({ unitRef }) => unitRef), + Match.exhaustive, + ); + +const evidenceOwnerConfigurationRef = (evidence: StockPositionOnHandEvidence) => evidence.ownerConfigurationRef; + +export const StockPositionSchema = Schema.Struct({ + createdAt: stockPositionInstant, + endedAt: Schema.toEncoded(Schema.OptionFromNullOr(stockPositionInstant)), + lifecycle: Schema.Literals(['CURRENT', 'HISTORICAL']), + onHand: StockPositionOnHandEvidenceSchema, + ref: StockPositionRefSchema, + revision: StockPositionRevisionSchema, + scope: StockPositionScopeSchema, +}).check( + Schema.makeFilter((position) => { + const { ref, scope } = position; + if ( + ref.tenantId !== scope.stockItemRef.tenantId || + ref.tenantId !== scope.stockLocationRef.tenantId || + ref.tenantId !== scope.unitRef.tenantId + ) { + return 'Stock Position and all constrained scope references must share one Tenant'; + } + if (!sameUnitRef(evidenceUnitRef(position.onHand), scope.unitRef)) { + return 'ON_HAND must use the exact Stock Item Product Unit reference'; + } + if (evidenceOwnerConfigurationRef(position.onHand).tenantId !== ref.tenantId) { + return 'ON_HAND owner configuration and Stock Position must share one Tenant'; + } + if (position.lifecycle === 'HISTORICAL' && Schema.is(CurrentOnHandEvidenceSchema)(position.onHand)) { + return 'A historical Stock Position cannot expose Current ON_HAND evidence'; + } + return (position.lifecycle === 'CURRENT' && position.endedAt === null) || + (position.lifecycle === 'HISTORICAL' && position.endedAt !== null) + ? undefined + : 'Stock Position end timestamp must match its lifecycle'; + }), +); +export type StockPosition = typeof StockPositionSchema.Type; + +export const CreateStockPositionInputSchema = Schema.Struct({ + onHand: StockPositionOnHandEvidenceSchema, + scope: StockPositionScopeSchema, +}).check( + Schema.makeFilter(({ onHand, scope }) => + sameUnitRef(evidenceUnitRef(onHand), scope.unitRef) + ? undefined + : 'Initial ON_HAND must use the exact Stock Item Product Unit reference', + ), +); +export type CreateStockPositionInput = typeof CreateStockPositionInputSchema.Type; + +export const CurrentSuccessfulAllocationQuantitySchema = Schema.Struct({ + allocationId: boundedIdentifier.pipe(Schema.brand('InventoryStockAllocationId')), + positionRef: StockPositionRefSchema, + quantity: StockQuantitySchema, + status: Schema.Literal('CURRENT_SUCCESSFUL'), +}); +export type CurrentSuccessfulAllocationQuantity = typeof CurrentSuccessfulAllocationQuantitySchema.Type; + +export const DerivedReservedQuantitySchema = Schema.Struct({ + allocationCount: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), + currentness: Schema.Literal('CURRENT'), + derivation: Schema.Literal('CURRENT_SUCCESSFUL_RESERVATION_ALLOCATIONS'), + meaning: Schema.Literal('RESERVED'), + owner: Schema.Literal('INVENTORY'), + quantity: StockQuantitySchema, +}); + +export const HistoricalReservedQuantitySchema = Schema.Struct({ + currentness: Schema.Literal('HISTORICAL'), + derivation: Schema.Literal('CURRENT_SUCCESSFUL_RESERVATION_ALLOCATIONS'), + meaning: Schema.Literal('RESERVED'), + owner: Schema.Literal('INVENTORY'), + reason: Schema.Literal('POSITION_NOT_CURRENT'), +}); + +export const StockPositionReservedEvidenceSchema = Schema.Union([ + DerivedReservedQuantitySchema, + HistoricalReservedQuantitySchema, +]); +export type StockPositionReservedEvidence = typeof StockPositionReservedEvidenceSchema.Type; + +export class StockPositionRejected extends Schema.TaggedError()('StockPositionRejected', { + code: Schema.Literal('stock_position_rejected'), + positionRef: Schema.optionalKey(StockPositionRefSchema), + reason: Schema.Literals([ + 'POSITION_NOT_CURRENT', + 'POSITION_NOT_FOUND', + 'POSITION_SCOPE_ALREADY_CURRENT', + 'POSITION_IDENTITY_CONFLICT', + 'POSITION_REVISION_CONFLICT', + 'TENANT_SCOPE_MISMATCH', + 'ALLOCATION_POSITION_MISMATCH', + 'OWNER_CONFIGURATION_MISMATCH', + 'STOCK_ITEM_NOT_FOUND', + 'STOCK_LOCATION_NOT_FOUND', + 'STOCK_UNIT_MISMATCH', + 'INVALID_POSITION', + ]), +}) {} + +interface DecimalParts { + readonly coefficient: bigint; + readonly scale: number; +} + +const decimalParts = (amount: ExactStockQuantityAmount): DecimalParts => { + const [integer = '0', fraction = ''] = amount.split('.'); + return { coefficient: BigInt(`${integer}${fraction}`), scale: fraction.length }; +}; + +const alignedCoefficients = (left: ExactStockQuantityAmount, right: ExactStockQuantityAmount) => { + const leftParts = decimalParts(left); + const rightParts = decimalParts(right); + const scale = Math.max(leftParts.scale, rightParts.scale); + return { + left: leftParts.coefficient * 10n ** BigInt(scale - leftParts.scale), + right: rightParts.coefficient * 10n ** BigInt(scale - rightParts.scale), + scale, + }; +}; + +const formatDecimal = (coefficient: bigint, scale: number): string => { + if (scale === 0) { + return coefficient.toString(); + } + const padded = coefficient.toString().padStart(scale + 1, '0'); + const integer = padded.slice(0, -scale); + const fraction = padded.slice(-scale).replace(/0+$/u, ''); + return fraction.length === 0 ? integer : `${integer}.${fraction}`; +}; + +export const addExactStockQuantityAmounts = ( + left: ExactStockQuantityAmount, + right: ExactStockQuantityAmount, +): Result.Result => { + const aligned = alignedCoefficients(left, right); + return Schema.decodeResult(ExactStockQuantityAmountSchema)( + formatDecimal(aligned.left + aligned.right, aligned.scale), + ); +}; + +export const compareExactStockQuantityAmounts = ( + left: ExactStockQuantityAmount, + right: ExactStockQuantityAmount, +): -1 | 0 | 1 => { + const aligned = alignedCoefficients(left, right); + if (aligned.left < aligned.right) { + return -1; + } + return aligned.left > aligned.right ? 1 : 0; +}; + +export const subtractExactStockQuantityAmounts = ( + left: ExactStockQuantityAmount, + right: ExactStockQuantityAmount, +): Result.Result => { + const aligned = alignedCoefficients(left, right); + return Schema.decodeResult(ExactStockQuantityAmountSchema)( + formatDecimal(aligned.left - aligned.right, aligned.scale), + ); +}; + +const samePositionRef = (left: StockPositionRef, right: StockPositionRef): boolean => + left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +const invalidFromCause = (positionRef: StockPositionRef, cause: unknown) => { + const failure = new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef, + reason: 'INVALID_POSITION', + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +/** RESERVED is a read-time derivation. There is intentionally no writable RESERVED state. */ +export const deriveReservedQuantity = Effect.fn('deriveReservedQuantity')(function* deriveCurrentReservedQuantity( + position: StockPosition, + allocations: readonly CurrentSuccessfulAllocationQuantity[], +) { + if (position.lifecycle === 'HISTORICAL') { + return { + currentness: 'HISTORICAL' as const, + derivation: 'CURRENT_SUCCESSFUL_RESERVATION_ALLOCATIONS' as const, + meaning: 'RESERVED' as const, + owner: 'INVENTORY' as const, + reason: 'POSITION_NOT_CURRENT' as const, + }; + } + const zero = yield* Schema.decodeEffect(ExactStockQuantityAmountSchema)('0').pipe( + Effect.mapError((cause) => invalidFromCause(position.ref, cause)), + ); + const amount = yield* Effect.reduce( + allocations, + () => zero, + (subtotal, allocation) => { + if (!samePositionRef(position.ref, allocation.positionRef)) { + return Effect.fail( + new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'ALLOCATION_POSITION_MISMATCH', + }), + ); + } + if (!sameUnitRef(position.scope.unitRef, allocation.quantity.unitRef)) { + return Effect.fail( + new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'STOCK_UNIT_MISMATCH', + }), + ); + } + return Effect.fromResult(addExactStockQuantityAmounts(subtotal, allocation.quantity.amount)).pipe( + Effect.mapError((cause) => invalidFromCause(position.ref, cause)), + ); + }, + ); + + return { + allocationCount: allocations.length, + currentness: 'CURRENT' as const, + derivation: 'CURRENT_SUCCESSFUL_RESERVATION_ALLOCATIONS' as const, + meaning: 'RESERVED' as const, + owner: 'INVENTORY' as const, + quantity: { amount, unitRef: position.scope.unitRef }, + }; +}); + +export const recordOnHandEvidence = ( + position: StockPosition, + onHand: StockPositionOnHandEvidence, +): Effect.Effect => { + if (position.lifecycle !== 'CURRENT') { + return Effect.fail( + new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'POSITION_NOT_CURRENT', + }), + ); + } + if (!sameUnitRef(evidenceUnitRef(onHand), position.scope.unitRef)) { + return Effect.fail( + new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'STOCK_UNIT_MISMATCH', + }), + ); + } + return Schema.decodeEffect(StockPositionSchema)({ + ...position, + onHand, + revision: position.revision + 1, + }).pipe( + Effect.mapError((cause) => { + const failure = new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'INVALID_POSITION', + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; + }), + ); +}; + +export const endStockPosition = ( + position: StockPosition, + endedAt: string, +): Effect.Effect => { + if (position.lifecycle !== 'CURRENT') { + return Effect.fail( + new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'POSITION_NOT_CURRENT', + }), + ); + } + const onHand = Match.value(position.onHand).pipe( + Match.tag('CURRENT', (current) => ({ + _tag: 'STALE' as const, + evidenceRef: current.evidenceRef, + lastKnownQuantity: current.quantity, + lastObservedAt: current.observedAt, + meaning: current.meaning, + ownerConfigurationRef: current.ownerConfigurationRef, + })), + Match.tag('STALE', (stale) => stale), + Match.tag('UNKNOWN', (unknown) => unknown), + Match.tag('MISSING', (missing) => missing), + Match.tag('INDETERMINATE', (indeterminate) => indeterminate), + Match.exhaustive, + ); + return Schema.decodeEffect(StockPositionSchema)({ + ...position, + endedAt, + lifecycle: 'HISTORICAL', + onHand, + revision: position.revision + 1, + }).pipe( + Effect.mapError((cause) => { + const failure = new StockPositionRejected({ + code: 'stock_position_rejected', + positionRef: position.ref, + reason: 'INVALID_POSITION', + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; + }), + ); +}; diff --git a/app/verticals/inventory/shared/domain/stock-sharing-eligibility-unavailable.ts b/app/verticals/inventory/shared/domain/stock-sharing-eligibility-unavailable.ts new file mode 100644 index 000000000..8a812a246 --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-sharing-eligibility-unavailable.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class StockSharingEligibilityUnavailable extends Schema.TaggedError()( + 'StockSharingEligibilityUnavailable', + { + code: Schema.Literal('stock_sharing_eligibility_unavailable'), + reason: Schema.Literal('Stock Sharing Eligibility persistence or owner validation is temporarily unavailable'), + }, +) {} diff --git a/app/verticals/inventory/shared/domain/stock-sharing-eligibility.ts b/app/verticals/inventory/shared/domain/stock-sharing-eligibility.ts new file mode 100644 index 000000000..4d4da57cf --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-sharing-eligibility.ts @@ -0,0 +1,274 @@ +import type { Effect as EffectType, Option } from 'effect'; +import { Schema } from 'effect'; + +import { CustomerConfigurationIdSchema } from '../inventory-launch-scope.ts'; +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { StockPositionRefSchema } from '../resources/stock-position.ts'; +import { StockSharingEligibilityRefSchema } from '../resources/stock-sharing-eligibility.ts'; +import type { StockSharingEligibilityUnavailable } from './stock-sharing-eligibility-unavailable.ts'; + +const boundedText = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); +const tenantIdSchema = StockSharingEligibilityRefSchema.fields.tenantId; +const SellingLegalEntityResourceIdSchema = Schema.String.check(Schema.isUUID()).pipe( + Schema.brand('InventorySellingLegalEntityResourceId'), +); +const CommerceMarketResourceIdSchema = boundedText.pipe(Schema.brand('InventoryCommerceMarketResourceId')); +const InventoryStorefrontAppIdSchema = Schema.String.check( + Schema.isMinLength(1), + Schema.isMaxLength(100), + Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u), +).pipe(Schema.brand('InventoryStorefrontAppId')); +export const StockSharingEligibilityInstantSchema = Schema.toEncoded(Schema.DateTimeUtcFromString); + +export const InventoryChannelSchema = Schema.Literals(['B2C', 'B2B']); + +export const InventorySellingLegalEntityRefSchema = Schema.Struct({ + moduleId: Schema.Literal('core.identity'), + resourceId: SellingLegalEntityResourceIdSchema, + resourceType: Schema.Literal('core.identity.legal-entity'), + tenantId: tenantIdSchema, +}); + +export const InventoryCommerceMarketRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.market-catalog'), + resourceId: CommerceMarketResourceIdSchema, + resourceType: Schema.Literal('commerce.market-catalog.market'), + tenantId: tenantIdSchema, +}); + +export const InventoryStorefrontRefSchema = Schema.Struct({ + appId: InventoryStorefrontAppIdSchema, + tenantId: tenantIdSchema, +}); + +/** + * The relation subject is deliberately limited to the confirmed four dimensions. Purchasing + * Subject, Principal, Permission, Assortment, Price Group, Cart, and operation time never enter it. + */ +export const StockSharingEligibilitySubjectSchema = Schema.Struct({ + channel: InventoryChannelSchema, + commerceMarketRef: Schema.optionalKey(InventoryCommerceMarketRefSchema), + sellingLegalEntityRef: InventorySellingLegalEntityRefSchema, + storefrontRef: Schema.optionalKey(InventoryStorefrontRefSchema), +}).check( + Schema.makeFilter(({ commerceMarketRef, sellingLegalEntityRef, storefrontRef }) => { + const { tenantId } = sellingLegalEntityRef; + return (commerceMarketRef === undefined || commerceMarketRef.tenantId === tenantId) && + (storefrontRef === undefined || storefrontRef.tenantId === tenantId) + ? undefined + : 'Stock Sharing Eligibility subject references must share one Tenant'; + }), +); +export type StockSharingEligibilitySubject = typeof StockSharingEligibilitySubjectSchema.Type; + +export const StockSharingEligibilityScopeSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + ownerConfigurationRef: InventoryBackendConfigurationRefSchema, + positionRef: StockPositionRefSchema, +}).check( + Schema.makeFilter(({ ownerConfigurationRef, positionRef }) => + ownerConfigurationRef.tenantId === positionRef.tenantId + ? undefined + : 'Stock Position and selected Inventory Backend configuration must share one Tenant', + ), +); +export type StockSharingEligibilityScope = typeof StockSharingEligibilityScopeSchema.Type; + +export const StockSharingCommerceValidationSchema = Schema.Struct({ + evidenceRef: boundedText, + observedAt: StockSharingEligibilityInstantSchema, + verification: Schema.Literal('OWNER_VERIFIED_CURRENT'), +}); +export type StockSharingCommerceValidation = typeof StockSharingCommerceValidationSchema.Type; + +export const StockSharingEligibilityEffectivePeriodSchema = Schema.Struct({ + from: StockSharingEligibilityInstantSchema, + to: Schema.toEncoded(Schema.OptionFromNullOr(StockSharingEligibilityInstantSchema)), +}).check( + Schema.makeFilter(({ from, to }) => + to === null || from < to ? undefined : 'Stock Sharing Eligibility Effective Period must be non-empty', + ), +); + +export const StockSharingEligibilitySchema = Schema.Struct({ + commerceValidation: StockSharingCommerceValidationSchema, + effectivePeriod: StockSharingEligibilityEffectivePeriodSchema, + lifecycle: Schema.Literals(['CURRENT', 'ENDED']), + ref: StockSharingEligibilityRefSchema, + revision: Schema.Int.check(Schema.isBetween({ maximum: 2_147_483_647, minimum: 1 })), + scope: StockSharingEligibilityScopeSchema, + subject: StockSharingEligibilitySubjectSchema, +}).check( + Schema.makeFilter((relation) => { + const { tenantId } = relation.ref; + if ( + relation.scope.positionRef.tenantId !== tenantId || + relation.scope.ownerConfigurationRef.tenantId !== tenantId || + relation.subject.sellingLegalEntityRef.tenantId !== tenantId + ) { + return 'Stock Sharing Eligibility identity, scope, and subject must share one Tenant'; + } + return (relation.lifecycle === 'CURRENT' && relation.effectivePeriod.to === null) || + (relation.lifecycle === 'ENDED' && relation.effectivePeriod.to !== null) + ? undefined + : 'Stock Sharing Eligibility lifecycle must match its Effective Period'; + }), +); +export type StockSharingEligibility = typeof StockSharingEligibilitySchema.Type; + +export const TrustedCurrentCommercePurchasingContextSchema = Schema.Struct({ + channel: InventoryChannelSchema, + commerceMarketRef: InventoryCommerceMarketRefSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + evidenceRef: boundedText, + observedAt: StockSharingEligibilityInstantSchema, + sellingLegalEntityRef: InventorySellingLegalEntityRefSchema, + status: Schema.Literal('CURRENT_OWNER_VERIFIED'), + storefrontRef: InventoryStorefrontRefSchema, + tenantId: tenantIdSchema, +}).check( + Schema.makeFilter(({ commerceMarketRef, sellingLegalEntityRef, storefrontRef, tenantId }) => + commerceMarketRef.tenantId === tenantId && + sellingLegalEntityRef.tenantId === tenantId && + storefrontRef.tenantId === tenantId + ? undefined + : 'Trusted Commerce Purchasing Context references must share one Tenant', + ), +); +export type TrustedCurrentCommercePurchasingContext = typeof TrustedCurrentCommercePurchasingContextSchema.Type; + +export const UnverifiableCommercePurchasingContextSchema = Schema.TaggedStruct('UNVERIFIABLE', { + customerConfigurationId: CustomerConfigurationIdSchema, + reason: Schema.Literals([ + 'OWNER_EVIDENCE_MISSING', + 'OWNER_EVIDENCE_STALE', + 'OWNER_EVIDENCE_UNAVAILABLE', + 'OWNER_EVIDENCE_INDETERMINATE', + ]), + tenantId: tenantIdSchema, +}); +export const StockSharingCommerceContextEvidenceSchema = Schema.Union([ + TrustedCurrentCommercePurchasingContextSchema, + UnverifiableCommercePurchasingContextSchema, +]); + +export class StockSharingEligibilityRejected extends Schema.TaggedError()( + 'StockSharingEligibilityRejected', + { + code: Schema.Literal('stock_sharing_eligibility_rejected'), + reason: Schema.Literals([ + 'INVALID_RELATION', + 'TENANT_SCOPE_MISMATCH', + 'POSITION_SCOPE_MISMATCH', + 'COMMERCE_SCOPE_NOT_CURRENT', + 'COMMERCE_CONTEXT_UNVERIFIABLE', + 'RELATION_IDENTITY_CONFLICT', + 'RELATION_NOT_FOUND', + 'RELATION_NOT_CURRENT', + 'REVISION_CONFLICT', + 'INVALID_LIFECYCLE_TIME', + 'NO_APPLICABLE_CURRENT_RELATION', + 'DUPLICATE_CURRENT_RELATION', + ]), + relationRef: Schema.optionalKey(StockSharingEligibilityRefSchema), + }, +) {} + +export type StockSharingEligibilityError = StockSharingEligibilityRejected | StockSharingEligibilityUnavailable; + +export interface StockSharingEligibilityPersistence { + readonly findByRef: ( + relationRef: StockSharingEligibility['ref'], + ) => EffectType.Effect, StockSharingEligibilityError>; + readonly insertCurrent: ( + relation: StockSharingEligibility, + ) => EffectType.Effect; + readonly listCurrent: ( + scope: StockSharingEligibilityScope, + ) => EffectType.Effect; + readonly readHistory: ( + relationRef: StockSharingEligibility['ref'], + ) => EffectType.Effect; + readonly saveRevision: (input: { + readonly current: StockSharingEligibility; + readonly next: StockSharingEligibility; + }) => EffectType.Effect; +} + +export interface StockSharingCommerceScopeValidator { + /** + * The Commerce owner contract must prove Current tenant/configuration scope, seller + Channel, + * Market ownership by that seller when restricted, and Current Storefront applicability when + * restricted. Missing, stale, unavailable, or indeterminate proof fails through the typed error. + */ + readonly validateCurrent: ( + scope: StockSharingEligibilityScope, + subject: StockSharingEligibilitySubject, + effectiveAt: string, + ) => EffectType.Effect; +} + +export const EstablishStockSharingEligibilityInputSchema = Schema.Struct({ + effectiveFrom: StockSharingEligibilityInstantSchema, + scope: StockSharingEligibilityScopeSchema, + subject: StockSharingEligibilitySubjectSchema, +}); +export type EstablishStockSharingEligibilityInput = typeof EstablishStockSharingEligibilityInputSchema.Type; + +export const ChangeStockSharingEligibilityInputSchema = Schema.Struct({ + changedAt: StockSharingEligibilityInstantSchema, + relationRef: StockSharingEligibilityRefSchema, + subject: StockSharingEligibilitySubjectSchema, +}); +export type ChangeStockSharingEligibilityInput = typeof ChangeStockSharingEligibilityInputSchema.Type; + +export const EndStockSharingEligibilityInputSchema = Schema.Struct({ + endedAt: StockSharingEligibilityInstantSchema, + relationRef: StockSharingEligibilityRefSchema, +}); +export type EndStockSharingEligibilityInput = typeof EndStockSharingEligibilityInputSchema.Type; + +export const EvaluateStockSharingEligibilityInputSchema = Schema.Struct({ + context: StockSharingCommerceContextEvidenceSchema, + scope: StockSharingEligibilityScopeSchema, +}); +export type EvaluateStockSharingEligibilityInput = typeof EvaluateStockSharingEligibilityInputSchema.Type; + +export const StockSharingEligibilityDecisionSchema = Schema.Struct({ + applicableRelationRefs: Schema.Array(StockSharingEligibilityRefSchema).check(Schema.isMinLength(1)), + contextEvidenceRef: boundedText, + outcome: Schema.Literal('ELIGIBLE'), + positionRef: StockPositionRefSchema, + rule: Schema.Literal('POSITIVE_CURRENT_RELATION_UNION'), +}); + +const sameResourceRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +/** Positive-union applicability: omitted optional dimensions are wildcards, never DENY rules. */ +export const commerceScopeMatchesRelation = ( + subject: StockSharingEligibilitySubject, + context: TrustedCurrentCommercePurchasingContext, +): boolean => + subject.channel === context.channel && + sameResourceRef(subject.sellingLegalEntityRef, context.sellingLegalEntityRef) && + (subject.commerceMarketRef === undefined || sameResourceRef(subject.commerceMarketRef, context.commerceMarketRef)) && + (subject.storefrontRef === undefined || + (subject.storefrontRef.appId === context.storefrontRef.appId && + subject.storefrontRef.tenantId === context.storefrontRef.tenantId)); diff --git a/app/verticals/inventory/shared/domain/stock-source-currentness.ts b/app/verticals/inventory/shared/domain/stock-source-currentness.ts new file mode 100644 index 000000000..cc94416b5 --- /dev/null +++ b/app/verticals/inventory/shared/domain/stock-source-currentness.ts @@ -0,0 +1,82 @@ +import { Schema } from 'effect'; + +import { InventoryBackendConfigurationRefSchema } from '../resources/inventory-backend-configuration.ts'; +import { InventorySourceAssertionEvaluationSchema } from './inventory-source-assertion.ts'; +import { StockPositionSchema } from './stock-position.ts'; + +const sourceInstant = Schema.toEncoded(Schema.DateTimeUtcFromString); +const sourceReference = Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)); + +export const SourceAssertionConditionSchema = Schema.TaggedStruct('SOURCE_ASSERTION', { + evaluation: InventorySourceAssertionEvaluationSchema, +}); +export const OmittedSourceConditionSchema = Schema.TaggedStruct('OMITTED', { + batchRef: sourceReference, + observedAt: sourceInstant, +}); +export const UnavailableSourceConditionSchema = Schema.TaggedStruct('UNAVAILABLE', { + observedAt: sourceInstant, + sourceReference, +}); +export const OwnerUnknownSourceConditionSchema = Schema.TaggedStruct('OWNER_UNKNOWN', { + observedAt: sourceInstant, + ownerEvidenceRef: sourceReference, +}); +export const MissingSourceConditionSchema = Schema.TaggedStruct('MISSING', { + observedAt: sourceInstant, + reason: Schema.Literals(['CORRELATION_NOT_FOUND', 'NO_USABLE_EVIDENCE']), +}); +export const ConflictingSourceConditionSchema = Schema.TaggedStruct('CONFLICTING', { + evidenceRefs: Schema.NonEmptyArray(sourceReference).check( + Schema.makeFilter((refs) => + refs.length >= 2 && new Set(refs).size === refs.length + ? undefined + : 'Conflicting source evidence requires at least two distinct evidence references', + ), + ), + observedAt: sourceInstant, +}); + +/** Source transport/assessment conditions stay separate from Stock Position quantity evidence. */ +export const StockSourceConditionSchema = Schema.Union([ + SourceAssertionConditionSchema, + OmittedSourceConditionSchema, + UnavailableSourceConditionSchema, + OwnerUnknownSourceConditionSchema, + MissingSourceConditionSchema, + ConflictingSourceConditionSchema, +]); +export type StockSourceCondition = typeof StockSourceConditionSchema.Type; + +export const StockSourceCurrentnessInputSchema = Schema.Struct({ + evaluatedAt: sourceInstant, + ownerConfigurationRef: InventoryBackendConfigurationRefSchema, + ownerCurrentThrough: sourceInstant, + position: StockPositionSchema, + sourceCondition: StockSourceConditionSchema, +}); +export type StockSourceCurrentnessInput = typeof StockSourceCurrentnessInputSchema.Type; + +export const StockSourceCurrentnessResultSchema = Schema.Struct({ + establishesCurrentStockGuarantee: Schema.Boolean, + hasCurrentStockGuarantee: Schema.Boolean, + position: StockPositionSchema, + reconciliationRequired: Schema.Boolean, + sourceCondition: StockSourceConditionSchema, +}); +export type StockSourceCurrentnessResult = typeof StockSourceCurrentnessResultSchema.Type; + +export class StockSourceCurrentnessRejected extends Schema.TaggedError()( + 'StockSourceCurrentnessRejected', + { + code: Schema.Literal('stock_source_currentness_rejected'), + reason: Schema.Literals([ + 'ASSERTION_POSITION_MISMATCH', + 'ASSERTION_QUANTITY_MISMATCH', + 'AUTHORITY_SCOPE_MISMATCH', + 'INVALID_INPUT', + 'INVALID_POSITION_TRANSITION', + 'POSITION_NOT_CURRENT', + ]), + }, +) {} diff --git a/app/verticals/inventory/shared/inventory-launch-scope.ts b/app/verticals/inventory/shared/inventory-launch-scope.ts new file mode 100644 index 000000000..b63c55618 --- /dev/null +++ b/app/verticals/inventory/shared/inventory-launch-scope.ts @@ -0,0 +1,148 @@ +import { Effect, Schema } from 'effect'; + +const BoundedIdentifierSchema = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(300)); +export const CustomerConfigurationIdSchema = BoundedIdentifierSchema.pipe(Schema.brand('CustomerConfigurationId')); +const CatalogSelectionIdSchema = BoundedIdentifierSchema.pipe(Schema.brand('CatalogSelectionId')); +const PurchaseDemandOccurrenceIdSchema = BoundedIdentifierSchema.pipe(Schema.brand('PurchaseDemandOccurrenceId')); +const StockItemIdSchema = BoundedIdentifierSchema.pipe(Schema.brand('StockItemId')); +export const OrderCommitmentAttemptIdSchema = BoundedIdentifierSchema.pipe(Schema.brand('OrderCommitmentAttemptId')); + +export const InventoryBackendSchema = Schema.Literals(['external_business_system', 'ontos_wms']); +export type InventoryBackend = typeof InventoryBackendSchema.Type; + +export const InventoryBackendConfigurationInputSchema = Schema.Struct({ + customerConfigurationId: CustomerConfigurationIdSchema, + selectedBackends: Schema.Array(InventoryBackendSchema), +}); +export type InventoryBackendConfigurationInput = typeof InventoryBackendConfigurationInputSchema.Type; + +export const ValidatedInventoryBackendConfigurationSchema = Schema.Struct({ + backend: InventoryBackendSchema, + customerConfigurationId: CustomerConfigurationIdSchema, +}); +export type ValidatedInventoryBackendConfiguration = typeof ValidatedInventoryBackendConfigurationSchema.Type; + +const LaunchQuantitySchema = Schema.String.check( + Schema.isPattern(/^(?:0|[1-9]\d*)(?:\.\d+)?$/u), + Schema.isMaxLength(80), +); +const LaunchUnitSchema = BoundedIdentifierSchema.pipe(Schema.brand('InventoryLaunchUnit')); + +const UsableStockItemBindingSchema = Schema.Struct({ + status: Schema.Literal('usable'), + stockItemId: StockItemIdSchema, +}); +const UnusableStockItemBindingSchema = Schema.Struct({ + reason: Schema.Literals(['incompatible_meaning', 'not_current']), + status: Schema.Literal('unusable'), +}); +// oxlint-disable-next-line effect-native/no-nullable-schema-field -- null is the established launch-cutline wire sentinel for a missing binding; expires: 2027-03-31. +export const InventoryStockItemBindingSchema = Schema.NullOr( + Schema.Union([UsableStockItemBindingSchema, UnusableStockItemBindingSchema]), +); + +export const InventoryStockDemandInputSchema = Schema.Struct({ + binding: InventoryStockItemBindingSchema, + catalogSelectionId: CatalogSelectionIdSchema, + purchaseDemandOccurrenceId: PurchaseDemandOccurrenceIdSchema, + quantity: LaunchQuantitySchema, + unit: LaunchUnitSchema, +}); +export type InventoryStockDemandInput = typeof InventoryStockDemandInputSchema.Type; + +export const InventoryStockRequirementSchema = Schema.Struct({ + catalogSelectionId: CatalogSelectionIdSchema, + purchaseDemandOccurrenceId: PurchaseDemandOccurrenceIdSchema, + quantity: LaunchQuantitySchema, + stockItemId: StockItemIdSchema, + unit: LaunchUnitSchema, +}); +export type InventoryStockRequirement = typeof InventoryStockRequirementSchema.Type; + +export const InventoryPurchaseKindSchema = Schema.Literals(['b2c', 'b2b']); +export type InventoryPurchaseKind = typeof InventoryPurchaseKindSchema.Type; + +export const InventoryCommitmentInputSchema = Schema.Struct({ + attemptId: OrderCommitmentAttemptIdSchema, + purchaseKind: InventoryPurchaseKindSchema, +}); +export type InventoryCommitmentInput = typeof InventoryCommitmentInputSchema.Type; + +export class InventoryLaunchCutlineRejected extends Schema.TaggedError()( + 'InventoryLaunchCutlineRejected', + { + attemptId: Schema.optionalKey(OrderCommitmentAttemptIdSchema), + catalogSelectionId: Schema.optionalKey(CatalogSelectionIdSchema), + code: Schema.Literal('inventory_launch_cutline_rejected'), + customerConfigurationId: Schema.optionalKey(CustomerConfigurationIdSchema), + purchaseKind: Schema.optionalKey(InventoryPurchaseKindSchema), + reason: Schema.Literals([ + 'exactly_one_backend_required', + 'usable_stock_item_binding_required', + 'owner_enforceable_reservation_protection_required', + ]), + selectedBackends: Schema.optionalKey(Schema.Array(InventoryBackendSchema)), + }, +) {} + +export const validateLaunchInventoryBackend = ( + input: InventoryBackendConfigurationInput, +): Effect.Effect => { + const [backend] = input.selectedBackends; + if (input.selectedBackends.length !== 1 || backend === undefined) { + return Effect.fail( + new InventoryLaunchCutlineRejected({ + code: 'inventory_launch_cutline_rejected', + customerConfigurationId: input.customerConfigurationId, + reason: 'exactly_one_backend_required', + selectedBackends: [...input.selectedBackends], + }), + ); + } + + return Effect.succeed({ + backend, + customerConfigurationId: input.customerConfigurationId, + }); +}; + +export const resolveLaunchStockRequirement = ( + input: InventoryStockDemandInput, +): Effect.Effect => { + if (input.binding === null || input.binding.status !== 'usable') { + return Effect.fail( + new InventoryLaunchCutlineRejected({ + catalogSelectionId: input.catalogSelectionId, + code: 'inventory_launch_cutline_rejected', + reason: 'usable_stock_item_binding_required', + }), + ); + } + + return Effect.succeed({ + catalogSelectionId: input.catalogSelectionId, + purchaseDemandOccurrenceId: input.purchaseDemandOccurrenceId, + quantity: input.quantity, + stockItemId: input.binding.stockItemId, + unit: input.unit, + }); +}; + +export const requireLaunchCommitmentProtection = ( + input: InventoryCommitmentInput, +): Effect.Effect => + Effect.fail( + new InventoryLaunchCutlineRejected({ + attemptId: input.attemptId, + code: 'inventory_launch_cutline_rejected', + purchaseKind: input.purchaseKind, + reason: 'owner_enforceable_reservation_protection_required', + }), + ); + +export const inventoryLaunchCapabilityKeys = [ + 'single_customer_configuration_backend', + 'exact_selection_stock_item_binding', + 'quantity_and_unit_preservation', + 'owner_enforceable_reservation_protection', +] as const; diff --git a/app/verticals/inventory/shared/inventory-privacy-owner-contract.ts b/app/verticals/inventory/shared/inventory-privacy-owner-contract.ts new file mode 100644 index 000000000..ff10d3cd5 --- /dev/null +++ b/app/verticals/inventory/shared/inventory-privacy-owner-contract.ts @@ -0,0 +1,469 @@ +import type { + AntiResurrectionProtectionEncoded, + PrivacyMeasureEncoded, + PrivacyOwnerCoveragePartEncoded, + PrivacyOwnerCoverageResultEncoded, + PrivacyOwnerExecutionOutcomeEncoded, + PrivacyOwnerReconciliationResultEncoded, +} from '@app/shared-contracts'; +import { Function as EffectFunction, Match } from 'effect'; + +/** + * Inventory-owned privacy scope that must be accounted for before Inventory can truthfully report + * complete NO_DATA. These are responsibilities, not assertions that every scope contains personal data. + */ +export const inventoryPrivacyOwnerScopeParts = [ + 'ACTOR_PRINCIPAL_ATTRIBUTION', + 'CURRENT_RESERVATION_CORRELATIONS', + 'BACKEND_AUTHORITY_AND_CUTOVER_HISTORY', + 'DEMAND_SELECTION_BINDING_AND_REQUIREMENTS_HISTORY', + 'RESERVATION_ATTEMPT_ORDER_AND_ALLOCATION_HISTORY', + 'CONFIRMATION_SHORTAGE_PRIORITY_AND_RELEASE_HISTORY', + 'COMMITMENT_PROTECTION_HISTORY', + 'COMMITTED_OBLIGATION_HISTORY', + 'EFFECT_AND_RECONCILIATION_EVIDENCE', + 'PHYSICAL_STOCK_EFFECT_AND_STOCK_CORRECTION_EVIDENCE', + 'EXTERNAL_SOURCE_ASSERTION_COVERAGE_AND_CORRELATION_HISTORY', + 'EXTERNAL_COPY_RESPONSIBILITIES', + 'IMPORT_REPLAY_PROJECTION_AND_BACKUP_RESPONSIBILITIES', +] as const; + +export type InventoryPrivacyOwnerScopePart = (typeof inventoryPrivacyOwnerScopeParts)[number]; + +export interface InventoryPrivacyScopeObservation { + readonly coverageStatus: PrivacyOwnerCoveragePartEncoded['coverageStatus']; + readonly evidenceRefs: readonly string[]; + readonly foundContentRefs: readonly string[]; + readonly observedAt: PrivacyOwnerCoveragePartEncoded['observedAt']; + readonly scopePart: InventoryPrivacyOwnerScopePart; + readonly unresolvedReason?: string; +} + +export interface InventoryPrivacyCoverageInput { + readonly assessedAt: PrivacyOwnerCoverageResultEncoded['assessedAt']; + readonly evidenceRefs: readonly string[]; + readonly observations: readonly InventoryPrivacyScopeObservation[]; + readonly scope: PrivacyOwnerCoverageResultEncoded['scope']; +} + +const incompleteCoveragePriority = [ + 'INDETERMINATE', + 'UNAVAILABLE', + 'PARTIAL', +] as const satisfies readonly PrivacyOwnerCoverageResultEncoded['coverageStatus'][]; + +const aggregateCoverageStatus = ( + parts: readonly PrivacyOwnerCoveragePartEncoded[], +): PrivacyOwnerCoverageResultEncoded['coverageStatus'] => { + if (parts.every(({ coverageStatus }) => coverageStatus === 'COMPLETE')) { + return 'COMPLETE'; + } + return ( + incompleteCoveragePriority.find((status) => parts.some(({ coverageStatus }) => coverageStatus === status)) ?? + 'INDETERMINATE' + ); +}; + +/** + * Adapts complete Inventory-owned scope observations to the shared Privacy Owner Contract. + * Missing or duplicate scope observations remain indeterminate instead of becoming NO_DATA. + */ +export const assessInventoryPrivacyOwnerCoverage = ( + input: InventoryPrivacyCoverageInput, +): PrivacyOwnerCoverageResultEncoded => { + const observationsByPart = new Map(); + for (const observation of input.observations) { + const observations = observationsByPart.get(observation.scopePart) ?? []; + observations.push(observation); + observationsByPart.set(observation.scopePart, observations); + } + + const coverageParts = inventoryPrivacyOwnerScopeParts.map((scopePart): PrivacyOwnerCoveragePartEncoded => { + const observations = observationsByPart.get(scopePart) ?? []; + const [observation] = observations; + if (observations.length !== 1 || observation === undefined) { + const unresolvedReason = + observations.length === 0 + ? 'REQUIRED_INVENTORY_OWNER_SCOPE_NOT_OBSERVED' + : 'DUPLICATE_INVENTORY_OWNER_SCOPE_OBSERVATION'; + return { + coverageStatus: 'INDETERMINATE', + evidenceRefs: observations.flatMap(({ evidenceRefs }) => evidenceRefs), + foundContentRefs: observations.flatMap(({ foundContentRefs }) => foundContentRefs), + observedAt: input.assessedAt, + scopeRef: `commerce.inventory/privacy-owner-scope/${scopePart}`, + unresolvedReason, + }; + } + + const coveragePart = { + coverageStatus: observation.coverageStatus, + evidenceRefs: [...observation.evidenceRefs], + foundContentRefs: [...observation.foundContentRefs], + observedAt: observation.observedAt, + scopeRef: `commerce.inventory/privacy-owner-scope/${scopePart}`, + }; + if (observation.coverageStatus === 'COMPLETE') { + return coveragePart; + } + return { + ...coveragePart, + unresolvedReason: observation.unresolvedReason ?? 'INVENTORY_OWNER_SCOPE_NOT_COMPLETELY_VERIFIED', + }; + }); + const coverageStatus = aggregateCoverageStatus(coverageParts); + const anyContentFound = coverageParts.some(({ foundContentRefs }) => foundContentRefs.length > 0); + let contentStatus: PrivacyOwnerCoverageResultEncoded['contentStatus']; + if (anyContentFound) { + contentStatus = 'FOUND'; + } else if (coverageStatus === 'COMPLETE') { + contentStatus = 'NO_DATA'; + } else { + contentStatus = 'UNKNOWN'; + } + + return { + assessedAt: input.assessedAt, + contentStatus, + coverageParts, + coverageStatus, + evidenceRefs: [...input.evidenceRefs], + scope: input.scope, + }; +}; + +export const inventoryPrivacyEvidencePreservationClasses = [ + 'REQUIRED_RESERVATION_EVIDENCE', + 'REQUIRED_COMMITTED_OBLIGATION_EVIDENCE', + 'REQUIRED_HISTORICAL_EVIDENCE', + 'PRIVACY_RELEVANT_OWNER_COPY', +] as const; +export type InventoryPrivacyEvidencePreservationClass = (typeof inventoryPrivacyEvidencePreservationClasses)[number]; + +export interface InventoryPrivacyMeasureTarget { + readonly contentRef: string; + readonly preservationClass: InventoryPrivacyEvidencePreservationClass; +} + +export interface InventoryPrivacyPreviousAttempt { + readonly measure: PrivacyMeasureEncoded; + readonly outcome: PrivacyOwnerExecutionOutcomeEncoded; +} + +export interface InventoryPrivacyMeasureEvaluationInput { + readonly antiResurrectionProtection?: AntiResurrectionProtectionEncoded; + readonly confirmedAt: PrivacyOwnerExecutionOutcomeEncoded['confirmedAt']; + readonly coverage: PrivacyOwnerCoverageResultEncoded; + readonly evidenceRefs: readonly string[]; + readonly measure: PrivacyMeasureEncoded; + readonly outcomeRef: string; + readonly previousAttempt?: InventoryPrivacyPreviousAttempt; + readonly reconciliation?: PrivacyOwnerReconciliationResultEncoded; + readonly targets: readonly InventoryPrivacyMeasureTarget[]; +} + +export interface InventoryPrivacyMeasureEvaluation { + readonly antiResurrectionProtection?: AntiResurrectionProtectionEncoded; + readonly outcome: PrivacyOwnerExecutionOutcomeEncoded; +} + +const canonicalReferences = (references: readonly string[]): readonly string[] => [...references].toSorted(); + +const canonicalPrivacySubject = (subject: PrivacyMeasureEncoded['scope']['subject']) => + Match.value(subject).pipe( + Match.tag('RESOLVED_DATA_SUBJECT', ({ _tag, subjectRef }) => ({ _tag, subjectRef })), + Match.tag('ANONYMOUS_PRIVACY_CONTEXT', ({ _tag, contextRef }) => ({ _tag, contextRef })), + Match.exhaustive, + ); + +const canonicalOwnerScope = (scope: PrivacyMeasureEncoded['scope']) => ({ + controllerRef: scope.controllerRef, + dsrControllerObligationRef: scope.dsrControllerObligationRef ?? null, + ownerCapability: scope.ownerCapability, + requestedScopePartRefs: canonicalReferences(scope.requestedScopePartRefs), + requestedScopeRef: scope.requestedScopeRef, + subject: canonicalPrivacySubject(scope.subject), + tenantId: scope.tenantId, + trustedLookupRefs: canonicalReferences(scope.trustedLookupRefs), +}); + +/** Stable comparison value persisted by the previous-attempt measure itself. */ +/* oxlint-disable effect-native/no-native-json-stringify -- The explicitly ordered canonical projection is the persisted fingerprint contract; expires: 2027-03-31. */ +export const inventoryPrivacyMeasureIdentityFingerprint = (measure: PrivacyMeasureEncoded): string => + JSON.stringify({ + expectedEvidenceRefs: canonicalReferences(measure.expectedEvidenceRefs), + idempotencyKey: measure.idempotencyKey, + intendedOutcome: measure.intendedOutcome, + measureRef: measure.measureRef, + preconditionRefs: canonicalReferences(measure.preconditionRefs), + requestedAt: measure.requestedAt, + scope: canonicalOwnerScope(measure.scope), + sourceDecisionRef: measure.sourceDecisionRef, + sourceDecisionRevision: measure.sourceDecisionRevision, + targetContentRefs: canonicalReferences(measure.targetContentRefs), + }); +/* oxlint-enable effect-native/no-native-json-stringify */ + +const hasSameMeasureIntent = (left: PrivacyMeasureEncoded, right: PrivacyMeasureEncoded): boolean => + inventoryPrivacyMeasureIdentityFingerprint(left) === inventoryPrivacyMeasureIdentityFingerprint(right); + +const hasExactReferences = (left: readonly string[], right: readonly string[]): boolean => { + if (left.length !== right.length) { + return false; + } + const canonicalLeft = canonicalReferences(left); + const canonicalRight = canonicalReferences(right); + return ( + canonicalLeft.length === canonicalRight.length && + canonicalLeft.every((reference, index) => reference === canonicalRight[index]) + ); +}; + +const hasSamePrivacySubject = ( + left: ReturnType, + right: ReturnType, +): boolean => + Match.value(left).pipe( + Match.tag('RESOLVED_DATA_SUBJECT', ({ subjectRef }) => + Match.value(right).pipe( + Match.tag('RESOLVED_DATA_SUBJECT', (candidate) => subjectRef === candidate.subjectRef), + Match.orElse(() => false), + ), + ), + Match.tag('ANONYMOUS_PRIVACY_CONTEXT', ({ contextRef }) => + Match.value(right).pipe( + Match.tag('ANONYMOUS_PRIVACY_CONTEXT', (candidate) => contextRef === candidate.contextRef), + Match.orElse(() => false), + ), + ), + Match.exhaustive, + ); + +const hasSameOwnerScope = (left: PrivacyMeasureEncoded['scope'], right: PrivacyMeasureEncoded['scope']): boolean => { + const leftCanonical = canonicalOwnerScope(left); + const rightCanonical = canonicalOwnerScope(right); + return ( + leftCanonical.controllerRef === rightCanonical.controllerRef && + leftCanonical.dsrControllerObligationRef === rightCanonical.dsrControllerObligationRef && + leftCanonical.ownerCapability === rightCanonical.ownerCapability && + leftCanonical.requestedScopeRef === rightCanonical.requestedScopeRef && + leftCanonical.tenantId === rightCanonical.tenantId && + hasSamePrivacySubject(leftCanonical.subject, rightCanonical.subject) && + hasExactReferences(leftCanonical.requestedScopePartRefs, rightCanonical.requestedScopePartRefs) && + hasExactReferences(leftCanonical.trustedLookupRefs, rightCanonical.trustedLookupRefs) + ); +}; + +const requiredAntiResurrectionKind = ( + intendedOutcome: PrivacyMeasureEncoded['intendedOutcome'], +): AntiResurrectionProtectionEncoded['kind'] | undefined => + Match.value(intendedOutcome).pipe( + Match.when('DELETE', () => 'DELETED_SCOPE' as const), + Match.when('ANONYMIZE', () => 'ANONYMIZED_SCOPE' as const), + Match.when('ENFORCE_DISPOSITION_RESTRICTION', () => 'OWNER_ENFORCED_DISPOSITION_RESTRICTION' as const), + Match.when('ENFORCE_PROCESSING_RESTRICTION', () => 'OWNER_ENFORCED_PROCESSING_RESTRICTION' as const), + Match.when('RECTIFY', EffectFunction.constUndefined), + Match.exhaustive, + ); + +/** + * Evaluates Inventory's truthful response without inventing a generic privacy mutation path. + * Inventory currently has no approved generic privacy Action; required business evidence is preserved, + * and any indeterminate prior attempt must be reconciled before this evaluator considers a retry. + */ +// oxlint-disable-next-line eslint/complexity -- The owner decision table remains intentionally explicit and exhaustively tested; expires: 2027-03-31. +export const evaluateInventoryPrivacyMeasure = ( + input: InventoryPrivacyMeasureEvaluationInput, +): InventoryPrivacyMeasureEvaluation => { + const baseOutcome = { + confirmedAt: input.confirmedAt, + evidenceRefs: [...input.evidenceRefs], + measureRef: input.measure.measureRef, + outcomeRef: input.outcomeRef, + scope: input.measure.scope, + sourceDecisionRef: input.measure.sourceDecisionRef, + sourceDecisionRevision: input.measure.sourceDecisionRevision, + } as const; + const remainingContentRefs = [...input.measure.targetContentRefs]; + + if (input.previousAttempt !== undefined) { + if (!hasSameMeasureIntent(input.previousAttempt.measure, input.measure)) { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'IDEMPOTENCY_IDENTITY_OR_MEASURE_SCOPE_CONFLICT', + reconciliationRequired: false, + remainingContentRefs, + status: 'BUSINESS_REJECTED', + }, + }; + } + + if (input.previousAttempt.outcome.status === 'INDETERMINATE') { + const { reconciliation } = input; + if ( + reconciliation === undefined || + reconciliation.measureRef !== input.measure.measureRef || + reconciliation.sourceDecisionRevision !== input.measure.sourceDecisionRevision || + reconciliation.status === 'STILL_INDETERMINATE' || + reconciliation.status === 'PARTIAL_CONFIRMED' + ) { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'OWNER_RECONCILIATION_REQUIRED_BEFORE_RETRY', + reconciliationRequired: true, + remainingContentRefs, + status: 'INDETERMINATE', + }, + }; + } + if (reconciliation.status === 'EXECUTION_CONFIRMED') { + const requiredProtectionKind = requiredAntiResurrectionKind(input.measure.intendedOutcome); + const protection = input.antiResurrectionProtection; + const hasCompleteProtection = + requiredProtectionKind === undefined || + (protection !== undefined && + protection.kind === requiredProtectionKind && + hasSameOwnerScope(protection.scope, input.measure.scope) && + protection.sourceDecisionRef === input.measure.sourceDecisionRef && + protection.sourceDecisionRevision === input.measure.sourceDecisionRevision && + protection.sourceOutcomeRef === input.outcomeRef && + hasExactReferences(protection.protectedContentRefs, input.measure.targetContentRefs) && + hasExactReferences(protection.staleSourceResponsibilities, [ + 'IMPORT', + 'REPLAY', + 'PROJECTION_REBUILD', + 'BACKUP_RECOVERY', + ])); + + if (!hasCompleteProtection) { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [...input.measure.targetContentRefs], + evidenceRefs: [...input.evidenceRefs, ...reconciliation.evidenceRefs], + reason: 'EXECUTION_CONFIRMED_BUT_ANTI_RESURRECTION_PROTECTION_NOT_PROVEN', + reconciliationRequired: false, + remainingContentRefs, + status: 'PARTIAL', + }, + }; + } + + const achieved = { + outcome: { + ...baseOutcome, + affectedContentRefs: [...input.measure.targetContentRefs], + evidenceRefs: [...input.evidenceRefs, ...reconciliation.evidenceRefs], + reason: 'ORIGINAL_OWNER_EXECUTION_CONFIRMED_BY_RECONCILIATION', + reconciliationRequired: false, + remainingContentRefs: [], + status: 'ACHIEVED', + }, + } satisfies InventoryPrivacyMeasureEvaluation; + return protection === undefined ? achieved : { ...achieved, antiResurrectionProtection: protection }; + } + if (!reconciliation.retryAllowed) { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'OWNER_RECONCILIATION_DID_NOT_AUTHORIZE_RETRY', + reconciliationRequired: true, + remainingContentRefs, + status: 'INDETERMINATE', + }, + }; + } + } else { + return { outcome: input.previousAttempt.outcome }; + } + } + + if ( + input.coverage.scope.requestedScopeRef !== input.measure.scope.requestedScopeRef || + input.coverage.scope.tenantId !== input.measure.scope.tenantId || + input.coverage.scope.ownerCapability !== input.measure.scope.ownerCapability + ) { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'OWNER_COVERAGE_SCOPE_DOES_NOT_MATCH_MEASURE_SCOPE', + reconciliationRequired: false, + remainingContentRefs, + status: 'BUSINESS_REJECTED', + }, + }; + } + + if (input.coverage.coverageStatus !== 'COMPLETE') { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'COMPLETE_INVENTORY_OWNER_SCOPE_COVERAGE_REQUIRED', + reconciliationRequired: true, + remainingContentRefs, + status: 'INDETERMINATE', + }, + }; + } + + if (input.coverage.contentStatus === 'NO_DATA') { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'COMPLETE_INVENTORY_OWNER_SCOPE_CONFIRMS_NO_DATA', + reconciliationRequired: false, + remainingContentRefs: [], + status: 'NOT_APPLICABLE', + }, + }; + } + + const protectedTargets = input.targets.filter( + ({ preservationClass }) => preservationClass !== 'PRIVACY_RELEVANT_OWNER_COPY', + ); + if (protectedTargets.length > 0) { + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'REQUIRED_RESERVATION_COMMITTED_OR_HISTORICAL_EVIDENCE_MUST_BE_PRESERVED', + reconciliationRequired: false, + remainingContentRefs, + status: 'BUSINESS_REJECTED', + }, + }; + } + + return { + outcome: { + ...baseOutcome, + affectedContentRefs: [], + reason: 'NO_APPROVED_INVENTORY_PRIVACY_MUTATION_ACTION', + reconciliationRequired: false, + remainingContentRefs, + status: 'BUSINESS_REJECTED', + }, + }; +}; + +export const inventoryPrivacyOwnerContract = { + antiResurrectionProtectionRequiredFor: [ + 'DELETE', + 'ANONYMIZE', + 'ENFORCE_DISPOSITION_RESTRICTION', + 'ENFORCE_PROCESSING_RESTRICTION', + ], + copiedCommerceCustomerProfileFieldsForReservation: [], + ownerCapability: 'commerce.inventory', + ownerMutationBoundary: 'NO_APPROVED_GENERIC_PRIVACY_MUTATION_ACTION', + requiredScopeParts: inventoryPrivacyOwnerScopeParts, + stockRecordsArePersonalByExistence: false, +} as const; diff --git a/app/verticals/inventory/shared/inventory-public-operations.ts b/app/verticals/inventory/shared/inventory-public-operations.ts new file mode 100644 index 000000000..589576af9 --- /dev/null +++ b/app/verticals/inventory/shared/inventory-public-operations.ts @@ -0,0 +1,794 @@ +/** + * Public Inventory owner-contract catalog. + * + * This is schema-name and behavior metadata only. It deliberately imports no executable + * implementation, provider contract, repository, or private deployment source. + */ + +export const inventoryPublicOperationBoundaries = [ + { + key: 'ONE_CONFIGURATION_ONE_BACKEND', + rule: 'One Customer Configuration selects exactly one Inventory Backend.', + }, + { + key: 'OWNER_CONTRACT_ONLY', + rule: 'Consumers use Inventory owner contracts and never a provider-specific WMS or ERP API.', + }, + { + key: 'EXACT_BINDING', + rule: 'Each supported exact Catalog Selection resolves to one Stock Item or a typed binding-resolution failure.', + }, + { + key: 'EXACT_QUANTITY_AND_UNIT', + rule: 'Inventory preserves exact Quantity and Unit without conversion or Package/Set decomposition.', + }, + { + key: 'ONE_RESERVATION_PER_ATTEMPT', + rule: 'One normal-runtime Attempt has exactly one Reservation, with one or more exact Allocations.', + }, + { + key: 'DISTINCT_MUTATION_IDENTITY', + rule: 'Every mutation uses a distinct stable owner-scoped idempotency identity.', + }, + { + key: 'RECOVER_ORIGINAL_IDENTITY', + rule: 'An indeterminate effect is verified or recovered through its original identity, never a fresh key.', + }, + { + key: 'CORRECTION_AUTHORITY_ONLY', + rule: 'Stock Correction is accepted only where the selected authority permits that correction.', + }, + { + key: 'PROTECTION_IS_NOT_CONFIRMATION', + rule: 'Commitment Protection is an Attempt-bound owner fence distinct from Reservation Confirmation.', + }, + { + key: 'TYPED_SOURCE_COVERAGE', + rule: 'Source-effect coverage uncertainty is typed; arrival order and guessed arithmetic do not establish Current truth.', + }, + { + key: 'NO_AUTOMATIC_BACKEND_FALLBACK', + rule: 'Changing an external backend to OntOS WMS is an explicit cutover, never automatic fallback.', + }, + { + key: 'POSITIVE_UNION_SHARING', + rule: 'Every applicable Current positive sharing relation grants eligibility; there is no DENY or specificity override.', + }, + { + key: 'SHARING_CHANGES_NEW_RESERVATIONS_ONLY', + rule: 'Sharing lifecycle changes affect new Reservations only and never rewrite existing Allocations or history.', + }, + { + key: 'NO_AVAILABILITY_CONTRACT', + rule: 'Inventory publishes governed stock evidence, not customer-facing Availability computation.', + }, +] as const; + +export type InventoryPublicOperationBoundaryKey = (typeof inventoryPublicOperationBoundaries)[number]['key']; + +export interface InventoryPublicOperationDescriptor { + readonly authority: string; + readonly boundaries: readonly InventoryPublicOperationBoundaryKey[]; + readonly businessIntent: string; + readonly idempotency: { + readonly identity: string; + readonly recovery: string; + readonly retry: string; + }; + readonly inputPrecision: string; + readonly key: `commerce.inventory.${string}`; + readonly kind: 'ACTION' | 'GOVERNED_READ'; + readonly outcomes: { + readonly sourceSchemaName: `${string}${'ResponseSchema' | 'ResultSchema'}`; + readonly vocabulary: readonly string[]; + }; + readonly owner: 'commerce.inventory'; + readonly safeCallerNextSteps: readonly string[]; + readonly scopeSubject: string; +} + +const INVENTORY_OWNER = 'commerce.inventory' as const; +const CATALOG_BINDING_SCOPE = 'Exact Catalog Selection -> Stock Item relation'; +const EXTERNAL_CORRELATION_SCOPE = 'Qualified external key -> exact Inventory target correlation'; +const STOCK_SHARING_SCOPE = 'Exact Stock Position -> Selling Legal Entity + Channel (+ optional Market/Storefront)'; + +export const inventoryPublicActionContracts = [ + { + authority: 'Inventory owns the Customer Configuration selection and cutover evidence.', + boundaries: ['ONE_CONFIGURATION_ONE_BACKEND', 'OWNER_CONTRACT_ONLY', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'Select the one authoritative Inventory Backend for one Customer Configuration.', + idempotency: { + identity: 'One owner-scoped selection mutation identity for the exact Customer Configuration and selection.', + recovery: 'A conflicting selection becomes typed conflict/cutover evidence; a fallback is never fabricated.', + retry: 'Retry the same identity and payload; an exact committed selection is an exact replay.', + }, + inputPrecision: 'Exact Customer Configuration and complete backend capability selection.', + key: 'commerce.inventory.select-inventory-backend', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'SelectInventoryBackendResultSchema', + vocabulary: ['SELECTED', 'EXACT_REPLAY', 'BACKEND_CONFIGURATION_CONFLICT'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Continue only with the returned Current configuration.', 'Resolve conflict before cutover.'], + scopeSubject: 'Customer Configuration', + }, + { + authority: + 'The selected external Inventory Backend supplies qualified source evidence; Inventory owns import truth.', + boundaries: ['ONE_CONFIGURATION_ONE_BACKEND', 'OWNER_CONTRACT_ONLY', 'TYPED_SOURCE_COVERAGE'], + businessIntent: 'Import a qualified external source assertion without inferring Current truth from arrival order.', + idempotency: { + identity: 'One import identity for the exact issuer/backend origin, source revision, scope, and assertion.', + recovery: 'Indeterminate source coverage remains reconciliation evidence under the original import identity.', + retry: 'Retry the same identity and assertion; never synthesize a newer revision or alternate source.', + }, + inputPrecision: + 'Exact correlated Stock Position, Stock Item, Stock Location, Unit, coverage, and source ordering evidence.', + key: 'commerce.inventory.import-source-assertion', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'ImportSourceAssertionResultSchema', + vocabulary: ['IMPORTED', 'EXACT_REPLAY', 'CONFLICT_RECORDED', 'INDETERMINATE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Use only determinate Current evidence.', 'Reconcile typed conflicts or uncertainty.'], + scopeSubject: 'External source assertion for one exact Stock Position', + }, + { + authority: 'Inventory resolves its durable source conflict; no provider write is exposed.', + boundaries: ['OWNER_CONTRACT_ONLY', 'TYPED_SOURCE_COVERAGE', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'Resolve one exact Inventory source conflict using owner-qualified evidence.', + idempotency: { + identity: 'One resolution mutation identity for the exact conflict and proposed owner resolution.', + recovery: 'Re-read the original conflict outcome; never bypass it with a fresh conflict identity.', + retry: 'Retry the same identity and resolution proposal only.', + }, + inputPrecision: 'Exact conflict ResourceRef, expected revision, resolution proposal, and evidence.', + key: 'commerce.inventory.resolve-inventory-source-conflict', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'ResolveInventorySourceConflictResultSchema', vocabulary: ['RESOLVED'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Refresh the governed affected-resource read.', 'Stop on a typed stale/conflict outcome.'], + scopeSubject: 'Inventory Source Conflict', + }, + { + authority: 'Inventory owns cleanup of its pre-commit Reservation effect under authoritative Order truth.', + boundaries: ['ONE_RESERVATION_PER_ATTEMPT', 'DISTINCT_MUTATION_IDENTITY', 'RECOVER_ORIGINAL_IDENTITY'], + businessIntent: + 'Compensate one exact pre-commit Reservation when final Order commit did not establish an obligation.', + idempotency: { + identity: 'One compensation mutation identity tied to the original Attempt and Reservation.', + recovery: 'Uncertain release remains attached to the original release effect identity.', + retry: 'Retry only after authoritative Order and protection truth is re-established.', + }, + inputPrecision: 'Exact Attempt, Reservation, original allocation scope, and authoritative non-commit evidence.', + key: 'commerce.inventory.compensate-inventory-pre-commit', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'CompensateInventoryPreCommitResultSchema', + vocabulary: ['NO_CLEANUP_REQUIRED', 'RELEASED', 'ALREADY_RELEASED', 'RECONCILIATION_REQUIRED'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Close the predecessor only after definite release.', + 'Reconcile uncertain cleanup before replacement.', + ], + scopeSubject: 'Original Attempt + provisional Reservation', + }, + { + authority: 'The selected backend establishes the exact Reservation; Inventory owns the durable request and result.', + boundaries: [ + 'ONE_CONFIGURATION_ONE_BACKEND', + 'EXACT_BINDING', + 'EXACT_QUANTITY_AND_UNIT', + 'ONE_RESERVATION_PER_ATTEMPT', + 'DISTINCT_MUTATION_IDENTITY', + 'RECOVER_ORIGINAL_IDENTITY', + ], + businessIntent: 'Establish or recover the one exact Reservation whose Allocations cover every Attempt requirement.', + idempotency: { + identity: 'One create effect and mutation identity for the one Reservation bound to the normal-runtime Attempt.', + recovery: 'INDETERMINATE is recovered only through that original create effect identity.', + retry: 'Retry the same exact request; a replacement requires safe predecessor closure and a new Attempt.', + }, + inputPrecision: 'Exact Stock Item + Quantity + Unit requirements and 1..N exact Stock Position allocations.', + key: 'commerce.inventory.create-inventory-reservation', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'CreateInventoryReservationResultSchema', + vocabulary: [ + 'PENDING', + 'ESTABLISHED', + 'EXACT_REPLAY', + 'RECONCILIATION_REQUIRED', + 'INDETERMINATE', + 'RESOLVED_NO_RESERVATION', + ], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Proceed to Confirmation only when ESTABLISHED.', + 'Recover the original effect when unresolved or indeterminate.', + 'Create a new Attempt only after safe predecessor closure.', + ], + scopeSubject: 'Normal-runtime Attempt + exact Reservation + Allocations', + }, + { + authority: 'The selected backend releases only after Inventory verifies authoritative owner and Order truth.', + boundaries: ['ONE_RESERVATION_PER_ATTEMPT', 'DISTINCT_MUTATION_IDENTITY', 'RECOVER_ORIGINAL_IDENTITY'], + businessIntent: 'Release one whole provisional Reservation when owner and Order truth prove release is safe.', + idempotency: { + identity: 'One release effect and mutation identity for the whole original Reservation.', + recovery: 'INDETERMINATE remains attached to the original release effect identity.', + retry: 'Retry the same whole-release identity; partial release and renewed Confirmation are forbidden.', + }, + inputPrecision: 'Exact Reservation + Attempt; whole-reservation scope only.', + key: 'commerce.inventory.release-inventory-reservation', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'ReleaseInventoryReservationResultSchema', + vocabulary: ['PENDING', 'RELEASED', 'ALREADY_RELEASED', 'NOT_RELEASABLE', 'INDETERMINATE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Close the predecessor on definite release.', + 'Reconcile original release before replacement.', + ], + scopeSubject: 'Whole provisional Reservation + original Attempt', + }, + { + authority: 'Inventory establishes the selected-backend owner fence immediately before final Order commit.', + boundaries: [ + 'ONE_RESERVATION_PER_ATTEMPT', + 'DISTINCT_MUTATION_IDENTITY', + 'RECOVER_ORIGINAL_IDENTITY', + 'PROTECTION_IS_NOT_CONFIRMATION', + ], + businessIntent: 'Establish exact Reservation + Attempt-bound Commitment Protection before final Order commit.', + idempotency: { + identity: 'One protection effect identity for the exact Reservation and Attempt.', + recovery: 'PENDING or INDETERMINATE is recovered only through the original protection effect identity.', + retry: 'Recover or retry the same original identity; never create a new fence, including after expiry.', + }, + inputPrecision: 'Exact Reservation, Attempt, Confirmation, backend authority, and observed owner-health instant.', + key: 'commerce.inventory.establish-commitment-protection', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'EstablishCommitmentProtectionResultSchema', + vocabulary: ['PENDING', 'PROTECTED', 'AT_RISK', 'INDETERMINATE', 'NOT_PROTECTABLE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Commit only when PROTECTED.', + 'PENDING means the original fence intent is durably queued; recover that original effect.', + 'Never create a new fence while the original effect is pending or indeterminate.', + 'Reconcile AT_RISK or INDETERMINATE through the original effect identity.', + 'Stop when NOT_PROTECTABLE.', + ], + scopeSubject: 'Exact Reservation + Attempt Commitment Protection', + }, + { + authority: 'The selected Inventory Backend performs the authoritative inbound physical change when permitted.', + boundaries: [ + 'ONE_CONFIGURATION_ONE_BACKEND', + 'OWNER_CONTRACT_ONLY', + 'EXACT_QUANTITY_AND_UNIT', + 'RECOVER_ORIGINAL_IDENTITY', + ], + businessIntent: 'Request one authoritative inbound physical Stock Receipt.', + idempotency: { + identity: 'One owner-scoped receipt effect identity for the exact physical change.', + recovery: 'An indeterminate receipt is recovered through its original effect identity.', + retry: 'Retry the same Stock Position, Quantity, Unit, reason, and effect identity.', + }, + inputPrecision: 'Exact Stock Position, Stock Item, Stock Location, positive Quantity, and Unit.', + key: 'commerce.inventory.stock-receipt', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'StockReceiptResultSchema', + vocabulary: ['REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Use APPLIED evidence.', + 'Stop on REJECTED.', + 'Recover the original effect on INDETERMINATE.', + ], + scopeSubject: 'Exact Stock Position physical inbound effect', + }, + { + authority: 'The selected Inventory Backend performs the authoritative physical decrease when permitted.', + boundaries: [ + 'ONE_CONFIGURATION_ONE_BACKEND', + 'OWNER_CONTRACT_ONLY', + 'EXACT_QUANTITY_AND_UNIT', + 'RECOVER_ORIGINAL_IDENTITY', + ], + businessIntent: 'Request one authoritative physical Stock Issue; Fulfillment trigger remains downstream.', + idempotency: { + identity: 'One owner-scoped issue effect identity for the exact physical change.', + recovery: 'An indeterminate issue is recovered through its original effect identity.', + retry: 'Retry the same Stock Position, Quantity, Unit, reason, and effect identity.', + }, + inputPrecision: 'Exact Stock Position, Stock Item, Stock Location, positive Quantity, and Unit.', + key: 'commerce.inventory.stock-issue', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'StockIssueResultSchema', + vocabulary: ['REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Use APPLIED evidence.', + 'Stop on REJECTED.', + 'Recover the original effect on INDETERMINATE.', + ], + scopeSubject: 'Exact Stock Position physical outbound effect', + }, + { + authority: + 'Only the selected backend authority may establish corrected absolute ON_HAND from still-current evidence.', + boundaries: [ + 'ONE_CONFIGURATION_ONE_BACKEND', + 'EXACT_QUANTITY_AND_UNIT', + 'CORRECTION_AUTHORITY_ONLY', + 'TYPED_SOURCE_COVERAGE', + 'NO_AUTOMATIC_BACKEND_FALLBACK', + ], + businessIntent: 'Establish corrected absolute ON_HAND for one Stock Position in an authority-permitted scope.', + idempotency: { + identity: 'One correction effect identity for the exact Position, absolute Quantity + Unit, and source evidence.', + recovery: 'Indeterminate correction remains under its original correction identity.', + retry: 'Retry the same correction only while its exact source evidence remains owner-valid.', + }, + inputPrecision: + 'Exact Stock Position, Stock Item, Stock Location, absolute ON_HAND Quantity + Unit, and source evidence.', + key: 'commerce.inventory.correct-stock-position', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'CorrectStockPositionResultSchema', + vocabulary: ['APPLIED', 'EXACT_REPLAY', 'INDETERMINATE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Use APPLIED Current evidence.', 'Reconcile INDETERMINATE.', 'Stop on authority rejection.'], + scopeSubject: 'Exact Stock Position absolute ON_HAND correction', + }, + { + authority: 'Inventory owns the Selection-to-Stock Item relation under the selected Customer Configuration.', + boundaries: ['EXACT_BINDING', 'DISTINCT_MUTATION_IDENTITY'], + businessIntent: 'Establish one explicit exact Catalog Selection to Stock Item binding.', + idempotency: { + identity: 'One lifecycle mutation identity for the exact binding ResourceRef and candidate.', + recovery: 'Read the exact binding after uncertainty; never infer from SKU, Product, or stock.', + retry: 'Retry the same candidate and identity; use Correct for a new Current relation.', + }, + inputPrecision: + 'Exact Catalog Selection identity, Stock Item, Unit meaning, configuration, and lifecycle evidence.', + key: 'commerce.inventory.establish-catalog-to-stock-binding', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'EstablishCatalogToStockBindingResultSchema', vocabulary: ['CURRENT'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Resolve through the governed binding read.', 'Stop on typed scope or uniqueness rejection.'], + scopeSubject: CATALOG_BINDING_SCOPE, + }, + { + authority: 'Inventory owns correction of its explicit Selection-to-Stock Item relation.', + boundaries: ['EXACT_BINDING', 'DISTINCT_MUTATION_IDENTITY'], + businessIntent: 'Correct one Current exact Catalog Selection to Stock Item binding with preserved history.', + idempotency: { + identity: 'One correction identity for the exact binding and expected revision.', + recovery: 'Read the exact binding revision after uncertainty; never silently replace it.', + retry: 'Retry the same expected revision and candidate only.', + }, + inputPrecision: 'Exact binding ResourceRef, expected revision, corrected Stock Item/Unit meaning, and evidence.', + key: 'commerce.inventory.correct-catalog-to-stock-binding', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'CorrectCatalogToStockBindingResultSchema', vocabulary: ['CURRENT'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Use the returned revision.', 'Refresh and decide explicitly on a typed revision conflict.'], + scopeSubject: CATALOG_BINDING_SCOPE, + }, + { + authority: 'Inventory owns ending its explicit Selection-to-Stock Item relation.', + boundaries: ['EXACT_BINDING', 'DISTINCT_MUTATION_IDENTITY'], + businessIntent: 'End one Current exact Catalog Selection to Stock Item binding without erasing history.', + idempotency: { + identity: 'One end identity for the exact binding and expected revision.', + recovery: 'Read the exact lifecycle state after uncertainty.', + retry: 'Retry the same end identity and evidence; do not create a replacement implicitly.', + }, + inputPrecision: 'Exact binding ResourceRef, expected revision, end instant, and lifecycle evidence.', + key: 'commerce.inventory.end-catalog-to-stock-binding', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'EndCatalogToStockBindingResultSchema', vocabulary: ['ENDED'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Treat future resolution as a typed non-success until explicitly re-established.'], + scopeSubject: CATALOG_BINDING_SCOPE, + }, + { + authority: 'Inventory owns the qualified external-key correlation and preserves its issuer/backend origin.', + boundaries: ['OWNER_CONTRACT_ONLY', 'DISTINCT_MUTATION_IDENTITY', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'Establish one qualified external stock correlation.', + idempotency: { + identity: 'One lifecycle identity for the exact correlation ResourceRef and qualified external key.', + recovery: 'Read the exact correlation after uncertainty; Current backend selection never rewrites key identity.', + retry: 'Retry the same origin, namespace/scope, identifier kind, external value, and target.', + }, + inputPrecision: 'Exact issuer/backend origin + namespace/scope + identifier kind + external ID value + target.', + key: 'commerce.inventory.establish-external-stock-correlation', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'EstablishExternalStockCorrelationResultSchema', vocabulary: ['CURRENT'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Use only the returned exact correlation.', 'Stop on ambiguous or conflicting identity.'], + scopeSubject: EXTERNAL_CORRELATION_SCOPE, + }, + { + authority: 'Inventory owns correction of the qualified external-key correlation.', + boundaries: ['OWNER_CONTRACT_ONLY', 'DISTINCT_MUTATION_IDENTITY', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'Correct one Current qualified external stock correlation while preserving history.', + idempotency: { + identity: 'One correction identity for the exact correlation and expected revision.', + recovery: 'Read the exact correlation revision after uncertainty.', + retry: 'Retry the same qualified identity, target, expected revision, and evidence.', + }, + inputPrecision: + 'Exact correlation ResourceRef, immutable qualified key origin, corrected target, and expected revision.', + key: 'commerce.inventory.correct-external-stock-correlation', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'CorrectExternalStockCorrelationResultSchema', vocabulary: ['CURRENT'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Use the returned revision.', 'Resolve a typed collision explicitly.'], + scopeSubject: EXTERNAL_CORRELATION_SCOPE, + }, + { + authority: 'Inventory owns ending the qualified external-key correlation.', + boundaries: ['OWNER_CONTRACT_ONLY', 'DISTINCT_MUTATION_IDENTITY', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'End one Current qualified external stock correlation without erasing historical identity.', + idempotency: { + identity: 'One end identity for the exact correlation and expected revision.', + recovery: 'Use authorized ended-correlation evidence lookup after uncertainty.', + retry: 'Retry the same end identity and evidence only.', + }, + inputPrecision: 'Exact correlation ResourceRef, expected revision, end instant, and evidence.', + key: 'commerce.inventory.end-external-stock-correlation', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'EndExternalStockCorrelationResultSchema', vocabulary: ['ENDED'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Stop using the external key for Current resolution.', + 'Use authorized history for reconciliation.', + ], + scopeSubject: EXTERNAL_CORRELATION_SCOPE, + }, + { + authority: 'Inventory owns the positive relation after validating the trusted Commerce scope.', + boundaries: ['DISTINCT_MUTATION_IDENTITY', 'POSITIVE_UNION_SHARING', 'SHARING_CHANGES_NEW_RESERVATIONS_ONLY'], + businessIntent: 'Establish one Current positive Stock Sharing Eligibility relation.', + idempotency: { + identity: 'One lifecycle identity for the exact Position and Commerce subject relation.', + recovery: 'Re-read the exact relation; never infer a DENY or broader Sales Context Resource.', + retry: 'Retry the same relation identity and scope evidence.', + }, + inputPrecision: 'Exact Position + required Selling Legal Entity + Channel + optional Market and/or Storefront.', + key: 'commerce.inventory.establish-stock-sharing-eligibility', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'EstablishStockSharingEligibilityResultSchema', vocabulary: ['CURRENT'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Evaluate trusted Current purchase context through the governed positive-union read.'], + scopeSubject: STOCK_SHARING_SCOPE, + }, + { + authority: 'Inventory owns changes to the positive relation after validating trusted Commerce scope.', + boundaries: ['DISTINCT_MUTATION_IDENTITY', 'POSITIVE_UNION_SHARING', 'SHARING_CHANGES_NEW_RESERVATIONS_ONLY'], + businessIntent: 'Change one Current positive Stock Sharing Eligibility relation with preserved history.', + idempotency: { + identity: 'One change identity for the exact relation and expected revision.', + recovery: 'Re-read the exact relation revision after uncertainty.', + retry: 'Retry the same subject, expected revision, and evidence.', + }, + inputPrecision: 'Exact relation + Position + required Selling Legal Entity + Channel + optional restrictions.', + key: 'commerce.inventory.change-stock-sharing-eligibility', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'ChangeStockSharingEligibilityResultSchema', vocabulary: ['CURRENT'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Apply the new relation only to new Reservations.', + 'Preserve existing Allocations and history.', + ], + scopeSubject: STOCK_SHARING_SCOPE, + }, + { + authority: 'Inventory owns ending one positive relation; other applicable Current relations remain effective.', + boundaries: ['DISTINCT_MUTATION_IDENTITY', 'POSITIVE_UNION_SHARING', 'SHARING_CHANGES_NEW_RESERVATIONS_ONLY'], + businessIntent: 'End one Current positive Stock Sharing Eligibility relation without creating a DENY.', + idempotency: { + identity: 'One end identity for the exact relation and expected revision.', + recovery: 'Re-read the exact relation and positive-union result after uncertainty.', + retry: 'Retry the same end identity and evidence only.', + }, + inputPrecision: 'Exact relation ResourceRef and end evidence for its Selling Legal Entity + Channel subject.', + key: 'commerce.inventory.end-stock-sharing-eligibility', + kind: 'ACTION', + outcomes: { sourceSchemaName: 'EndStockSharingEligibilityResultSchema', vocabulary: ['ENDED'] }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Re-evaluate positive-union eligibility.', + 'Do not revoke access proven by another applicable relation.', + ], + scopeSubject: STOCK_SHARING_SCOPE, + }, + { + authority: 'Inventory consults the original selected-backend owner recovery adapter for the exact durable target.', + boundaries: ['ONE_CONFIGURATION_ONE_BACKEND', 'OWNER_CONTRACT_ONLY', 'RECOVER_ORIGINAL_IDENTITY'], + businessIntent: 'Resolve one uncertain Inventory effect using its original owner-scoped identity and intent.', + idempotency: { + identity: 'The original effect ID, kind, target, backend, scope, and intent are immutable recovery identity.', + recovery: + 'Recovery can prove original success, definitive non-effect, existing terminal state, or continuing uncertainty.', + retry: 'Repeat only the same original effect identity; a fresh key is a different mutation, not recovery.', + }, + inputPrecision: + 'Exact original effect ID + kind + durable target ResourceRef; original stored intent remains authoritative.', + key: 'commerce.inventory.recover-inventory-effect', + kind: 'ACTION', + outcomes: { + sourceSchemaName: 'RecoverInventoryEffectResultSchema', + vocabulary: ['RECOVERED', 'DEFINITIVE_NON_EFFECT', 'ALREADY_TERMINAL', 'INDETERMINATE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Continue only on proven success.', + 'Stop on definitive non-effect/rejection.', + 'Retry original recovery on INDETERMINATE.', + ], + scopeSubject: 'Original owner-scoped Inventory Effect + exact durable target', + }, +] as const satisfies readonly InventoryPublicOperationDescriptor[]; + +export const inventoryGovernedReadContracts = [ + { + authority: 'Inventory resolves its owner-governed Current binding under the selected Customer Configuration.', + boundaries: ['ONE_CONFIGURATION_ONE_BACKEND', 'EXACT_BINDING'], + businessIntent: 'Resolve one supported exact Catalog Selection to its one Current Stock Item binding.', + idempotency: { + identity: 'The read identity is the exact Customer Configuration and Catalog Selection demand.', + recovery: 'Unavailable or ambiguous resolution is re-read; no guessed binding is cached as truth.', + retry: 'Repeat the same governed read after the typed cause changes.', + }, + inputPrecision: 'Exact Catalog Selection, Quantity, Unit, occurrence, and Customer Configuration.', + key: 'commerce.inventory.api.catalog-to-stock-binding-resolution', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'CatalogToStockBindingResolutionResponseSchema', + vocabulary: ['RESOLVED', 'AMBIGUOUS', 'UNSUPPORTED', 'UNAVAILABLE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Use the exact resolved Stock Item.', + 'Invoke an explicit binding lifecycle Action on typed failure.', + ], + scopeSubject: 'Exact Catalog Selection -> Stock Item binding', + }, + { + authority: 'Inventory evaluates Current positive relations against trusted Commerce-owner context evidence.', + boundaries: ['POSITIVE_UNION_SHARING', 'SHARING_CHANGES_NEW_RESERVATIONS_ONLY'], + businessIntent: 'Resolve Current Stock Sharing Eligibility for one Position and trusted Current purchase context.', + idempotency: { + identity: 'The read identity is the exact Position plus trusted Current Commerce context evidence.', + recovery: 'Unverifiable evidence cannot fabricate eligibility; obtain fresh trusted evidence and re-read.', + retry: 'Repeat the same governed read with Current owner evidence.', + }, + inputPrecision: + 'Exact Position + required Selling Legal Entity + Channel + every specified Market/Storefront restriction.', + key: 'commerce.inventory.api.stock-sharing-eligibility-resolution', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'StockSharingEligibilityResolutionResponseSchema', + vocabulary: ['ELIGIBLE', 'NO_APPLICABLE_RELATION', 'UNVERIFIABLE'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Permit this gate when at least one applicable Current positive relation is proven.', + 'Otherwise stop or refresh evidence.', + ], + scopeSubject: 'Exact Stock Position + trusted Selling Legal Entity + Channel purchase context', + }, + { + authority: 'Inventory returns owner-governed evidence for the exact durable Stock Position identity.', + boundaries: ['ONE_CONFIGURATION_ONE_BACKEND', 'TYPED_SOURCE_COVERAGE', 'NO_AVAILABILITY_CONTRACT'], + businessIntent: 'Read Current stock evidence for one exact durable Stock Position without computing Availability.', + idempotency: { + identity: 'The read identity is the exact Stock Position ResourceRef.', + recovery: 'Missing, stale, or unverifiable evidence remains typed and is refreshed through owner contracts.', + retry: 'Repeat the same governed read after owner evidence changes.', + }, + inputPrecision: 'Exact Stock Position ResourceRef; never ad-hoc (Stock Item, Stock Location) identity.', + key: 'commerce.inventory.api.current-stock-evidence-for-availability', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'CurrentStockEvidenceForAvailabilityResponseSchema', + vocabulary: [ + 'STOCK_EVIDENCE_ONLY', + 'OWNER_MANAGED', + 'EXTERNAL_SOURCE_ASSERTION', + 'MISSING', + 'EXACT', + 'INDETERMINATE', + ], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Apply caller-owned Availability policy.', + 'Do not infer reusable stock from unresolved effects or missing source evidence.', + ], + scopeSubject: 'Exact durable Stock Position ResourceRef', + }, + { + authority: 'Inventory owns and returns the one Current backend selection for the Customer Configuration.', + boundaries: ['ONE_CONFIGURATION_ONE_BACKEND', 'OWNER_CONTRACT_ONLY', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'Read the Current authoritative Inventory Backend selection for one Customer Configuration.', + idempotency: { + identity: 'The read identity is the exact Customer Configuration.', + recovery: 'Missing or unavailable configuration remains typed; callers never infer or substitute a backend.', + retry: 'Repeat the same governed read after the owner configuration changes or becomes available.', + }, + inputPrecision: 'Exact Customer Configuration identifier in the authenticated Tenant scope.', + key: 'commerce.inventory.api.inventory-backend-configuration-current', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'InventoryBackendConfigurationCurrentResponseSchema', + vocabulary: ['CURRENT_CONFIGURATION'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Use only the returned Current backend configuration.', + 'Stop when no Current configuration exists.', + ], + scopeSubject: 'Exact Customer Configuration backend selection', + }, + { + authority: 'Inventory returns the Current owner record for the exact Reservation.', + boundaries: ['ONE_RESERVATION_PER_ATTEMPT', 'EXACT_QUANTITY_AND_UNIT'], + businessIntent: 'Read one exact provisional Reservation or runtime committed obligation.', + idempotency: { + identity: 'The read identity is the exact Reservation ResourceRef.', + recovery: 'A typed unavailable/conflict result is re-read; callers do not reconstruct Reservation truth.', + retry: 'Repeat the same governed read after owner state settles.', + }, + inputPrecision: 'Exact Reservation ResourceRef with preserved Allocations, Stock Items, Quantities, and Units.', + key: 'commerce.inventory.api.inventory-reservation-detail', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'InventoryReservationDetailResponseSchema', + vocabulary: ['PROVISIONAL_RESERVATION', 'COMMITTED_OBLIGATION'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Use the returned owner state.', 'Verify Confirmation separately before protection.'], + scopeSubject: 'Exact Reservation ResourceRef', + }, + { + authority: 'Inventory returns the exact durable source conflict and its owner-qualified reconciliation evidence.', + boundaries: ['OWNER_CONTRACT_ONLY', 'TYPED_SOURCE_COVERAGE', 'NO_AUTOMATIC_BACKEND_FALLBACK'], + businessIntent: 'Read one exact Inventory Source Conflict without exposing provider-private state.', + idempotency: { + identity: 'The read identity is the exact Inventory Source Conflict ResourceRef.', + recovery: 'Missing or unavailable conflict evidence remains typed; callers never reconstruct conflict truth.', + retry: 'Repeat the same governed read after owner evidence or conflict state changes.', + }, + inputPrecision: 'Exact Inventory Source Conflict ResourceRef in the authenticated Tenant scope.', + key: 'commerce.inventory.api.inventory-source-conflict-detail', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'InventorySourceConflictDetailResponseSchema', + vocabulary: ['OPEN', 'RESOLVED'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Resolve only an OPEN conflict through the owning Action.', + 'Use RESOLVED evidence as immutable reconciliation history.', + ], + scopeSubject: 'Exact Inventory Source Conflict ResourceRef', + }, + { + authority: 'Inventory evaluates owner Confirmation health for the exact Reservation + Attempt.', + boundaries: ['ONE_RESERVATION_PER_ATTEMPT', 'PROTECTION_IS_NOT_CONFIRMATION'], + businessIntent: 'Verify Current Reservation Confirmation and readiness for Commitment Protection.', + idempotency: { + identity: 'The read identity is the exact Confirmation + Reservation + Attempt at the evaluation instant.', + recovery: 'Expired or terminal Confirmation is not renewed by this read.', + retry: 'Repeat with Current owner evidence; use a new Attempt only after safe predecessor closure.', + }, + inputPrecision: 'Exact Confirmation ResourceRef, Reservation ResourceRef, Attempt, and evaluation instant.', + key: 'commerce.inventory.api.reservation-confirmation-verification', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'ReservationConfirmationVerificationResponseSchema', + vocabulary: ['READY_TO_ESTABLISH_PROTECTION', 'NOT_READY', 'TERMINAL_READINESS_LOSS'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Establish protection only when ready.', 'Resolve predecessor before a replacement Attempt.'], + scopeSubject: 'Exact Reservation + Attempt + Confirmation', + }, + { + authority: 'Inventory verifies the Current selected-backend protection fence for the exact Reservation + Attempt.', + boundaries: ['ONE_RESERVATION_PER_ATTEMPT', 'PROTECTION_IS_NOT_CONFIRMATION'], + businessIntent: 'Verify Commitment Protection immediately before the caller relies on the owner fence.', + idempotency: { + identity: 'The read identity is the exact Protection + Reservation + Attempt.', + recovery: 'AT_RISK is reconciled; verification never upgrades or backdates protection.', + retry: 'Repeat the exact governed read with Current owner evidence.', + }, + inputPrecision: 'Exact Protection ResourceRef, Reservation ResourceRef, and Attempt.', + key: 'commerce.inventory.api.commitment-protection-verification', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'CommitmentProtectionVerificationResponseSchema', + vocabulary: ['PROTECTED', 'AT_RISK'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: ['Continue only when PROTECTED.', 'Reconcile when AT_RISK.'], + scopeSubject: 'Exact Reservation + Attempt Commitment Protection', + }, + { + authority: 'Inventory resolves its durable effect ledger using the original immutable owner intent.', + boundaries: ['RECOVER_ORIGINAL_IDENTITY', 'OWNER_CONTRACT_ONLY'], + businessIntent: 'Resolve one Inventory Effect outcome by original owner-scoped idempotency identity.', + idempotency: { + identity: 'The read identity is the original effect ID plus the exact immutable stored intent.', + recovery: 'UNRESOLVED or INDETERMINATE directs recovery of the same original effect identity.', + retry: 'Repeat the same governed read; never substitute a fresh mutation key.', + }, + inputPrecision: 'Exact original effect ID and original owner intent.', + key: 'commerce.inventory.api.inventory-effect-outcome', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'InventoryEffectOutcomeResponseSchema', + vocabulary: ['UNRESOLVED', 'INDETERMINATE', 'RESOLVED'], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Recover only the original effect identity when unresolved or indeterminate.', + 'Continue or stop only from the terminal owner result.', + ], + scopeSubject: 'Original owner-scoped Inventory Effect identity + intent', + }, + { + authority: + 'Inventory exposes bounded authorized history and reconciliation evidence for its exact owner resources.', + boundaries: ['OWNER_CONTRACT_ONLY', 'RECOVER_ORIGINAL_IDENTITY', 'TYPED_SOURCE_COVERAGE'], + businessIntent: 'Look up authorized historical or reconciliation evidence for one exact Inventory owner subject.', + idempotency: { + identity: 'The read identity is the exact requested evidence kind and owner ResourceRef/effect identity.', + recovery: 'Unavailable evidence remains typed; callers neither scrape private history nor infer missing truth.', + retry: 'Repeat the same bounded governed read after evidence becomes available.', + }, + inputPrecision: + 'Exact binding, ended correlation, sharing, Confirmation, Protection, effect, or conflict identity.', + key: 'commerce.inventory.api.inventory-reconciliation-evidence', + kind: 'GOVERNED_READ', + outcomes: { + sourceSchemaName: 'InventoryReconciliationEvidenceResponseSchema', + vocabulary: [ + 'BINDING_HISTORY', + 'ENDED_CORRELATION', + 'SHARING_HISTORY', + 'CONFIRMATION_HISTORY', + 'PROTECTION_HISTORY', + 'EFFECT_OUTCOME', + 'SOURCE_CONFLICT_DETAIL', + ], + }, + owner: INVENTORY_OWNER, + safeCallerNextSteps: [ + 'Use evidence only for its declared reconciliation subject.', + 'Use the owning mutation/recovery Action for any state change.', + ], + scopeSubject: 'Exact authorized historical or reconciliation evidence subject', + }, +] as const satisfies readonly InventoryPublicOperationDescriptor[]; + +export const inventoryPublicOperations = [ + ...inventoryPublicActionContracts, + ...inventoryGovernedReadContracts, +] as const satisfies readonly InventoryPublicOperationDescriptor[]; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts new file mode 100644 index 000000000..6b0d24b92 --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts @@ -0,0 +1,23 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.commitment-protection-changed.v1 +import { Schema } from 'effect'; + +import { + InventoryCommittedEventSubjectRefSchema, + InventoryOwnerAggregateRevisionOrderingSchema, +} from '../domain/inventory-domain-event-handoff.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + ordering: InventoryOwnerAggregateRevisionOrderingSchema, + ownerReadOrProofKey: Schema.Literal('commerce.inventory.api.commitment-protection-verification'), + state: Schema.Literals(['PROTECTED', 'AT_RISK']), + subjectRef: Schema.Struct({ + ...InventoryCommittedEventSubjectRefSchema.fields, + resourceType: Schema.Literal('commerce.inventory.commitment-protection'), + }), +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.commitment-protection-changed.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-commitment-protection-establishment-requested-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-commitment-protection-establishment-requested-v1.ts new file mode 100644 index 000000000..a87094927 --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-commitment-protection-establishment-requested-v1.ts @@ -0,0 +1,14 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.commitment-protection-establishment-requested.v1 +import { Schema } from 'effect'; + +import { CommitmentProtectionEffectRequestSchema } from '../domain/commitment-protection.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + request: CommitmentProtectionEffectRequestSchema, +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.commitment-protection-establishment-requested.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-committed-obligation-changed-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-committed-obligation-changed-v1.ts new file mode 100644 index 000000000..470678d5d --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-committed-obligation-changed-v1.ts @@ -0,0 +1,26 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.committed-obligation-changed.v1 +import { Schema } from 'effect'; + +import { + InventoryCommittedEventSubjectRefSchema, + InventoryImmutableOccurrenceOrderingSchema, +} from '../domain/inventory-domain-event-handoff.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + ordering: InventoryImmutableOccurrenceOrderingSchema, + ownerReadOrProofKey: Schema.Literal('commerce.inventory.api.inventory-reconciliation-evidence'), + state: Schema.Literal('RECONCILIATION_REQUIRED'), + subjectRef: Schema.Struct({ + ...InventoryCommittedEventSubjectRefSchema.fields, + resourceType: Schema.Literals([ + 'commerce.inventory.inventory-reservation', + 'commerce.inventory.imported-committed-obligation', + ]), + }), +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.committed-obligation-changed.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-inventory-reservation-create-requested-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-inventory-reservation-create-requested-v1.ts new file mode 100644 index 000000000..a64f0e434 --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-inventory-reservation-create-requested-v1.ts @@ -0,0 +1,13 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.inventory-reservation-create-requested.v1 +import { Schema } from 'effect'; +import { InventoryReservationCreateRequestSchema } from '../domain/inventory-reservation-create.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + request: InventoryReservationCreateRequestSchema, +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.inventory-reservation-create-requested.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-inventory-reservation-release-requested-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-inventory-reservation-release-requested-v1.ts new file mode 100644 index 000000000..421f51b5a --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-inventory-reservation-release-requested-v1.ts @@ -0,0 +1,13 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.inventory-reservation-release-requested.v1 +import { Schema } from 'effect'; +import { ReservationReleaseRequestSchema } from '../domain/inventory-reservation-release.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + request: ReservationReleaseRequestSchema, +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.inventory-reservation-release-requested.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1.ts new file mode 100644 index 000000000..6bb3da5dd --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1.ts @@ -0,0 +1,25 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.reservation-confirmation-issuance-requested.v1 +import { Schema } from 'effect'; + +import { InventoryReservationCreateMutationIdSchema } from '../domain/inventory-reservation-create.ts'; +import { ProvisionalInventoryReservationSchema } from '../domain/inventory-obligation.ts'; +import { ActionInvocationIdSchema, LegalEntityIdSchema } from '../domain/physical-stock-effect.ts'; +import { ReservationAuthorityEffectIdSchema } from '../domain/reservation-issuer-failure-fields.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + request: Schema.Struct({ + confirmationRef: ReservationConfirmationRefSchema, + effectId: ReservationAuthorityEffectIdSchema, + legalEntityId: LegalEntityIdSchema, + mutationId: InventoryReservationCreateMutationIdSchema, + reservation: ProvisionalInventoryReservationSchema, + sourceActionInvocationId: ActionInvocationIdSchema, + }), +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.reservation-confirmation-issuance-requested.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-reservation-guarantee-changed-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-reservation-guarantee-changed-v1.ts new file mode 100644 index 000000000..cb9ec7a7e --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-reservation-guarantee-changed-v1.ts @@ -0,0 +1,35 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.reservation-guarantee-changed.v1 +import { Schema } from 'effect'; + +import { + InventoryCommittedEventSubjectRefSchema, + InventoryImmutableOccurrenceOrderingSchema, +} from '../domain/inventory-domain-event-handoff.ts'; +import { ReservationConfirmationRefSchema } from '../resources/reservation-confirmation.ts'; + +const subjectRef = Schema.Struct({ + ...InventoryCommittedEventSubjectRefSchema.fields, + resourceType: Schema.Literal('commerce.inventory.inventory-reservation'), +}); + +export const OutboxPayloadSchema = Schema.Union([ + Schema.Struct({ + confirmationRef: ReservationConfirmationRefSchema, + ordering: InventoryImmutableOccurrenceOrderingSchema, + ownerReadOrProofKey: Schema.Literal('commerce.inventory.api.reservation-confirmation-verification'), + state: Schema.Literal('ESTABLISHED'), + subjectRef, + }), + Schema.Struct({ + ordering: InventoryImmutableOccurrenceOrderingSchema, + ownerReadOrProofKey: Schema.Literal('commerce.inventory.api.inventory-reservation-detail'), + state: Schema.Literals(['RELEASED', 'AT_RISK']), + subjectRef, + }), +]); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.reservation-guarantee-changed.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-stock-issue-requested-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-stock-issue-requested-v1.ts new file mode 100644 index 000000000..093ccb3d3 --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-stock-issue-requested-v1.ts @@ -0,0 +1,14 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.stock-issue-requested.v1 +import { Schema } from 'effect'; + +import { PhysicalStockEffectRequestSchema } from '../domain/physical-stock-effect.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + request: PhysicalStockEffectRequestSchema, +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.stock-issue-requested.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-stock-position-evidence-changed-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-stock-position-evidence-changed-v1.ts new file mode 100644 index 000000000..633f9b2ca --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-stock-position-evidence-changed-v1.ts @@ -0,0 +1,35 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.stock-position-evidence-changed.v1 +import { Schema } from 'effect'; + +import { + InventoryCommittedEventSubjectRefSchema, + InventoryImmutableOccurrenceOrderingSchema, + InventoryOwnerAggregateRevisionOrderingSchema, +} from '../domain/inventory-domain-event-handoff.ts'; + +const commonPayloadFields = { + ownerReadOrProofKey: Schema.Literal('commerce.inventory.api.current-stock-evidence-for-availability'), + subjectRef: Schema.Struct({ + ...InventoryCommittedEventSubjectRefSchema.fields, + resourceType: Schema.Literal('commerce.inventory.stock-position'), + }), +} as const; + +export const OutboxPayloadSchema = Schema.Union([ + Schema.Struct({ + ...commonPayloadFields, + ordering: InventoryOwnerAggregateRevisionOrderingSchema, + state: Schema.Literals(['CORRECTED', 'INDETERMINATE']), + }), + Schema.Struct({ + ...commonPayloadFields, + ordering: InventoryImmutableOccurrenceOrderingSchema, + state: Schema.Literals(['RECEIPT_APPLIED', 'ISSUE_APPLIED']), + }), +]); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.stock-position-evidence-changed.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/outbox/commerce-inventory-stock-receipt-requested-v1.ts b/app/verticals/inventory/shared/outbox/commerce-inventory-stock-receipt-requested-v1.ts new file mode 100644 index 000000000..e14f2ac5f --- /dev/null +++ b/app/verticals/inventory/shared/outbox/commerce-inventory-stock-receipt-requested-v1.ts @@ -0,0 +1,14 @@ +// @generated by OntOS Codesmith Outbox Message Contract v1 +// @ontos-outbox-producer commerce.inventory +// @ontos-outbox-topic commerce.inventory.stock-receipt-requested.v1 +import { Schema } from 'effect'; + +import { PhysicalStockEffectRequestSchema } from '../domain/physical-stock-effect.ts'; + +export const OutboxPayloadSchema = Schema.Struct({ + request: PhysicalStockEffectRequestSchema, +}); +export type OutboxPayload = Schema.Schema.Type; + +export const outboxTopic = 'commerce.inventory.stock-receipt-requested.v1' as const; +export const outboxProducerModuleKey = 'commerce.inventory' as const; diff --git a/app/verticals/inventory/shared/permissions/inventory-audit-read.ts b/app/verticals/inventory/shared/permissions/inventory-audit-read.ts new file mode 100644 index 000000000..4af6ee1e4 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-audit-read.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.audit.read +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryAuditReadPermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.audit.read', + meaning: 'Inventory Audit Read business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.api.inventory-reconciliation-evidence'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-catalog-to-stock-binding-manage.ts b/app/verticals/inventory/shared/permissions/inventory-catalog-to-stock-binding-manage.ts new file mode 100644 index 000000000..ba07bf987 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-catalog-to-stock-binding-manage.ts @@ -0,0 +1,21 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.catalog_to_stock_binding.manage +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryCatalogToStockBindingManagePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.catalog_to_stock_binding.manage', + meaning: 'Inventory Catalog To Stock Binding Manage business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: [ + 'commerce.inventory.establish-catalog-to-stock-binding', + 'commerce.inventory.correct-catalog-to-stock-binding', + 'commerce.inventory.end-catalog-to-stock-binding', + ], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-commitment-protection-establish.ts b/app/verticals/inventory/shared/permissions/inventory-commitment-protection-establish.ts new file mode 100644 index 000000000..9364111b6 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-commitment-protection-establish.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.commitment_protection.establish +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryCommitmentProtectionEstablishPermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.commitment_protection.establish', + meaning: 'Inventory Commitment Protection Establish business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.establish-commitment-protection'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-external-stock-correlation-manage.ts b/app/verticals/inventory/shared/permissions/inventory-external-stock-correlation-manage.ts new file mode 100644 index 000000000..31275fa56 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-external-stock-correlation-manage.ts @@ -0,0 +1,21 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.external_stock_correlation.manage +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryExternalStockCorrelationManagePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.external_stock_correlation.manage', + meaning: 'Inventory External Stock Correlation Manage business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: [ + 'commerce.inventory.establish-external-stock-correlation', + 'commerce.inventory.correct-external-stock-correlation', + 'commerce.inventory.end-external-stock-correlation', + ], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-migration-manage.ts b/app/verticals/inventory/shared/permissions/inventory-migration-manage.ts new file mode 100644 index 000000000..0741b1bca --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-migration-manage.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.migration.manage +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryMigrationManagePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.migration.manage', + meaning: 'Inventory Migration Manage business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.select-inventory-backend', 'commerce.inventory.import-source-assertion'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-recovery-execute.ts b/app/verticals/inventory/shared/permissions/inventory-recovery-execute.ts new file mode 100644 index 000000000..4fa234391 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-recovery-execute.ts @@ -0,0 +1,21 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.recovery.execute +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryRecoveryExecutePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.recovery.execute', + meaning: 'Inventory Recovery Execute business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: [ + 'commerce.inventory.recover-inventory-effect', + 'commerce.inventory.compensate-inventory-pre-commit', + 'commerce.inventory.resolve-inventory-source-conflict', + ], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-reservation-establish.ts b/app/verticals/inventory/shared/permissions/inventory-reservation-establish.ts new file mode 100644 index 000000000..24baf3420 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-reservation-establish.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.reservation.establish +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryReservationEstablishPermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.reservation.establish', + meaning: 'Inventory Reservation Establish business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.create-inventory-reservation'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-reservation-release.ts b/app/verticals/inventory/shared/permissions/inventory-reservation-release.ts new file mode 100644 index 000000000..c0833c032 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-reservation-release.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.reservation.release +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryReservationReleasePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.reservation.release', + meaning: 'Inventory Reservation Release business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.release-inventory-reservation'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-resource-read.ts b/app/verticals/inventory/shared/permissions/inventory-resource-read.ts new file mode 100644 index 000000000..93f0abc5c --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-resource-read.ts @@ -0,0 +1,25 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.resource.read +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryResourceReadPermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.resource.read', + meaning: 'Inventory Resource Read business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: [ + 'commerce.inventory.api.catalog-to-stock-binding-resolution', + 'commerce.inventory.api.commitment-protection-verification', + 'commerce.inventory.api.current-stock-evidence-for-availability', + 'commerce.inventory.api.inventory-effect-outcome', + 'commerce.inventory.api.inventory-reservation-detail', + 'commerce.inventory.api.reservation-confirmation-verification', + 'commerce.inventory.api.stock-sharing-eligibility-resolution', + ], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-stock-correct.ts b/app/verticals/inventory/shared/permissions/inventory-stock-correct.ts new file mode 100644 index 000000000..6d7693e66 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-stock-correct.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.stock.correct +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryStockCorrectPermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.stock.correct', + meaning: 'Inventory Stock Correct business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.correct-stock-position'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-stock-issue.ts b/app/verticals/inventory/shared/permissions/inventory-stock-issue.ts new file mode 100644 index 000000000..c246e90a0 --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-stock-issue.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.stock.issue +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryStockIssuePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.stock.issue', + meaning: 'Inventory Stock Issue business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.stock-issue'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-stock-receipt.ts b/app/verticals/inventory/shared/permissions/inventory-stock-receipt.ts new file mode 100644 index 000000000..fccf5fe6c --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-stock-receipt.ts @@ -0,0 +1,17 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.stock.receipt +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryStockReceiptPermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.stock.receipt', + meaning: 'Inventory Stock Receipt business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: ['commerce.inventory.stock-receipt'], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/permissions/inventory-stock-sharing-eligibility-manage.ts b/app/verticals/inventory/shared/permissions/inventory-stock-sharing-eligibility-manage.ts new file mode 100644 index 000000000..e4d1200ac --- /dev/null +++ b/app/verticals/inventory/shared/permissions/inventory-stock-sharing-eligibility-manage.ts @@ -0,0 +1,21 @@ +// @generated by OntOS Codesmith Business Permission v1 +// @ontos-permission-owner commerce.inventory +// @ontos-permission-code inventory.stock_sharing_eligibility.manage +import { defineBusinessPermission } from '@app/core-runtime'; + +export const inventoryStockSharingEligibilityManagePermission = defineBusinessPermission({ + allowedScopeKinds: ['inventory_resource'], + auditSensitivity: 'sensitive', + authorityGroups: [], + customerDelegable: false, + internalGrantable: false, + key: 'inventory.stock_sharing_eligibility.manage', + meaning: 'Inventory Stock Sharing Eligibility Manage business permission.', + owningCapability: 'commerce.inventory', + protectedEntrypoints: [ + 'commerce.inventory.establish-stock-sharing-eligibility', + 'commerce.inventory.change-stock-sharing-eligibility', + 'commerce.inventory.end-stock-sharing-eligibility', + ], + schemaVersion: '1', +}); diff --git a/app/verticals/inventory/shared/resources/catalog-to-stock-binding.ts b/app/verticals/inventory/shared/resources/catalog-to-stock-binding.ts new file mode 100644 index 000000000..ef9335f78 --- /dev/null +++ b/app/verticals/inventory/shared/resources/catalog-to-stock-binding.ts @@ -0,0 +1,33 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug catalog-to-stock-binding +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +const checkedUuid = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()); + +export const CatalogToStockBindingIdSchema = checkedUuid.pipe(Schema.brand('CatalogToStockBindingId')); +export const CatalogToStockBindingTenantIdSchema = checkedUuid.pipe(Schema.brand('CatalogToStockBindingTenantId')); + +export const CatalogToStockBindingRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: CatalogToStockBindingIdSchema, + resourceType: Schema.Literal('commerce.inventory.catalog-to-stock-binding'), + tenantId: CatalogToStockBindingTenantIdSchema, +}); +export type CatalogToStockBindingRef = typeof CatalogToStockBindingRefSchema.Type; + +export const catalogToStockBindingResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: + 'Inventory-owned Current relation from one exact Catalog Selection meaning to one compatible Stock Item.', + key: 'commerce.inventory.catalog-to-stock-binding', + label: 'Catalog To Stock Binding', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/commitment-protection.ts b/app/verticals/inventory/shared/resources/commitment-protection.ts new file mode 100644 index 000000000..66120b131 --- /dev/null +++ b/app/verticals/inventory/shared/resources/commitment-protection.ts @@ -0,0 +1,32 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug commitment-protection +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const CommitmentProtectionIdSchema = Schema.String.check(Schema.isTrimmed(), Schema.isUUID()).pipe( + Schema.brand('CommitmentProtectionId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe(Schema.brand('InventoryTenantId')); + +export const CommitmentProtectionRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: CommitmentProtectionIdSchema, + resourceType: Schema.Literal('commerce.inventory.commitment-protection'), + tenantId: TenantIdSchema, +}); +export type CommitmentProtectionRef = typeof CommitmentProtectionRefSchema.Type; + +export const commitmentProtectionResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Attempt-bound owner guarantee fencing one exact Inventory Reservation through Order commitment.', + key: 'commerce.inventory.commitment-protection', + label: 'Commitment Protection', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/external-stock-correlation.ts b/app/verticals/inventory/shared/resources/external-stock-correlation.ts new file mode 100644 index 000000000..6eacdffe6 --- /dev/null +++ b/app/verticals/inventory/shared/resources/external-stock-correlation.ts @@ -0,0 +1,35 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug external-stock-correlation +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const ExternalStockCorrelationIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('InventoryExternalStockCorrelationId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('InventoryExternalStockCorrelationTenantId'), +); + +export const ExternalStockCorrelationRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: ExternalStockCorrelationIdSchema, + resourceType: Schema.Literal('commerce.inventory.external-stock-correlation'), + tenantId: TenantIdSchema, +}); +export type ExternalStockCorrelationRef = typeof ExternalStockCorrelationRefSchema.Type; + +export const externalStockCorrelationResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: + 'Issuer-qualified relation from one external stock identifier to one stable Stock Item or Stock Location for an Effective Period.', + key: 'commerce.inventory.external-stock-correlation', + label: 'External Stock Correlation', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/imported-committed-obligation.ts b/app/verticals/inventory/shared/resources/imported-committed-obligation.ts new file mode 100644 index 000000000..38b9bf259 --- /dev/null +++ b/app/verticals/inventory/shared/resources/imported-committed-obligation.ts @@ -0,0 +1,32 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug imported-committed-obligation +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const ImportedCommittedObligationIdSchema = Schema.String.check(Schema.isTrimmed(), Schema.isUUID()).pipe( + Schema.brand('ImportedCommittedObligationId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe(Schema.brand('InventoryTenantId')); + +export const ImportedCommittedObligationRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: ImportedCommittedObligationIdSchema, + resourceType: Schema.Literal('commerce.inventory.imported-committed-obligation'), + tenantId: TenantIdSchema, +}); +export type ImportedCommittedObligationRef = typeof ImportedCommittedObligationRefSchema.Type; + +export const importedCommittedObligationResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Migration-origin committed stock obligation for an already-proven imported Order.', + key: 'commerce.inventory.imported-committed-obligation', + label: 'Imported Committed Obligation', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/inventory-backend-configuration.ts b/app/verticals/inventory/shared/resources/inventory-backend-configuration.ts new file mode 100644 index 000000000..414724e95 --- /dev/null +++ b/app/verticals/inventory/shared/resources/inventory-backend-configuration.ts @@ -0,0 +1,32 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug inventory-backend-configuration +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +const ResourceIdSchema = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(300)).pipe( + Schema.brand('InventoryBackendConfigurationResourceId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('TenantId')); + +export const InventoryBackendConfigurationRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: ResourceIdSchema, + resourceType: Schema.Literal('commerce.inventory.inventory-backend-configuration'), + tenantId: TenantIdSchema, +}); +export type InventoryBackendConfigurationRef = typeof InventoryBackendConfigurationRefSchema.Type; + +export const inventoryBackendConfigurationResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Inventory Backend Configuration resource.', + key: 'commerce.inventory.inventory-backend-configuration', + label: 'Inventory Backend Configuration', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/inventory-reservation.ts b/app/verticals/inventory/shared/resources/inventory-reservation.ts new file mode 100644 index 000000000..5b19a6855 --- /dev/null +++ b/app/verticals/inventory/shared/resources/inventory-reservation.ts @@ -0,0 +1,32 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug inventory-reservation +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const InventoryReservationIdSchema = Schema.String.check(Schema.isTrimmed(), Schema.isUUID()).pipe( + Schema.brand('InventoryReservationId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe(Schema.brand('InventoryTenantId')); + +export const InventoryReservationRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: InventoryReservationIdSchema, + resourceType: Schema.Literal('commerce.inventory.inventory-reservation'), + tenantId: TenantIdSchema, +}); +export type InventoryReservationRef = typeof InventoryReservationRefSchema.Type; + +export const inventoryReservationResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'One durable provisional stock obligation for one exact Order Commitment Attempt.', + key: 'commerce.inventory.inventory-reservation', + label: 'Inventory Reservation', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/inventory-source-conflict.ts b/app/verticals/inventory/shared/resources/inventory-source-conflict.ts new file mode 100644 index 000000000..c1601320f --- /dev/null +++ b/app/verticals/inventory/shared/resources/inventory-source-conflict.ts @@ -0,0 +1,35 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug inventory-source-conflict +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const InventorySourceConflictIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('InventorySourceConflictId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('InventorySourceConflictTenantId'), +); + +export const InventorySourceConflictRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: InventorySourceConflictIdSchema, + resourceType: Schema.Literal('commerce.inventory.inventory-source-conflict'), + tenantId: TenantIdSchema, +}); +export type InventorySourceConflictRef = typeof InventorySourceConflictRefSchema.Type; + +export const inventorySourceConflictResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: + 'Stable Inventory-owned identity for one exact external source conflict and its append-only resolution evidence.', + key: 'commerce.inventory.inventory-source-conflict', + label: 'Inventory Source Conflict', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/reservation-confirmation.ts b/app/verticals/inventory/shared/resources/reservation-confirmation.ts new file mode 100644 index 000000000..de5cacfca --- /dev/null +++ b/app/verticals/inventory/shared/resources/reservation-confirmation.ts @@ -0,0 +1,32 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug reservation-confirmation +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const ReservationConfirmationIdSchema = Schema.String.check(Schema.isTrimmed(), Schema.isUUID()).pipe( + Schema.brand('ReservationConfirmationId'), +); +const TenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe(Schema.brand('InventoryTenantId')); + +export const ReservationConfirmationRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: ReservationConfirmationIdSchema, + resourceType: Schema.Literal('commerce.inventory.reservation-confirmation'), + tenantId: TenantIdSchema, +}); +export type ReservationConfirmationRef = typeof ReservationConfirmationRefSchema.Type; + +export const reservationConfirmationResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Single Attempt-bound proof issued by the selected Reservation Authority.', + key: 'commerce.inventory.reservation-confirmation', + label: 'Reservation Confirmation', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/stock-item.ts b/app/verticals/inventory/shared/resources/stock-item.ts new file mode 100644 index 000000000..4868b4031 --- /dev/null +++ b/app/verticals/inventory/shared/resources/stock-item.ts @@ -0,0 +1,34 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug stock-item +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +export const StockItemIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('InventoryStockItemId'), +); +export const InventoryTenantIdSchema = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()).pipe( + Schema.brand('InventoryTenantId'), +); + +export const StockItemRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: StockItemIdSchema, + resourceType: Schema.Literal('commerce.inventory.stock-item'), + tenantId: InventoryTenantIdSchema, +}); +export type StockItemRef = typeof StockItemRefSchema.Type; + +export const stockItemResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Durable Inventory identity for one immutable exact Catalog Selection meaning and Unit.', + key: 'commerce.inventory.stock-item', + label: 'Stock Item', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/stock-location.ts b/app/verticals/inventory/shared/resources/stock-location.ts new file mode 100644 index 000000000..85b1a1836 --- /dev/null +++ b/app/verticals/inventory/shared/resources/stock-location.ts @@ -0,0 +1,37 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug stock-location +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +const checkedUuid = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()); +export const StockLocationResourceIdSchema = checkedUuid.pipe( + Schema.brand('InventoryStockLocationResourceId'), + Schema.decodeTo(checkedUuid), +); +export const StockLocationTenantIdSchema = checkedUuid.pipe( + Schema.brand('InventoryStockLocationTenantId'), + Schema.decodeTo(checkedUuid), +); + +export const StockLocationRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: StockLocationResourceIdSchema, + resourceType: Schema.Literal('commerce.inventory.stock-location'), + tenantId: StockLocationTenantIdSchema, +}); +export type StockLocationRef = typeof StockLocationRefSchema.Type; + +export const stockLocationResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Durable operational scope in which Inventory stock facts have meaning.', + key: 'commerce.inventory.stock-location', + label: 'Stock Location', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/stock-position.ts b/app/verticals/inventory/shared/resources/stock-position.ts new file mode 100644 index 000000000..bcd3a0f6a --- /dev/null +++ b/app/verticals/inventory/shared/resources/stock-position.ts @@ -0,0 +1,37 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug stock-position +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +const checkedUuid = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()); +export const StockPositionIdSchema = checkedUuid.pipe( + Schema.brand('InventoryStockPositionId'), + Schema.decodeTo(checkedUuid), +); +export const StockPositionTenantIdSchema = checkedUuid.pipe( + Schema.brand('InventoryStockPositionTenantId'), + Schema.decodeTo(checkedUuid), +); + +export const StockPositionRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: StockPositionIdSchema, + resourceType: Schema.Literal('commerce.inventory.stock-position'), + tenantId: StockPositionTenantIdSchema, +}); +export type StockPositionRef = typeof StockPositionRefSchema.Type; + +export const stockPositionResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Durable constrained quantity scope for one exact Stock Item and Stock Location.', + key: 'commerce.inventory.stock-position', + label: 'Stock Position', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/resources/stock-sharing-eligibility.ts b/app/verticals/inventory/shared/resources/stock-sharing-eligibility.ts new file mode 100644 index 000000000..34c108d03 --- /dev/null +++ b/app/verticals/inventory/shared/resources/stock-sharing-eligibility.ts @@ -0,0 +1,37 @@ +// @generated by OntOS Codesmith Resource v1 +// @ontos-resource-owner commerce.inventory +// @ontos-resource-slug stock-sharing-eligibility +import type { OntosResourceType } from '@app/core-runtime'; +import { Schema } from 'effect'; + +const checkedUuid = Schema.String.check(Schema.isUUID(), Schema.isTrimmed()); +export const StockSharingEligibilityIdSchema = checkedUuid.pipe( + Schema.brand('InventoryStockSharingEligibilityId'), + Schema.decodeTo(checkedUuid), +); +export const StockSharingEligibilityTenantIdSchema = checkedUuid.pipe( + Schema.brand('InventoryStockSharingEligibilityTenantId'), + Schema.decodeTo(checkedUuid), +); + +export const StockSharingEligibilityRefSchema = Schema.Struct({ + moduleId: Schema.Literal('commerce.inventory'), + resourceId: StockSharingEligibilityIdSchema, + resourceType: Schema.Literal('commerce.inventory.stock-sharing-eligibility'), + tenantId: StockSharingEligibilityTenantIdSchema, +}); +export type StockSharingEligibilityRef = typeof StockSharingEligibilityRefSchema.Type; + +export const stockSharingEligibilityResourceDescriptor = { + capabilities: { + graphVisible: false, + linkable: false, + mediaAttachable: false, + searchable: false, + timelineVisible: false, + }, + description: 'Stock Sharing Eligibility resource.', + key: 'commerce.inventory.stock-sharing-eligibility', + label: 'Stock Sharing Eligibility', + owningModuleId: 'commerce.inventory', +} as const satisfies OntosResourceType; diff --git a/app/verticals/inventory/shared/ultramodern-build.json b/app/verticals/inventory/shared/ultramodern-build.json new file mode 100644 index 000000000..3633c5b8c --- /dev/null +++ b/app/verticals/inventory/shared/ultramodern-build.json @@ -0,0 +1,44 @@ +{ + "deliveryUnit": { + "appId": "inventory", + "buildMarker": "d87a59b2fccc989f", + "deployProfile": "cloudflare-ssr-mf-effect-v1", + "kind": "microvertical-delivery-unit", + "packageName": "@app/inventory", + "schemaVersion": 1, + "sourceRevision": "workspace", + "unitId": "app/inventory", + "version": "0.1.0", + "build": "d87a59b2fccc989f" + }, + "kind": "ultramodern-build-artifact", + "schemaVersion": 1, + "surfaces": { + "api": { + "appId": "inventory", + "buildMarker": "d87a59b2fccc989f", + "deployProfile": "cloudflare-ssr-mf-effect-v1", + "kind": "microvertical-delivery-unit", + "packageName": "@app/inventory", + "schemaVersion": 1, + "sourceRevision": "workspace", + "unitId": "app/inventory", + "version": "0.1.0", + "build": "d87a59b2fccc989f", + "surface": "api" + }, + "ui": { + "appId": "inventory", + "buildMarker": "d87a59b2fccc989f", + "deployProfile": "cloudflare-ssr-mf-effect-v1", + "kind": "microvertical-delivery-unit", + "packageName": "@app/inventory", + "schemaVersion": 1, + "sourceRevision": "workspace", + "unitId": "app/inventory", + "version": "0.1.0", + "build": "d87a59b2fccc989f", + "surface": "ui" + } + } +} diff --git a/app/verticals/inventory/shared/ultramodern-build.ts b/app/verticals/inventory/shared/ultramodern-build.ts new file mode 100644 index 000000000..c884dff49 --- /dev/null +++ b/app/verticals/inventory/shared/ultramodern-build.ts @@ -0,0 +1,14 @@ +import buildArtifact from './ultramodern-build.json' with { type: 'json' }; +import { resolveUltramodernBuildArtifact } from '@modern-js/runtime-extensions/build-identity'; + +declare const ULTRAMODERN_BUILD_MARKER: string; +declare const ULTRAMODERN_SOURCE_REVISION: string; + +const ultramodernBuildArtifact = resolveUltramodernBuildArtifact(buildArtifact, { + buildMarker: () => ULTRAMODERN_BUILD_MARKER, + sourceRevision: () => ULTRAMODERN_SOURCE_REVISION, +}); + +export const ultramodernDeliveryUnit = ultramodernBuildArtifact.deliveryUnit; +export const ultramodernUiMarker = ultramodernBuildArtifact.surfaces.ui; +export const ultramodernApiMarker = ultramodernBuildArtifact.surfaces.api; diff --git a/app/verticals/inventory/src/actions/change-stock-sharing-eligibility.action.ts b/app/verticals/inventory/src/actions/change-stock-sharing-eligibility.action.ts new file mode 100644 index 000000000..36adf2ddb --- /dev/null +++ b/app/verticals/inventory/src/actions/change-stock-sharing-eligibility.action.ts @@ -0,0 +1,125 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug change-stock-sharing-eligibility +import { randomUUID } from 'node:crypto'; + +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; + +import { + ChangeStockSharingEligibilityPayloadSchema, + ChangeStockSharingEligibilityResultSchema, +} from '../../shared/actions/change-stock-sharing-eligibility.ts'; +import type { ChangeStockSharingEligibilityPayload } from '../../shared/actions/change-stock-sharing-eligibility.ts'; +import { + StockSharingEligibilityLifecycleAuditEvidenceSchema, + StockSharingEligibilityLifecycleErrorSchema, + StockSharingEligibilityLifecycleRejected, +} from '../../shared/actions/establish-stock-sharing-eligibility.ts'; +import type { StockSharingEligibilityActionService } from '../services/stock-sharing-eligibility-action.service.ts'; +import { + stockSharingEligibilityActionServiceForScope, + stockSharingEligibilityAuditEvidence, +} from '../services/stock-sharing-eligibility-action.service.ts'; + +const ACTION_KEY = 'commerce.inventory.change-stock-sharing-eligibility'; +const EVENT_TYPE = 'commerce.inventory.stock-sharing-eligibility-changed.v1'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = { + [EVENT_TYPE]: Schema.Struct({ relation: ChangeStockSharingEligibilityResultSchema }), +} as const; + +export const handleChangeStockSharingEligibility = Effect.fn('ChangeStockSharingEligibilityAction.handle')( + function* handle( + payload: ChangeStockSharingEligibilityPayload, + context: ActionHandlerContext, + ) { + if (context.scope.legalEntityId === undefined) { + return yield* new StockSharingEligibilityLifecycleRejected({ + code: 'stock_sharing_eligibility_lifecycle_rejected', + reason: 'TRUSTED_LEGAL_ENTITY_MISMATCH', + }); + } + const relation = yield* context.services.change(payload, context.scope.legalEntityId); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `stock-sharing-eligibility:${relation.ref.resourceId}:change`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: relation.scope.positionRef.resourceId, + targetResourceType: relation.scope.positionRef.resourceType, + }); + yield* context.addDomainEvent({ + eventType: EVENT_TYPE, + payloadJson: { relation }, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: relation.ref.resourceId, + subjectResourceType: relation.ref.resourceType, + }); + yield* context.recordAuditEvidence(stockSharingEligibilityAuditEvidence(relation, 'CHANGE')); + return relation; + }, +); + +export const changeStockSharingEligibilityAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.change-stock-sharing-eligibility.access.v1', + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: StockSharingEligibilityLifecycleAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.stock_sharing_eligibility.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.positionRef.moduleId, + resourceId: payload.positionRef.resourceId, + resourceType: payload.positionRef.resourceType, + }, + tenantId: payload.positionRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: StockSharingEligibilityLifecycleErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: ChangeStockSharingEligibilityPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.positionRef, + })), + resultSchema: ChangeStockSharingEligibilityResultSchema, + schemaVersion: '1', + }, + handleChangeStockSharingEligibility, + (transaction, scope) => stockSharingEligibilityActionServiceForScope(transaction, scope, randomUUID), +); + +export { + ChangeStockSharingEligibilityPayloadSchema, + ChangeStockSharingEligibilityResultSchema, +} from '../../shared/actions/change-stock-sharing-eligibility.ts'; +export type { ChangeStockSharingEligibilityPayload } from '../../shared/actions/change-stock-sharing-eligibility.ts'; + +// +// diff --git a/app/verticals/inventory/src/actions/compensate-inventory-pre-commit.action.ts b/app/verticals/inventory/src/actions/compensate-inventory-pre-commit.action.ts new file mode 100644 index 000000000..72f648650 --- /dev/null +++ b/app/verticals/inventory/src/actions/compensate-inventory-pre-commit.action.ts @@ -0,0 +1,203 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug compensate-inventory-pre-commit +/* oxlint-disable anti-slop-effect/no-service-constructor-imports -- The generated Action factory constructs owner-local services and repositories inside its transaction scope; expires: 2027-03-31. */ +import { createHash, randomUUID } from 'node:crypto'; + +import type { ActionHandlerContext } from '@app/core-runtime'; +import { DateTime, Effect, Schema } from 'effect'; + +import { defineAction, defineActionBusinessPermission, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { + CompensateInventoryPreCommitErrorSchema, + CompensateInventoryPreCommitPayloadSchema, + CompensateInventoryPreCommitResultSchema, +} from '../../shared/actions/compensate-inventory-pre-commit.ts'; +import type { CompensateInventoryPreCommitPayload } from '../../shared/actions/compensate-inventory-pre-commit.ts'; +import { + ReservationReleaseEffectIdSchema, + ReservationReleaseMutationIdSchema, +} from '../../shared/domain/inventory-reservation-release.ts'; +import { ActionInvocationIdSchema, LegalEntityIdSchema } from '../../shared/domain/physical-stock-effect.ts'; +import { OutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-inventory-reservation-release-requested-v1.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { inventoryObligationPersistenceForScope } from '../persistence/inventory-obligation-repository.ts'; +import { reservationCreateEffectPersistenceForScope } from '../persistence/reservation-create-effect-repository.ts'; +import { reservationReleaseEffectPersistenceForScope } from '../persistence/reservation-release-effect-repository.ts'; +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +import type { InventoryPreCommitCompensationService } from '../services/inventory-pre-commit-compensation.service.ts'; +import { + InventoryPreCommitCleanup, + InventoryPreCommitOrderTruth, + inventoryPreCommitCompensationUnavailable, + makeInventoryPreCommitCompensationService, +} from '../services/inventory-pre-commit-compensation.service.ts'; +import { + makeInventoryReservationReleaseService, + reservationReleaseUnavailable, +} from '../services/inventory-reservation-release.service.ts'; +import { createReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxMessage as createReleaseOutboxMessage } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; + +export { + CompensateInventoryPreCommitErrorSchema, + CompensateInventoryPreCommitPayloadSchema, + CompensateInventoryPreCommitResultSchema, +} from '../../shared/actions/compensate-inventory-pre-commit.ts'; + +const ACTION_KEY = 'commerce.inventory.compensate-inventory-pre-commit'; +const MODULE_KEY = 'commerce.inventory'; +const RELEASE_REQUESTED_EVENT = 'commerce.inventory.inventory-reservation-release-requested.v1'; +const domainEvents = { [RELEASE_REQUESTED_EVENT]: OutboxPayloadSchema } as const; + +export const handleCompensateInventoryPreCommit = Effect.fn('CompensateInventoryPreCommitAction.handle')( + function* handle( + payload: CompensateInventoryPreCommitPayload, + context: ActionHandlerContext, + ) { + if (context.scope.legalEntityId === undefined) { + return yield* inventoryPreCommitCompensationUnavailable( + payload.createEffectId, + 'Compensation requires a trusted Legal Entity scope', + ); + } + const legalEntityId = yield* Schema.decodeEffect(LegalEntityIdSchema)(context.scope.legalEntityId).pipe( + Effect.mapError((cause) => + inventoryPreCommitCompensationUnavailable( + payload.createEffectId, + 'Trusted Legal Entity identity is invalid', + cause, + ), + ), + ); + const actionInvocationId = yield* Schema.decodeEffect(ActionInvocationIdSchema)(context.actionInvocationId).pipe( + Effect.mapError((cause) => + inventoryPreCommitCompensationUnavailable( + payload.createEffectId, + 'Action Invocation identity is invalid', + cause, + ), + ), + ); + const decision = yield* context.services.compensate(payload, { + actionInvocationId, + legalEntityId, + requestedAt: DateTime.formatIso(yield* DateTime.now), + tenantId: context.scope.tenantId, + }); + const createEffect = + decision.result.outcome === 'RESERVATION_RELEASE' ? decision.result.createEffect : decision.result.effect; + const reservationRef = createEffect.request.reservation.ref; + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-pre-commit-compensation:${payload.createEffectId}`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: reservationRef.resourceId, + targetResourceType: reservationRef.resourceType, + }); + if (decision.releaseDispatchRequested) { + if (decision.result.outcome !== 'RESERVATION_RELEASE') { + return yield* inventoryPreCommitCompensationUnavailable( + payload.createEffectId, + 'Compensation returned an invalid Release dispatch decision', + ); + } + const eventPayload = { request: decision.result.release.effect.request }; + const event = yield* context.addDomainEvent({ + eventType: RELEASE_REQUESTED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: reservationRef.resourceId, + subjectResourceType: reservationRef.resourceType, + }); + yield* context.addOutboxMessage(event, createReleaseOutboxMessage(eventPayload)); + } + return decision.result; + }, +); + +export const compensateInventoryPreCommitAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.recovery.execute', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.authorizationTargetRef.moduleId, + resourceId: payload.authorizationTargetRef.resourceId, + resourceType: payload.authorizationTargetRef.resourceType, + }, + tenantId: payload.authorizationTargetRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: CompensateInventoryPreCommitErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: 'commerce.inventory', + payloadSchema: CompensateInventoryPreCommitPayloadSchema, + policies: [], + resultSchema: CompensateInventoryPreCommitResultSchema, + schemaVersion: '1', + }, + handleCompensateInventoryPreCommit, + (transaction, scope) => + Effect.all( + { + cleanup: InventoryPreCommitCleanup, + orderTruth: InventoryPreCommitOrderTruth, + }, + { concurrency: 2 }, + ).pipe( + Effect.map(({ cleanup, orderTruth }) => { + const obligations = inventoryObligationPersistenceForScope(transaction, scope); + const ledger = makeInventoryEffectLedgerService( + inventoryEffectLedgerPersistenceForScope(transaction, scope), + DateTime.now.pipe(Effect.map(DateTime.formatIso)), + ); + return makeInventoryPreCommitCompensationService({ + cleanup, + createEffects: reservationCreateEffectPersistenceForScope(transaction, scope), + ledger, + makeReleaseEffectId: (createEffectId) => + ReservationReleaseEffectIdSchema.make( + `pre-commit:${createHash('sha256').update(createEffectId).digest('hex')}`, + ), + orderTruth, + release: makeInventoryReservationReleaseService({ + effects: reservationReleaseEffectPersistenceForScope(transaction, scope), + ledger, + makeMutationId: () => ReservationReleaseMutationIdSchema.make(randomUUID()), + obligations: { + read: (ref) => + obligations + .read(ref) + .pipe( + Effect.mapError((cause) => + reservationReleaseUnavailable(undefined, 'Inventory Reservation is unavailable', cause), + ), + ), + }, + }), + }); + }), + ), +); + +// +// diff --git a/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts new file mode 100644 index 000000000..d617d8915 --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.correct-catalog-to-stock-binding +// @ontos-outbox-topic commerce.inventory.commitment-protection-changed.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; + +export { + OutboxPayloadSchema as CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxPayloadSchema, + outboxProducerModuleKey as CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxProducerModuleKey, + outboxTopic as CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; +export type { OutboxPayload as CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; + +export const createCorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts new file mode 100644 index 000000000..e3b35c289 --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.correct-catalog-to-stock-binding +// @ontos-outbox-topic commerce.inventory.committed-obligation-changed.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-committed-obligation-changed-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-committed-obligation-changed-v1'; + +export { + OutboxPayloadSchema as CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxPayloadSchema, + outboxProducerModuleKey as CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxProducerModuleKey, + outboxTopic as CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-committed-obligation-changed-v1'; +export type { OutboxPayload as CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-committed-obligation-changed-v1'; + +export const createCorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts new file mode 100644 index 000000000..558445280 --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.correct-catalog-to-stock-binding +// @ontos-outbox-topic commerce.inventory.reservation-guarantee-changed.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-reservation-guarantee-changed-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-reservation-guarantee-changed-v1'; + +export { + OutboxPayloadSchema as CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxPayloadSchema, + outboxProducerModuleKey as CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxProducerModuleKey, + outboxTopic as CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-reservation-guarantee-changed-v1'; +export type { OutboxPayload as CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-reservation-guarantee-changed-v1'; + +export const createCorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding.action.ts b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding.action.ts new file mode 100644 index 000000000..0ae79b9ae --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-catalog-to-stock-binding.action.ts @@ -0,0 +1,356 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug correct-catalog-to-stock-binding +import { createHash } from 'node:crypto'; + +import type { ActionHandlerContext, OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { defineAction, defineActionBusinessPermission, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { DateTime, Effect, Schema } from 'effect'; + +import { + CorrectCatalogToStockBindingErrorSchema, + CorrectCatalogToStockBindingPayloadSchema, + CorrectCatalogToStockBindingResultSchema, +} from '../../shared/actions/correct-catalog-to-stock-binding.ts'; +import type { CorrectCatalogToStockBindingPayload } from '../../shared/actions/correct-catalog-to-stock-binding.ts'; +import { + CatalogToStockBindingLifecycleEvidenceSchema, + CatalogToStockBindingRejected, + CatalogToStockBindingRevisionSchema, + CatalogToStockBindingSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- The Action composes the existing owner lifecycle inside Core's transaction-scoped service boundary; expires: 2027-03-31. + makeCatalogToStockBindingLifecycle, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import type { + CatalogToStockBinding, + CatalogToStockBindingPersistence, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import type { CatalogToStockBindingRef } from '../../shared/resources/catalog-to-stock-binding.ts'; +import { OutboxPayloadSchema as CommitmentProtectionChangedOutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts'; +import type { OutboxPayload as CommitmentProtectionChangedOutboxPayload } from '../../shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts'; +import { OutboxPayloadSchema as CommittedObligationChangedOutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-committed-obligation-changed-v1.ts'; +import type { OutboxPayload as CommittedObligationChangedOutboxPayload } from '../../shared/outbox/commerce-inventory-committed-obligation-changed-v1.ts'; +import { OutboxPayloadSchema as ReservationGuaranteeChangedOutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-reservation-guarantee-changed-v1.ts'; +import type { OutboxPayload as ReservationGuaranteeChangedOutboxPayload } from '../../shared/outbox/commerce-inventory-reservation-guarantee-changed-v1.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local repository constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeDrizzleCatalogToStockBindingPersistence } from '../persistence/catalog-to-stock-binding-repository.ts'; +import { bindingCorrectionImpactPersistenceForScope } from '../persistence/binding-correction-impact-repository.ts'; +import { serializeCatalogToStockBindingPersistence } from '../persistence/binding-correction-serialization.ts'; +import type { BindingCorrectionImpactOperations } from '../services/binding-correction-impact.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeBindingCorrectionImpactService } from '../services/binding-correction-impact.service.ts'; +import { createCorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxMessage } from './correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +import { createCorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxMessage } from './correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts'; +import { createCorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxMessage } from './correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts'; + +export { + CorrectCatalogToStockBindingErrorSchema, + CorrectCatalogToStockBindingPayloadSchema, + CorrectCatalogToStockBindingResultSchema, +} from '../../shared/actions/correct-catalog-to-stock-binding.ts'; +export type { CorrectCatalogToStockBindingPayload } from '../../shared/actions/correct-catalog-to-stock-binding.ts'; + +const ACTION_KEY = 'commerce.inventory.correct-catalog-to-stock-binding'; +const MODULE_KEY = 'commerce.inventory'; +const COMMITMENT_PROTECTION_CHANGED_EVENT = 'commerce.inventory.commitment-protection-changed.v1'; +const COMMITTED_OBLIGATION_CHANGED_EVENT = 'commerce.inventory.committed-obligation-changed.v1'; +const RESERVATION_GUARANTEE_CHANGED_EVENT = 'commerce.inventory.reservation-guarantee-changed.v1'; +const domainEvents = { + [COMMITMENT_PROTECTION_CHANGED_EVENT]: CommitmentProtectionChangedOutboxPayloadSchema, + [COMMITTED_OBLIGATION_CHANGED_EVENT]: CommittedObligationChangedOutboxPayloadSchema, + [RESERVATION_GUARANTEE_CHANGED_EVENT]: ReservationGuaranteeChangedOutboxPayloadSchema, +} as const; +type ScopedTransaction = Parameters>>>[0]; + +export interface CorrectCatalogToStockBindingServices { + readonly bindings: CatalogToStockBindingPersistence; + readonly impacts: BindingCorrectionImpactOperations; +} + +export const CorrectCatalogToStockBindingAuditEvidenceSchema = Schema.Struct({ + authority: CatalogToStockBindingLifecycleEvidenceSchema.fields.authority, + bindingRef: CatalogToStockBindingSchema.fields.bindingRef, + exactSelectionMeaning: CatalogToStockBindingSchema.fields.exactSelectionMeaning, + operation: Schema.Literal('CORRECTED'), + ownerEvidenceRef: CatalogToStockBindingLifecycleEvidenceSchema.fields.ownerEvidenceRef, + revision: CatalogToStockBindingRevisionSchema, + stockItemRef: CatalogToStockBindingSchema.fields.stockItemRef, + unitRef: CatalogToStockBindingSchema.fields.unitRef, +}); + +const sameBindingRef = (left: CatalogToStockBindingRef, right: CatalogToStockBindingRef): boolean => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const bindingCorrectionOccurrenceId = (...identity: readonly (number | string)[]): string => + createHash('sha256').update(identity.join('\u0000')).digest('hex'); + +const requireExactCurrentBinding = ( + persistence: CatalogToStockBindingPersistence, + payload: CorrectCatalogToStockBindingPayload, +) => + persistence + .findCurrentByExactSelectionMeaning( + payload.candidate.catalogSelection.productRef.tenantId, + payload.candidate.exactSelectionMeaning, + ) + .pipe( + Effect.flatMap((current): Effect.Effect => { + const [binding] = current; + if (binding === undefined) { + return Effect.fail( + new CatalogToStockBindingRejected({ + bindingRef: payload.bindingRef, + code: 'catalog_to_stock_binding_rejected', + reason: 'MISSING_BINDING', + }), + ); + } + if (current.length !== 1) { + return Effect.fail( + new CatalogToStockBindingRejected({ + bindingRef: payload.bindingRef, + code: 'catalog_to_stock_binding_rejected', + reason: 'MULTIPLE_CURRENT_BINDINGS', + }), + ); + } + return sameBindingRef(binding.bindingRef, payload.bindingRef) + ? Effect.succeed(binding) + : Effect.fail( + new CatalogToStockBindingRejected({ + bindingRef: binding.bindingRef, + code: 'catalog_to_stock_binding_rejected', + reason: 'BINDING_ID_CONFLICT', + stockItemRef: binding.stockItemRef, + }), + ); + }), + ); + +export const handleCorrectCatalogToStockBinding = Effect.fn('CorrectCatalogToStockBindingAction.handle')( + function* handle( + payload: CorrectCatalogToStockBindingPayload, + context: ActionHandlerContext, + ) { + const previousBinding = yield* requireExactCurrentBinding(context.services.bindings, payload); + const binding = yield* makeCatalogToStockBindingLifecycle(context.services.bindings, { + makeBindingId: () => payload.bindingRef.resourceId, + now: DateTime.now.pipe(Effect.map(DateTime.formatIso)), + }).correct({ candidate: payload.candidate, evidence: payload.evidence }); + const impact = yield* context.services.impacts.apply({ + correctedBinding: binding, + correctionEvidenceRef: payload.evidence.ownerEvidenceRef, + previousBinding, + }); + + yield* Effect.forEach( + impact.confirmationChanges, + (confirmation) => { + const eventPayload = { + ordering: { + _tag: 'IMMUTABLE_OCCURRENCE_IDENTITY' as const, + occurrenceId: bindingCorrectionOccurrenceId( + RESERVATION_GUARANTEE_CHANGED_EVENT, + binding.bindingRef.resourceId, + binding.revision, + confirmation.ref.resourceId, + confirmation.revision, + ), + }, + ownerReadOrProofKey: 'commerce.inventory.api.inventory-reservation-detail' as const, + state: 'AT_RISK' as const, + subjectRef: confirmation.reservation.ref, + } satisfies ReservationGuaranteeChangedOutboxPayload; + return context + .addDomainEvent({ + eventType: RESERVATION_GUARANTEE_CHANGED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: confirmation.reservation.ref.resourceId, + subjectResourceType: confirmation.reservation.ref.resourceType, + }) + .pipe( + Effect.flatMap((event) => + context.addOutboxMessage( + event, + createCorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxMessage( + eventPayload, + ), + ), + ), + ); + }, + { concurrency: 1, discard: true }, + ); + yield* Effect.forEach( + impact.protectionChanges, + (protection) => { + const eventPayload = { + ordering: { _tag: 'OWNER_AGGREGATE_REVISION' as const, revision: protection.revision }, + ownerReadOrProofKey: 'commerce.inventory.api.commitment-protection-verification' as const, + state: 'AT_RISK' as const, + subjectRef: protection.ref, + } satisfies CommitmentProtectionChangedOutboxPayload; + return context + .addDomainEvent({ + eventType: COMMITMENT_PROTECTION_CHANGED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: protection.ref.resourceId, + subjectResourceType: protection.ref.resourceType, + }) + .pipe( + Effect.flatMap((event) => + context.addOutboxMessage( + event, + createCorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxMessage( + eventPayload, + ), + ), + ), + ); + }, + { concurrency: 1, discard: true }, + ); + yield* Effect.forEach( + impact.committedReconciliationChanges, + (debt) => { + const subjectRef = { + moduleId: MODULE_KEY, + resourceId: debt.obligationId, + resourceType: debt.subjectResourceType, + tenantId: debt.tenantId, + } as const; + const eventPayload = { + ordering: { + _tag: 'IMMUTABLE_OCCURRENCE_IDENTITY' as const, + occurrenceId: bindingCorrectionOccurrenceId( + COMMITTED_OBLIGATION_CHANGED_EVENT, + debt.bindingId, + debt.bindingRevision, + debt.obligationId, + debt.purchaseDemandOccurrenceId, + ), + }, + ownerReadOrProofKey: 'commerce.inventory.api.inventory-reconciliation-evidence' as const, + state: 'RECONCILIATION_REQUIRED' as const, + subjectRef, + } satisfies CommittedObligationChangedOutboxPayload; + return context + .addDomainEvent({ + eventType: COMMITTED_OBLIGATION_CHANGED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: subjectRef.resourceId, + subjectResourceType: subjectRef.resourceType, + }) + .pipe( + Effect.flatMap((event) => + context.addOutboxMessage( + event, + createCorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxMessage( + eventPayload, + ), + ), + ), + ); + }, + { concurrency: 1, discard: true }, + ); + + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `catalog-to-stock-binding:correct:${payload.bindingRef.resourceId}:${binding.revision}`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: binding.bindingRef.resourceId, + targetResourceType: binding.bindingRef.resourceType, + }); + yield* context.recordAuditEvidence({ + authority: payload.evidence.authority, + bindingRef: binding.bindingRef, + exactSelectionMeaning: binding.exactSelectionMeaning, + operation: 'CORRECTED', + ownerEvidenceRef: payload.evidence.ownerEvidenceRef, + revision: binding.revision, + stockItemRef: binding.stockItemRef, + unitRef: binding.unitRef, + }); + return binding; + }, +); + +export const makeCorrectCatalogToStockBindingServices = (transaction: ScopedTransaction, scope: OperationalScope) => { + const bindings = serializeCatalogToStockBindingPersistence( + transaction, + makeDrizzleCatalogToStockBindingPersistence(transaction), + ); + return Effect.succeed({ + bindings, + impacts: makeBindingCorrectionImpactService(bindingCorrectionImpactPersistenceForScope(transaction, scope)), + }); +}; + +export const correctCatalogToStockBindingAction = defineAction( + { + accessEvidencePolicy: { captureMode: 'metadata_only', policyKey: `${ACTION_KEY}.access.v1` }, + actionKey: ACTION_KEY, + auditEvidenceSchema: CorrectCatalogToStockBindingAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.catalog_to_stock_binding.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.bindingRef.moduleId, + resourceId: payload.bindingRef.resourceId, + resourceType: payload.bindingRef.resourceType, + }, + tenantId: payload.bindingRef.tenantId, + }, + })), + domainErrorSchema: CorrectCatalogToStockBindingErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: CorrectCatalogToStockBindingPayloadSchema, + policies: [], + resultSchema: CorrectCatalogToStockBindingResultSchema, + schemaVersion: '1', + }, + handleCorrectCatalogToStockBinding, + makeCorrectCatalogToStockBindingServices, +); + +// +export { CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxPayloadSchema } from './correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxProducerModuleKey } from './correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxTopic } from './correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxPayloadSchema } from './correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxProducerModuleKey } from './correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxTopic } from './correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxPayloadSchema } from './correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxProducerModuleKey } from './correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts'; +export { CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxTopic } from './correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts'; +export { createCorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxMessage } from './correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { createCorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxMessage } from './correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts'; +export { createCorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxMessage } from './correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts'; +export type { CorrectCatalogToStockBindingCommerceInventoryCommitmentProtectionChangedV1OutboxPayload } from './correct-catalog-to-stock-binding-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export type { CorrectCatalogToStockBindingCommerceInventoryCommittedObligationChangedV1OutboxPayload } from './correct-catalog-to-stock-binding-commerce-inventory-committed-obligation-changed-v1.outbox-message.ts'; +export type { CorrectCatalogToStockBindingCommerceInventoryReservationGuaranteeChangedV1OutboxPayload } from './correct-catalog-to-stock-binding-commerce-inventory-reservation-guarantee-changed-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/actions/correct-external-stock-correlation.action.ts b/app/verticals/inventory/src/actions/correct-external-stock-correlation.action.ts new file mode 100644 index 000000000..58ddf87a6 --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-external-stock-correlation.action.ts @@ -0,0 +1,157 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug correct-external-stock-correlation +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; + +import { + CorrectExternalStockCorrelationErrorSchema, + CorrectExternalStockCorrelationPayloadSchema, + CorrectExternalStockCorrelationResultSchema, +} from '../../shared/actions/correct-external-stock-correlation.ts'; +import type { CorrectExternalStockCorrelationPayload } from '../../shared/actions/correct-external-stock-correlation.ts'; +import { + ExternalStockCorrelationInstantSchema, + ExternalStockTargetSchema, + InventoryBackendOriginSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- This Action composes the owner-local pure lifecycle with transaction-scoped persistence; expires: 2027-03-31. + makeExternalStockCorrelationLifecycle, +} from '../../shared/domain/external-stock-correlation.ts'; +import type { ExternalStockCorrelationPersistence } from '../../shared/domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationRejected } from '../../shared/domain/external-stock-correlation-rejected.ts'; +import { CustomerConfigurationIdSchema } from '../../shared/inventory-launch-scope.ts'; +import { ExternalStockCorrelationRefSchema } from '../../shared/resources/external-stock-correlation.ts'; +import { externalStockCorrelationPersistenceForScope } from '../persistence/external-stock-correlation-repository.ts'; + +export { + CorrectExternalStockCorrelationErrorSchema, + CorrectExternalStockCorrelationPayloadSchema, + CorrectExternalStockCorrelationResultSchema, +} from '../../shared/actions/correct-external-stock-correlation.ts'; + +const ACTION_KEY = 'commerce.inventory.correct-external-stock-correlation'; +const MODULE_KEY = 'commerce.inventory'; +const MANAGE_PERMISSION = 'inventory.external_stock_correlation.manage'; +const domainEvents = {} as const; + +export const CorrectExternalStockCorrelationAuditEvidenceSchema = Schema.Struct({ + correlationRef: ExternalStockCorrelationRefSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + effectiveAt: ExternalStockCorrelationInstantSchema, + issuer: InventoryBackendOriginSchema, + operation: Schema.Literal('CORRECTED'), + ownerEvidenceRef: CorrectExternalStockCorrelationPayloadSchema.fields.ownerEvidenceRef, + target: ExternalStockTargetSchema, +}); + +const tenantMismatch = (payload: CorrectExternalStockCorrelationPayload, tenantId: string): boolean => + payload.replacementCorrelationRef.tenantId !== tenantId || + payload.externalKey.tenantId !== tenantId || + payload.target.ref.tenantId !== tenantId; + +export const handleCorrectExternalStockCorrelation = Effect.fn('CorrectExternalStockCorrelationAction.handle')( + function* handle( + payload: CorrectExternalStockCorrelationPayload, + context: ActionHandlerContext, + ) { + if (tenantMismatch(payload, context.scope.tenantId)) { + return yield* new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef: payload.replacementCorrelationRef, + reason: 'TENANT_SCOPE_MISMATCH', + }); + } + const correlation = yield* makeExternalStockCorrelationLifecycle(context.services, { + makeCorrelationId: () => payload.replacementCorrelationRef.resourceId, + }).correct({ + correctedAt: payload.correctedAt, + externalKey: payload.externalKey, + ownerEvidenceRef: payload.ownerEvidenceRef, + target: payload.target, + }); + if ( + correlation.correlationRef.tenantId !== payload.replacementCorrelationRef.tenantId || + correlation.correlationRef.resourceId !== payload.replacementCorrelationRef.resourceId + ) { + return yield* new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef: payload.replacementCorrelationRef, + reason: 'CORRELATION_IDENTITY_CONFLICT', + }); + } + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `external-stock-correlation:correct:${payload.replacementCorrelationRef.resourceId}`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.replacementCorrelationRef.resourceId, + targetResourceType: payload.replacementCorrelationRef.resourceType, + }); + yield* context.recordAuditEvidence({ + correlationRef: correlation.correlationRef, + customerConfigurationId: correlation.externalKey.customerConfigurationId, + effectiveAt: correlation.effectivePeriod.from, + issuer: correlation.externalKey.issuer, + operation: 'CORRECTED', + ownerEvidenceRef: correlation.ownerEvidenceRef, + target: correlation.target, + }); + return { correlation }; + }, +); + +export const correctExternalStockCorrelationAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: CorrectExternalStockCorrelationAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: MANAGE_PERMISSION, + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.replacementCorrelationRef.moduleId, + resourceId: payload.replacementCorrelationRef.resourceId, + resourceType: payload.replacementCorrelationRef.resourceType, + }, + tenantId: tenantMismatch(payload, scope.tenantId) ? '' : scope.tenantId, + }, + })), + domainErrorSchema: CorrectExternalStockCorrelationErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: CorrectExternalStockCorrelationPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.replacementCorrelationRef, + })), + resultSchema: CorrectExternalStockCorrelationResultSchema, + schemaVersion: '1', + }, + handleCorrectExternalStockCorrelation, + (transaction, scope) => Effect.succeed(externalStockCorrelationPersistenceForScope(transaction, scope)), +); + +// +// diff --git a/app/verticals/inventory/src/actions/correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts b/app/verticals/inventory/src/actions/correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts new file mode 100644 index 000000000..f1751313a --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.correct-stock-position +// @ontos-outbox-topic commerce.inventory.stock-position-evidence-changed.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-stock-position-evidence-changed-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-stock-position-evidence-changed-v1'; + +export { + OutboxPayloadSchema as CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxPayloadSchema, + outboxProducerModuleKey as CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxProducerModuleKey, + outboxTopic as CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-stock-position-evidence-changed-v1'; +export type { OutboxPayload as CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-stock-position-evidence-changed-v1'; + +export const createCorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/correct-stock-position.action.ts b/app/verticals/inventory/src/actions/correct-stock-position.action.ts new file mode 100644 index 000000000..6086911e1 --- /dev/null +++ b/app/verticals/inventory/src/actions/correct-stock-position.action.ts @@ -0,0 +1,220 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug correct-stock-position +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Match, Schema } from 'effect'; + +import { + CorrectStockPositionErrorSchema, + CorrectStockPositionPayloadSchema, + CorrectStockPositionResultSchema, +} from '../../shared/actions/correct-stock-position.ts'; +import { InventorySourceAssertionIdSchema } from '../../shared/domain/inventory-source-assertion.ts'; +import { InventoryBackendIdSchema } from '../../shared/domain/inventory-backend-identifiers.ts'; +import { + StockCorrectionIdSchema, + StockCorrectionRecordSchema, + StockCorrectionSourceEvidenceIdSchema, +} from '../../shared/domain/stock-correction.ts'; +import { OutboxPayloadSchema as StockPositionEvidenceChangedOutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-stock-position-evidence-changed-v1.ts'; +import type { OutboxPayload as StockPositionEvidenceChangedOutboxPayload } from '../../shared/outbox/commerce-inventory-stock-position-evidence-changed-v1.ts'; +import { InventoryBackendConfigurationRefSchema } from '../../shared/resources/inventory-backend-configuration.ts'; +import { StockPositionRefSchema } from '../../shared/resources/stock-position.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { inventorySourceAssertionPersistenceForScope } from '../persistence/inventory-source-assertion-repository.ts'; +import { inventorySourceImportLedgerPersistenceForScope } from '../persistence/inventory-source-import-ledger-repository.ts'; +import { reservationShortageImpactPersistenceForScope } from '../persistence/reservation-shortage-impact-repository.ts'; +import { stockCorrectionSourceEvidencePersistenceForScope } from '../persistence/stock-correction-source-evidence-repository.ts'; +import { stockCorrectionPersistenceForScope } from '../persistence/stock-correction-repository.ts'; +import { stockPositionPersistenceForScope } from '../persistence/stock-position-repository.ts'; +import type { StockCorrectionService } from '../services/stock-correction.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeStockCorrectionService } from '../services/stock-correction.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- This owner-local constructor is bound inside the same generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeReservationShortageImpactService } from '../services/reservation-shortage-impact.service.ts'; +import { createCorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxMessage } from './correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts'; + +export { + CorrectStockPositionErrorSchema, + CorrectStockPositionPayloadSchema, + CorrectStockPositionResultSchema, +} from '../../shared/actions/correct-stock-position.ts'; + +const ACTION_KEY = 'commerce.inventory.correct-stock-position'; +const MODULE_KEY = 'commerce.inventory'; +const APPLIED_EVENT = 'commerce.inventory.stock-position-corrected.v1'; +const INDETERMINATE_EVENT = 'commerce.inventory.stock-position-correction-indeterminate.v1'; +const STOCK_POSITION_EVIDENCE_CHANGED_EVENT = 'commerce.inventory.stock-position-evidence-changed.v1'; +const correctionEventPayloadSchema = Schema.Struct({ correction: StockCorrectionRecordSchema }); +export const CorrectStockPositionAuditEvidenceSchema = Schema.Struct({ + authorityConfigurationId: InventoryBackendConfigurationRefSchema.fields.resourceId, + businessReasonCode: Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(100)), + businessReasonReference: Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)), + correctionId: StockCorrectionIdSchema, + evidenceIdentity: Schema.Union([InventorySourceAssertionIdSchema, StockCorrectionSourceEvidenceIdSchema]), + evidenceKind: Schema.Literals(['EXTERNAL_SOURCE_ASSERTION', 'ONTOS_WMS_OWNER_EVIDENCE']), + issuerBackendId: InventoryBackendIdSchema, + issuerBackendKind: Schema.Literals(['external_business_system', 'ontos_wms']), + outcome: Schema.Literals(['APPLIED', 'EXACT_REPLAY', 'RECONCILIATION_REQUIRED']), + ownerEvidenceRef: Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)), + positionId: StockPositionRefSchema.fields.resourceId, + sourceReference: Schema.String.check(Schema.isTrimmed(), Schema.isMinLength(1), Schema.isMaxLength(300)), +}); +const domainEvents = { + [APPLIED_EVENT]: correctionEventPayloadSchema, + [INDETERMINATE_EVENT]: correctionEventPayloadSchema, + [STOCK_POSITION_EVIDENCE_CHANGED_EVENT]: StockPositionEvidenceChangedOutboxPayloadSchema, +} as const; + +export const handleCorrectStockPosition = Effect.fn('CorrectStockPositionAction.handle')(function* handle( + payload: typeof CorrectStockPositionPayloadSchema.Type, + context: ActionHandlerContext, +) { + const result = yield* context.services.correct(payload, { + actionInvocationId: context.actionInvocationId, + principalId: context.scope.principalId, + tenantId: context.scope.tenantId, + }); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `stock-correction:${payload.correctionId}`, + resultCount: result.outcome === 'EXACT_REPLAY' ? 1 : 0, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.positionRef.resourceId, + targetResourceType: payload.positionRef.resourceType, + }); + if (result.outcome !== 'EXACT_REPLAY') { + const eventType: typeof APPLIED_EVENT | typeof INDETERMINATE_EVENT = Match.value(result.correction).pipe( + Match.tag('APPLIED', (): typeof APPLIED_EVENT => APPLIED_EVENT), + Match.tag('INDETERMINATE', (): typeof INDETERMINATE_EVENT => INDETERMINATE_EVENT), + Match.exhaustive, + ); + yield* context.addDomainEvent({ + eventType, + payloadJson: { correction: result.correction }, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: payload.positionRef.resourceId, + subjectResourceType: payload.positionRef.resourceType, + }); + const isMaterialEvidenceChange = Match.value(result.correction).pipe( + Match.tag('INDETERMINATE', () => true), + Match.tag('APPLIED', (correction) => correction.materialChange !== 'UNCHANGED'), + Match.exhaustive, + ); + if (isMaterialEvidenceChange) { + const state = Match.value(result.correction).pipe( + Match.tag('APPLIED', () => 'CORRECTED' as const), + Match.tag('INDETERMINATE', () => 'INDETERMINATE' as const), + Match.exhaustive, + ); + const eventPayload = { + ordering: { _tag: 'OWNER_AGGREGATE_REVISION' as const, revision: result.position.revision }, + ownerReadOrProofKey: 'commerce.inventory.api.current-stock-evidence-for-availability' as const, + state, + subjectRef: result.position.ref, + } satisfies StockPositionEvidenceChangedOutboxPayload; + const committedEvent = yield* context.addDomainEvent({ + eventType: STOCK_POSITION_EVIDENCE_CHANGED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: result.position.ref.resourceId, + subjectResourceType: result.position.ref.resourceType, + }); + yield* context.addOutboxMessage( + committedEvent, + createCorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxMessage(eventPayload), + ); + } + } + yield* context.recordAuditEvidence({ + authorityConfigurationId: result.correction.authorityConfigurationRef.resourceId, + businessReasonCode: result.correction.reason.code, + businessReasonReference: result.correction.reason.reference, + correctionId: result.correction.correctionId, + evidenceIdentity: result.correction.sourceAssertionId ?? result.correction.sourceEvidenceId, + evidenceKind: result.correction.evidenceKind, + issuerBackendId: result.correction.issuer.backendId, + issuerBackendKind: result.correction.issuer.backendKind, + outcome: result.outcome, + ownerEvidenceRef: result.correction.ownerEvidenceRef, + positionId: result.correction.positionRef.resourceId, + sourceReference: result.correction.sourceReference, + }); + return result; +}); + +export const correctStockPositionAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.correct-stock-position.access.v1', + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: CorrectStockPositionAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.stock.correct', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.positionRef.moduleId, + resourceId: payload.positionRef.resourceId, + resourceType: payload.positionRef.resourceType, + }, + tenantId: payload.positionRef.tenantId, + }, + })), + domainErrorSchema: CorrectStockPositionErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: CorrectStockPositionPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.positionRef, + })), + resultSchema: CorrectStockPositionResultSchema, + schemaVersion: '1', + }, + handleCorrectStockPosition, + (transaction, scope) => + Effect.succeed( + makeStockCorrectionService({ + assertions: inventorySourceAssertionPersistenceForScope(transaction, scope), + backendConfigurations: inventoryBackendConfigurationPersistenceForScope(transaction, scope), + corrections: stockCorrectionPersistenceForScope(transaction, scope), + impacts: makeReservationShortageImpactService({ + persistence: reservationShortageImpactPersistenceForScope(transaction, scope), + }), + positions: stockPositionPersistenceForScope(transaction, scope), + sourceEvidence: stockCorrectionSourceEvidencePersistenceForScope(transaction, scope), + sourceImports: inventorySourceImportLedgerPersistenceForScope(transaction, scope), + }), + ), +); + +// +export { CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxPayloadSchema } from './correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts'; +export { CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxProducerModuleKey } from './correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts'; +export { CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxTopic } from './correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts'; +export { createCorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxMessage } from './correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts'; +export type { CorrectStockPositionCommerceInventoryStockPositionEvidenceChangedV1OutboxPayload } from './correct-stock-position-commerce-inventory-stock-position-evidence-changed-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/actions/create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts b/app/verticals/inventory/src/actions/create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts new file mode 100644 index 000000000..9e130feb8 --- /dev/null +++ b/app/verticals/inventory/src/actions/create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.create-inventory-reservation +// @ontos-outbox-topic commerce.inventory.inventory-reservation-create-requested.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-inventory-reservation-create-requested-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-inventory-reservation-create-requested-v1'; + +export { + OutboxPayloadSchema as CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxPayloadSchema, + outboxProducerModuleKey as CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxProducerModuleKey, + outboxTopic as CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-inventory-reservation-create-requested-v1'; +export type { OutboxPayload as CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-inventory-reservation-create-requested-v1'; + +export const createCreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts b/app/verticals/inventory/src/actions/create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts new file mode 100644 index 000000000..729636a88 --- /dev/null +++ b/app/verticals/inventory/src/actions/create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts @@ -0,0 +1,23 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.create-inventory-reservation +// @ontos-outbox-topic commerce.inventory.reservation-confirmation-issuance-requested.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1'; + +export { + OutboxPayloadSchema as CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxPayloadSchema, + outboxProducerModuleKey as CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxProducerModuleKey, + outboxTopic as CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1'; +export type { OutboxPayload as CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1'; + +export const createCreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxMessage = + (payload: OutboxPayload): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, + }); diff --git a/app/verticals/inventory/src/actions/create-inventory-reservation.action.ts b/app/verticals/inventory/src/actions/create-inventory-reservation.action.ts new file mode 100644 index 000000000..ac6102ab2 --- /dev/null +++ b/app/verticals/inventory/src/actions/create-inventory-reservation.action.ts @@ -0,0 +1,195 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug create-inventory-reservation +/* oxlint-disable anti-slop-effect/no-service-constructor-imports -- The generated Action factory constructs owner-local services and repositories inside its transaction scope; expires: 2027-03-31. */ +import { createHash, randomUUID } from 'node:crypto'; + +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect } from 'effect'; + +import { makeCatalogToStockBindingResolver } from '../../shared/domain/catalog-to-stock-binding.ts'; +import { + CreateInventoryReservationErrorSchema, + CreateInventoryReservationPayloadSchema, + CreateInventoryReservationResultSchema, +} from '../../shared/actions/create-inventory-reservation.ts'; +import type { CreateInventoryReservationPayload } from '../../shared/actions/create-inventory-reservation.ts'; +import { + InventoryReservationCreateMutationIdSchema, + InventoryReservationCreateRejected, +} from '../../shared/domain/inventory-reservation-create.ts'; +import { StockAllocationIdSchema } from '../../shared/domain/inventory-obligation.ts'; +import { CatalogToStockBindingUnavailable } from '../../shared/domain/catalog-to-stock-binding-unavailable.ts'; +import { OutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-inventory-reservation-create-requested-v1.ts'; +import { + catalogToStockBindingStockItemReader, + makeDrizzleCatalogToStockBindingPersistence, +} from '../persistence/catalog-to-stock-binding-repository.ts'; +import { lockBindingCorrectionScopes } from '../persistence/binding-correction-serialization.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { + reservationAllocationCandidateReaderForScope, + reservationPositionEligibilityForScope, +} from '../persistence/reservation-allocation-candidate-repository.ts'; +import { reservationCreateEffectPersistenceForScope } from '../persistence/reservation-create-effect-repository.ts'; +import { makeDrizzleStockItemRepository } from '../persistence/stock-item-repository.ts'; +import { InventoryReservationCommerceContextAuthorityPort } from '../services/inventory-reservation-commerce-context.ts'; +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +import type { InventoryReservationCreateService } from '../services/inventory-reservation-create.service.ts'; +import { makeInventoryReservationCreateService } from '../services/inventory-reservation-create.service.ts'; +import { createCreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxMessage as createOutboxMessage } from './create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts'; + +export { + CreateInventoryReservationErrorSchema, + CreateInventoryReservationPayloadSchema, + CreateInventoryReservationResultSchema, +} from '../../shared/actions/create-inventory-reservation.ts'; + +const ACTION_KEY = 'commerce.inventory.create-inventory-reservation'; +const MODULE_KEY = 'commerce.inventory'; +const REQUESTED_EVENT = 'commerce.inventory.inventory-reservation-create-requested.v1'; +const domainEvents = { + [REQUESTED_EVENT]: OutboxPayloadSchema, +} as const; + +export const handleCreateInventoryReservation = Effect.fn('CreateInventoryReservationAction.handle')(function* handle( + payload: CreateInventoryReservationPayload, + context: ActionHandlerContext, +) { + if (context.scope.legalEntityId === undefined) { + return yield* new InventoryReservationCreateRejected({ + code: 'inventory_reservation_create_rejected', + effectId: payload.effectId, + reason: 'TENANT_SCOPE_MISMATCH', + }); + } + const decision = yield* context.services.create(payload, { + actionInvocationId: context.actionInvocationId, + legalEntityId: context.scope.legalEntityId, + tenantId: context.scope.tenantId, + trustedStorefrontId: context.scope.trustedStorefrontId, + }); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-reservation-create:${payload.effectId}`, + resultCount: decision.dispatchRequested ? 0 : 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.reservationRef.resourceId, + targetResourceType: payload.reservationRef.resourceType, + }); + if (decision.dispatchRequested) { + const eventPayload = { request: decision.result.effect.request }; + const event = yield* context.addDomainEvent({ + eventType: REQUESTED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: payload.reservationRef.resourceId, + subjectResourceType: payload.reservationRef.resourceType, + }); + yield* context.addOutboxMessage(event, createOutboxMessage(eventPayload)); + } + return decision.result; +}); + +export const createInventoryReservationAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.reservation.establish', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.reservationRef.moduleId, + resourceId: payload.reservationRef.resourceId, + resourceType: payload.reservationRef.resourceType, + }, + tenantId: payload.reservationRef.tenantId, + }, + })), + domainErrorSchema: CreateInventoryReservationErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'tenant_membership_default' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: CreateInventoryReservationPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.reservationRef, + })), + resultSchema: CreateInventoryReservationResultSchema, + schemaVersion: '1', + }, + handleCreateInventoryReservation, + (transaction, scope) => + InventoryReservationCommerceContextAuthorityPort.pipe( + Effect.map((commerceContexts) => + makeInventoryReservationCreateService({ + backendConfigurations: inventoryBackendConfigurationPersistenceForScope(transaction, scope), + candidates: reservationAllocationCandidateReaderForScope(transaction, scope), + commerceContexts, + effects: reservationCreateEffectPersistenceForScope(transaction, scope), + eligibility: reservationPositionEligibilityForScope(transaction, scope), + ledger: makeInventoryEffectLedgerService( + inventoryEffectLedgerPersistenceForScope(transaction, scope), + DateTime.now.pipe(Effect.map(DateTime.formatIso)), + ), + lockBindingScopes: (scopes) => + lockBindingCorrectionScopes(transaction, scopes).pipe( + Effect.mapError( + (cause) => + new CatalogToStockBindingUnavailable({ + code: 'catalog_to_stock_binding_unavailable', + reason: `Unable to serialize Catalog-to-Stock Binding resolution: ${String(cause)}`, + }), + ), + ), + makeAllocationId: ({ effectId, positionId, purchaseDemandOccurrenceId }) => + StockAllocationIdSchema.make( + createHash('sha256') + .update(`${effectId}\u0000${purchaseDemandOccurrenceId}\u0000${positionId}`) + .digest('hex'), + ), + makeMutationId: () => InventoryReservationCreateMutationIdSchema.make(randomUUID()), + resolver: makeCatalogToStockBindingResolver( + makeDrizzleCatalogToStockBindingPersistence(transaction), + catalogToStockBindingStockItemReader(makeDrizzleStockItemRepository(transaction)), + ), + }), + ), + ), +); + +// +export { createCreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxMessage } from './create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts'; +export { createCreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxMessage } from './create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts'; +export { CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxPayloadSchema } from './create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts'; +export { CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxProducerModuleKey } from './create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts'; +export { CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxTopic } from './create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts'; +export { CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxPayloadSchema } from './create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts'; +export { CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxProducerModuleKey } from './create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts'; +export { CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxTopic } from './create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts'; +export type { CreateInventoryReservationCommerceInventoryInventoryReservationCreateRequestedV1OutboxPayload } from './create-inventory-reservation-commerce-inventory-inventory-reservation-create-requested-v1.outbox-message.ts'; +export type { CreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxPayload } from './create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/actions/end-catalog-to-stock-binding.action.ts b/app/verticals/inventory/src/actions/end-catalog-to-stock-binding.action.ts new file mode 100644 index 000000000..7b80408f1 --- /dev/null +++ b/app/verticals/inventory/src/actions/end-catalog-to-stock-binding.action.ts @@ -0,0 +1,134 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug end-catalog-to-stock-binding +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect, Schema } from 'effect'; + +import { + EndCatalogToStockBindingErrorSchema, + EndCatalogToStockBindingPayloadSchema, + EndCatalogToStockBindingResultSchema, +} from '../../shared/actions/end-catalog-to-stock-binding.ts'; +import type { EndCatalogToStockBindingPayload } from '../../shared/actions/end-catalog-to-stock-binding.ts'; +import { + CatalogToStockBindingLifecycleEvidenceSchema, + CatalogToStockBindingRevisionSchema, + CatalogToStockBindingSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- The Action composes the existing owner lifecycle inside Core's transaction-scoped service boundary; expires: 2027-03-31. + makeCatalogToStockBindingLifecycle, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import type { CatalogToStockBindingPersistence } from '../../shared/domain/catalog-to-stock-binding.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local repository constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeDrizzleCatalogToStockBindingPersistence } from '../persistence/catalog-to-stock-binding-repository.ts'; +import { serializeCatalogToStockBindingPersistence } from '../persistence/binding-correction-serialization.ts'; + +export { + EndCatalogToStockBindingErrorSchema, + EndCatalogToStockBindingPayloadSchema, + EndCatalogToStockBindingResultSchema, +} from '../../shared/actions/end-catalog-to-stock-binding.ts'; +export type { EndCatalogToStockBindingPayload } from '../../shared/actions/end-catalog-to-stock-binding.ts'; + +const ACTION_KEY = 'commerce.inventory.end-catalog-to-stock-binding'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = {} as const; + +export const EndCatalogToStockBindingAuditEvidenceSchema = Schema.Struct({ + authority: CatalogToStockBindingLifecycleEvidenceSchema.fields.authority, + bindingRef: CatalogToStockBindingSchema.fields.bindingRef, + disposition: EndCatalogToStockBindingPayloadSchema.fields.disposition, + exactSelectionMeaning: CatalogToStockBindingSchema.fields.exactSelectionMeaning, + operation: Schema.Literal('ENDED'), + ownerEvidenceRef: CatalogToStockBindingLifecycleEvidenceSchema.fields.ownerEvidenceRef, + revision: CatalogToStockBindingRevisionSchema, + stockItemRef: CatalogToStockBindingSchema.fields.stockItemRef, + unitRef: CatalogToStockBindingSchema.fields.unitRef, +}); + +export const handleEndCatalogToStockBinding = Effect.fn('EndCatalogToStockBindingAction.handle')(function* handle( + payload: EndCatalogToStockBindingPayload, + context: ActionHandlerContext, +) { + const result = yield* makeCatalogToStockBindingLifecycle(context.services, { + makeBindingId: () => payload.bindingRef.resourceId, + now: DateTime.now.pipe(Effect.map(DateTime.formatIso)), + }).end(payload); + const { binding } = result.historyEntry; + + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `catalog-to-stock-binding:end:${payload.bindingRef.resourceId}:${binding.revision}`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: binding.bindingRef.resourceId, + targetResourceType: binding.bindingRef.resourceType, + }); + yield* context.recordAuditEvidence({ + authority: payload.evidence.authority, + bindingRef: binding.bindingRef, + disposition: result.disposition, + exactSelectionMeaning: binding.exactSelectionMeaning, + operation: 'ENDED', + ownerEvidenceRef: payload.evidence.ownerEvidenceRef, + revision: binding.revision, + stockItemRef: binding.stockItemRef, + unitRef: binding.unitRef, + }); + return result; +}); + +export const endCatalogToStockBindingAction = defineAction( + { + accessEvidencePolicy: { captureMode: 'metadata_only', policyKey: `${ACTION_KEY}.access.v1` }, + actionKey: ACTION_KEY, + auditEvidenceSchema: EndCatalogToStockBindingAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.catalog_to_stock_binding.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.bindingRef.moduleId, + resourceId: payload.bindingRef.resourceId, + resourceType: payload.bindingRef.resourceType, + }, + tenantId: payload.bindingRef.tenantId, + }, + })), + domainErrorSchema: EndCatalogToStockBindingErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: EndCatalogToStockBindingPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.bindingRef, + })), + resultSchema: EndCatalogToStockBindingResultSchema, + schemaVersion: '1', + }, + handleEndCatalogToStockBinding, + (transaction) => + Effect.succeed( + serializeCatalogToStockBindingPersistence(transaction, makeDrizzleCatalogToStockBindingPersistence(transaction)), + ), +); + +// +// diff --git a/app/verticals/inventory/src/actions/end-external-stock-correlation.action.ts b/app/verticals/inventory/src/actions/end-external-stock-correlation.action.ts new file mode 100644 index 000000000..e7efd112e --- /dev/null +++ b/app/verticals/inventory/src/actions/end-external-stock-correlation.action.ts @@ -0,0 +1,184 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug end-external-stock-correlation +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Option, Schema } from 'effect'; + +import { + EndExternalStockCorrelationErrorSchema, + EndExternalStockCorrelationPayloadSchema, + EndExternalStockCorrelationResultSchema, +} from '../../shared/actions/end-external-stock-correlation.ts'; +import type { EndExternalStockCorrelationPayload } from '../../shared/actions/end-external-stock-correlation.ts'; +import { + ExternalStockCorrelationInstantSchema, + ExternalStockTargetSchema, + InventoryBackendOriginSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- This Action composes the owner-local pure lifecycle with transaction-scoped persistence; expires: 2027-03-31. + makeExternalStockCorrelationLifecycle, +} from '../../shared/domain/external-stock-correlation.ts'; +import type { + ExternalStockCorrelationPersistence, + ExternalStockKey, +} from '../../shared/domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationRejected } from '../../shared/domain/external-stock-correlation-rejected.ts'; +import { CustomerConfigurationIdSchema } from '../../shared/inventory-launch-scope.ts'; +import { ExternalStockCorrelationRefSchema } from '../../shared/resources/external-stock-correlation.ts'; +import { externalStockCorrelationPersistenceForScope } from '../persistence/external-stock-correlation-repository.ts'; + +export { + EndExternalStockCorrelationErrorSchema, + EndExternalStockCorrelationPayloadSchema, + EndExternalStockCorrelationResultSchema, +} from '../../shared/actions/end-external-stock-correlation.ts'; + +const ACTION_KEY = 'commerce.inventory.end-external-stock-correlation'; +const MODULE_KEY = 'commerce.inventory'; +const MANAGE_PERMISSION = 'inventory.external_stock_correlation.manage'; +const domainEvents = {} as const; + +export const EndExternalStockCorrelationAuditEvidenceSchema = Schema.Struct({ + correlationRef: ExternalStockCorrelationRefSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + effectiveAt: ExternalStockCorrelationInstantSchema, + issuer: InventoryBackendOriginSchema, + operation: Schema.Literal('ENDED'), + ownerEvidenceRef: EndExternalStockCorrelationResultSchema.fields.correlation.fields.ownerEvidenceRef, + target: ExternalStockTargetSchema, +}); + +const sameExternalKey = (left: ExternalStockKey, right: ExternalStockKey): boolean => + left.tenantId === right.tenantId && + left.customerConfigurationId === right.customerConfigurationId && + left.issuer.backendKind === right.issuer.backendKind && + left.issuer.backendId === right.issuer.backendId && + left.namespace === right.namespace && + left.externalScope === right.externalScope && + left.identifierKind === right.identifierKind && + left.externalValue === right.externalValue; + +const tenantMismatch = (payload: EndExternalStockCorrelationPayload, tenantId: string): boolean => + payload.correlationRef.tenantId !== tenantId || payload.externalKey.tenantId !== tenantId; + +const reject = ( + reason: + | 'CORRELATION_IDENTITY_CONFLICT' + | 'CORRELATION_NOT_CURRENT' + | 'CORRELATION_NOT_FOUND' + | 'TENANT_SCOPE_MISMATCH', + correlationRef: EndExternalStockCorrelationPayload['correlationRef'], +) => + new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef, + reason, + }); + +export const handleEndExternalStockCorrelation = Effect.fn('EndExternalStockCorrelationAction.handle')(function* handle( + payload: EndExternalStockCorrelationPayload, + context: ActionHandlerContext, +) { + if (tenantMismatch(payload, context.scope.tenantId)) { + return yield* reject('TENANT_SCOPE_MISMATCH', payload.correlationRef); + } + const current = yield* context.services.findByRef(payload.correlationRef).pipe( + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(reject('CORRELATION_NOT_FOUND', payload.correlationRef)), + onSome: Effect.succeed, + }), + ), + ); + if (!sameExternalKey(current.externalKey, payload.externalKey)) { + return yield* reject('CORRELATION_NOT_FOUND', payload.correlationRef); + } + if (current.lifecycle !== 'CURRENT') { + return yield* reject('CORRELATION_NOT_CURRENT', payload.correlationRef); + } + const correlation = yield* makeExternalStockCorrelationLifecycle(context.services, { + makeCorrelationId: () => payload.correlationRef.resourceId, + }).end({ + endedAt: payload.endedAt, + externalKey: payload.externalKey, + }); + if ( + correlation.correlationRef.tenantId !== payload.correlationRef.tenantId || + correlation.correlationRef.resourceId !== payload.correlationRef.resourceId + ) { + return yield* reject('CORRELATION_IDENTITY_CONFLICT', payload.correlationRef); + } + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `external-stock-correlation:end:${payload.correlationRef.resourceId}`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.correlationRef.resourceId, + targetResourceType: payload.correlationRef.resourceType, + }); + yield* context.recordAuditEvidence({ + correlationRef: correlation.correlationRef, + customerConfigurationId: correlation.externalKey.customerConfigurationId, + effectiveAt: payload.endedAt, + issuer: correlation.externalKey.issuer, + operation: 'ENDED', + ownerEvidenceRef: correlation.ownerEvidenceRef, + target: correlation.target, + }); + return { correlation }; +}); + +export const endExternalStockCorrelationAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: EndExternalStockCorrelationAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: MANAGE_PERMISSION, + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.correlationRef.moduleId, + resourceId: payload.correlationRef.resourceId, + resourceType: payload.correlationRef.resourceType, + }, + tenantId: tenantMismatch(payload, scope.tenantId) ? '' : scope.tenantId, + }, + })), + domainErrorSchema: EndExternalStockCorrelationErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: EndExternalStockCorrelationPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.correlationRef, + })), + resultSchema: EndExternalStockCorrelationResultSchema, + schemaVersion: '1', + }, + handleEndExternalStockCorrelation, + (transaction, scope) => Effect.succeed(externalStockCorrelationPersistenceForScope(transaction, scope)), +); + +// +// diff --git a/app/verticals/inventory/src/actions/end-stock-sharing-eligibility.action.ts b/app/verticals/inventory/src/actions/end-stock-sharing-eligibility.action.ts new file mode 100644 index 000000000..2c694573f --- /dev/null +++ b/app/verticals/inventory/src/actions/end-stock-sharing-eligibility.action.ts @@ -0,0 +1,123 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug end-stock-sharing-eligibility +import { randomUUID } from 'node:crypto'; + +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; + +import { + EndStockSharingEligibilityPayloadSchema, + EndStockSharingEligibilityResultSchema, +} from '../../shared/actions/end-stock-sharing-eligibility.ts'; +import type { EndStockSharingEligibilityPayload } from '../../shared/actions/end-stock-sharing-eligibility.ts'; +import { + StockSharingEligibilityLifecycleAuditEvidenceSchema, + StockSharingEligibilityLifecycleErrorSchema, + StockSharingEligibilityLifecycleRejected, +} from '../../shared/actions/establish-stock-sharing-eligibility.ts'; +import type { StockSharingEligibilityActionService } from '../services/stock-sharing-eligibility-action.service.ts'; +import { + stockSharingEligibilityActionServiceForScope, + stockSharingEligibilityAuditEvidence, +} from '../services/stock-sharing-eligibility-action.service.ts'; + +const ACTION_KEY = 'commerce.inventory.end-stock-sharing-eligibility'; +const EVENT_TYPE = 'commerce.inventory.stock-sharing-eligibility-ended.v1'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = { + [EVENT_TYPE]: Schema.Struct({ relation: EndStockSharingEligibilityResultSchema }), +} as const; + +export const handleEndStockSharingEligibility = Effect.fn('EndStockSharingEligibilityAction.handle')(function* handle( + payload: EndStockSharingEligibilityPayload, + context: ActionHandlerContext, +) { + if (context.scope.legalEntityId === undefined) { + return yield* new StockSharingEligibilityLifecycleRejected({ + code: 'stock_sharing_eligibility_lifecycle_rejected', + reason: 'TRUSTED_LEGAL_ENTITY_MISMATCH', + }); + } + const relation = yield* context.services.end(payload, context.scope.legalEntityId); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `stock-sharing-eligibility:${relation.ref.resourceId}:end`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: relation.scope.positionRef.resourceId, + targetResourceType: relation.scope.positionRef.resourceType, + }); + yield* context.addDomainEvent({ + eventType: EVENT_TYPE, + payloadJson: { relation }, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: relation.ref.resourceId, + subjectResourceType: relation.ref.resourceType, + }); + yield* context.recordAuditEvidence(stockSharingEligibilityAuditEvidence(relation, 'END')); + return relation; +}); + +export const endStockSharingEligibilityAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.end-stock-sharing-eligibility.access.v1', + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: StockSharingEligibilityLifecycleAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.stock_sharing_eligibility.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.positionRef.moduleId, + resourceId: payload.positionRef.resourceId, + resourceType: payload.positionRef.resourceType, + }, + tenantId: payload.positionRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: StockSharingEligibilityLifecycleErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: EndStockSharingEligibilityPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.positionRef, + })), + resultSchema: EndStockSharingEligibilityResultSchema, + schemaVersion: '1', + }, + handleEndStockSharingEligibility, + (transaction, scope) => stockSharingEligibilityActionServiceForScope(transaction, scope, randomUUID), +); + +export { + EndStockSharingEligibilityPayloadSchema, + EndStockSharingEligibilityResultSchema, +} from '../../shared/actions/end-stock-sharing-eligibility.ts'; +export type { EndStockSharingEligibilityPayload } from '../../shared/actions/end-stock-sharing-eligibility.ts'; + +// +// diff --git a/app/verticals/inventory/src/actions/establish-catalog-to-stock-binding.action.ts b/app/verticals/inventory/src/actions/establish-catalog-to-stock-binding.action.ts new file mode 100644 index 000000000..5a97f32b1 --- /dev/null +++ b/app/verticals/inventory/src/actions/establish-catalog-to-stock-binding.action.ts @@ -0,0 +1,133 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug establish-catalog-to-stock-binding +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect, Schema } from 'effect'; + +import { + EstablishCatalogToStockBindingErrorSchema, + EstablishCatalogToStockBindingPayloadSchema, + EstablishCatalogToStockBindingResultSchema, +} from '../../shared/actions/establish-catalog-to-stock-binding.ts'; +import type { EstablishCatalogToStockBindingPayload } from '../../shared/actions/establish-catalog-to-stock-binding.ts'; +import { + CatalogToStockBindingLifecycleEvidenceSchema, + CatalogToStockBindingRevisionSchema, + CatalogToStockBindingSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- The Action composes the existing owner lifecycle inside Core's transaction-scoped service boundary; expires: 2027-03-31. + makeCatalogToStockBindingLifecycle, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import type { CatalogToStockBindingPersistence } from '../../shared/domain/catalog-to-stock-binding.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local repository constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeDrizzleCatalogToStockBindingPersistence } from '../persistence/catalog-to-stock-binding-repository.ts'; +import { serializeCatalogToStockBindingPersistence } from '../persistence/binding-correction-serialization.ts'; + +export { + EstablishCatalogToStockBindingErrorSchema, + EstablishCatalogToStockBindingPayloadSchema, + EstablishCatalogToStockBindingResultSchema, +} from '../../shared/actions/establish-catalog-to-stock-binding.ts'; +export type { EstablishCatalogToStockBindingPayload } from '../../shared/actions/establish-catalog-to-stock-binding.ts'; + +const ACTION_KEY = 'commerce.inventory.establish-catalog-to-stock-binding'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = {} as const; + +export const EstablishCatalogToStockBindingAuditEvidenceSchema = Schema.Struct({ + authority: CatalogToStockBindingLifecycleEvidenceSchema.fields.authority, + bindingRef: CatalogToStockBindingSchema.fields.bindingRef, + exactSelectionMeaning: CatalogToStockBindingSchema.fields.exactSelectionMeaning, + operation: Schema.Literal('ESTABLISHED'), + ownerEvidenceRef: CatalogToStockBindingLifecycleEvidenceSchema.fields.ownerEvidenceRef, + revision: CatalogToStockBindingRevisionSchema, + stockItemRef: CatalogToStockBindingSchema.fields.stockItemRef, + unitRef: CatalogToStockBindingSchema.fields.unitRef, +}); + +export const handleEstablishCatalogToStockBinding = Effect.fn('EstablishCatalogToStockBindingAction.handle')( + function* handle( + payload: EstablishCatalogToStockBindingPayload, + context: ActionHandlerContext, + ) { + const binding = yield* makeCatalogToStockBindingLifecycle(context.services, { + makeBindingId: () => payload.bindingRef.resourceId, + now: DateTime.now.pipe(Effect.map(DateTime.formatIso)), + }).establish(payload.candidate); + + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `catalog-to-stock-binding:establish:${payload.candidate.exactSelectionMeaning.kind}:${payload.candidate.exactSelectionMeaning.id}`, + resultCount: 0, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: binding.bindingRef.resourceId, + targetResourceType: binding.bindingRef.resourceType, + }); + yield* context.recordAuditEvidence({ + authority: payload.evidence.authority, + bindingRef: binding.bindingRef, + exactSelectionMeaning: binding.exactSelectionMeaning, + operation: 'ESTABLISHED', + ownerEvidenceRef: payload.evidence.ownerEvidenceRef, + revision: binding.revision, + stockItemRef: binding.stockItemRef, + unitRef: binding.unitRef, + }); + return binding; + }, +); + +export const establishCatalogToStockBindingAction = defineAction( + { + accessEvidencePolicy: { captureMode: 'metadata_only', policyKey: `${ACTION_KEY}.access.v1` }, + actionKey: ACTION_KEY, + auditEvidenceSchema: EstablishCatalogToStockBindingAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.catalog_to_stock_binding.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.bindingRef.moduleId, + resourceId: payload.bindingRef.resourceId, + resourceType: payload.bindingRef.resourceType, + }, + tenantId: payload.bindingRef.tenantId, + }, + })), + domainErrorSchema: EstablishCatalogToStockBindingErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: EstablishCatalogToStockBindingPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.bindingRef, + })), + resultSchema: EstablishCatalogToStockBindingResultSchema, + schemaVersion: '1', + }, + handleEstablishCatalogToStockBinding, + (transaction) => + Effect.succeed( + serializeCatalogToStockBindingPersistence(transaction, makeDrizzleCatalogToStockBindingPersistence(transaction)), + ), +); + +// +// diff --git a/app/verticals/inventory/src/actions/establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts b/app/verticals/inventory/src/actions/establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts new file mode 100644 index 000000000..af8b891e7 --- /dev/null +++ b/app/verticals/inventory/src/actions/establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.establish-commitment-protection +// @ontos-outbox-topic commerce.inventory.commitment-protection-changed.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; + +export { + OutboxPayloadSchema as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxPayloadSchema, + outboxProducerModuleKey as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxProducerModuleKey, + outboxTopic as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; +export type { OutboxPayload as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-commitment-protection-changed-v1'; + +export const createEstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts b/app/verticals/inventory/src/actions/establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts new file mode 100644 index 000000000..32ca97936 --- /dev/null +++ b/app/verticals/inventory/src/actions/establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts @@ -0,0 +1,23 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.establish-commitment-protection +// @ontos-outbox-topic commerce.inventory.commitment-protection-establishment-requested.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-commitment-protection-establishment-requested-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-commitment-protection-establishment-requested-v1'; + +export { + OutboxPayloadSchema as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxPayloadSchema, + outboxProducerModuleKey as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxProducerModuleKey, + outboxTopic as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-commitment-protection-establishment-requested-v1'; +export type { OutboxPayload as EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-commitment-protection-establishment-requested-v1'; + +export const createEstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxMessage = + (payload: OutboxPayload): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, + }); diff --git a/app/verticals/inventory/src/actions/establish-commitment-protection.action.ts b/app/verticals/inventory/src/actions/establish-commitment-protection.action.ts new file mode 100644 index 000000000..d7f3bf9fc --- /dev/null +++ b/app/verticals/inventory/src/actions/establish-commitment-protection.action.ts @@ -0,0 +1,178 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug establish-commitment-protection +/* oxlint-disable anti-slop-effect/no-service-constructor-imports -- The generated Action factory constructs owner-local services inside its transaction scope; expires: 2027-03-31. */ +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect, Match, Schema } from 'effect'; + +import { + EstablishCommitmentProtectionErrorSchema, + EstablishCommitmentProtectionPayloadSchema, + EstablishCommitmentProtectionResultSchema, +} from '../../shared/actions/establish-commitment-protection.ts'; +import type { EstablishCommitmentProtectionPayload } from '../../shared/actions/establish-commitment-protection.ts'; +import { + CommitmentProtectionRejected, + CommitmentProtectionUnavailable, +} from '../../shared/domain/commitment-protection.ts'; +import { LegalEntityIdSchema } from '../../shared/domain/physical-stock-effect.ts'; +import { OutboxPayloadSchema as CommitmentProtectionChangedOutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-commitment-protection-changed-v1.ts'; +import { OutboxPayloadSchema as CommitmentProtectionEstablishmentRequestedOutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-commitment-protection-establishment-requested-v1.ts'; +import { commitmentProtectionPersistenceForScope } from '../persistence/commitment-protection-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { reservationConfirmationPersistenceForScope } from '../persistence/reservation-confirmation-repository.ts'; +import type { CommitmentProtectionService } from '../services/commitment-protection.service.ts'; +import { makeCommitmentProtectionService } from '../services/commitment-protection.service.ts'; +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +import { createEstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxMessage as createEstablishmentRequestedOutboxMessage } from './establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts'; + +export { + EstablishCommitmentProtectionErrorSchema, + EstablishCommitmentProtectionPayloadSchema, + EstablishCommitmentProtectionResultSchema, +} from '../../shared/actions/establish-commitment-protection.ts'; + +const ACTION_KEY = 'commerce.inventory.establish-commitment-protection'; +const MODULE_KEY = 'commerce.inventory'; +const COMMITMENT_PROTECTION_CHANGED_EVENT = 'commerce.inventory.commitment-protection-changed.v1'; +const COMMITMENT_PROTECTION_ESTABLISHMENT_REQUESTED_EVENT = + 'commerce.inventory.commitment-protection-establishment-requested.v1'; +const domainEvents = { + [COMMITMENT_PROTECTION_CHANGED_EVENT]: CommitmentProtectionChangedOutboxPayloadSchema, + [COMMITMENT_PROTECTION_ESTABLISHMENT_REQUESTED_EVENT]: CommitmentProtectionEstablishmentRequestedOutboxPayloadSchema, +} as const; + +const invalidLegalEntityScope = (payload: EstablishCommitmentProtectionPayload, cause: unknown) => { + const failure = new CommitmentProtectionUnavailable({ + code: 'commitment_protection_unavailable', + effectId: payload.effectId, + reason: 'Trusted Legal Entity identity is invalid', + retryable: true, + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +export const handleEstablishCommitmentProtection = Effect.fn('EstablishCommitmentProtectionAction.handle')( + function* handle( + payload: EstablishCommitmentProtectionPayload, + context: ActionHandlerContext, + ) { + if (context.scope.legalEntityId === undefined) { + return yield* new CommitmentProtectionRejected({ + code: 'commitment_protection_rejected', + effectId: payload.effectId, + reason: 'TENANT_SCOPE_MISMATCH', + }); + } + const legalEntityId = yield* Schema.decodeEffect(LegalEntityIdSchema)(context.scope.legalEntityId).pipe( + Effect.mapError((cause) => invalidLegalEntityScope(payload, cause)), + ); + const decision = yield* context.services.establish(payload, { + actionInvocationId: context.actionInvocationId, + legalEntityId, + tenantId: context.scope.tenantId, + }); + const resultCount = Match.value(decision.result).pipe( + Match.tag('PROTECTED', () => 1), + Match.orElse(() => 0), + ); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `commitment-protection:${payload.effectId}`, + resultCount, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.protectionRef.resourceId, + targetResourceType: payload.protectionRef.resourceType, + }); + if (decision.dispatchRequested) { + const eventPayload = { request: decision.request }; + const event = yield* context.addDomainEvent({ + eventType: COMMITMENT_PROTECTION_ESTABLISHMENT_REQUESTED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: payload.protectionRef.resourceId, + subjectResourceType: payload.protectionRef.resourceType, + }); + yield* context.addOutboxMessage(event, createEstablishmentRequestedOutboxMessage(eventPayload)); + } + return decision.result; + }, +); + +export const establishCommitmentProtectionAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.commitment_protection.establish', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.protectionRef.moduleId, + resourceId: payload.protectionRef.resourceId, + resourceType: payload.protectionRef.resourceType, + }, + tenantId: payload.protectionRef.tenantId, + }, + })), + domainErrorSchema: EstablishCommitmentProtectionErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: EstablishCommitmentProtectionPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.protectionRef, + })), + resultSchema: EstablishCommitmentProtectionResultSchema, + schemaVersion: '1', + }, + handleEstablishCommitmentProtection, + (transaction, scope) => + Effect.succeed( + makeCommitmentProtectionService({ + confirmations: reservationConfirmationPersistenceForScope(transaction, scope), + ledger: makeInventoryEffectLedgerService( + inventoryEffectLedgerPersistenceForScope(transaction, scope), + DateTime.now.pipe(Effect.map(DateTime.formatIso)), + ), + now: DateTime.now.pipe(Effect.map(DateTime.formatIso)), + protections: commitmentProtectionPersistenceForScope(transaction, scope), + }), + ), +); + +// +export { createEstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxMessage } from './establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { createEstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxMessage } from './establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts'; +export { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxPayloadSchema } from './establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxProducerModuleKey } from './establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxTopic } from './establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxPayloadSchema } from './establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts'; +export { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxProducerModuleKey } from './establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts'; +export { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxTopic } from './establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts'; +export type { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionChangedV1OutboxPayload } from './establish-commitment-protection-commerce-inventory-commitment-protection-changed-v1.outbox-message.ts'; +export type { EstablishCommitmentProtectionCommerceInventoryCommitmentProtectionEstablishmentRequestedV1OutboxPayload } from './establish-commitment-protection-commerce-inventory-commitment-protection-establishment-requested-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/actions/establish-external-stock-correlation.action.ts b/app/verticals/inventory/src/actions/establish-external-stock-correlation.action.ts new file mode 100644 index 000000000..6727a276f --- /dev/null +++ b/app/verticals/inventory/src/actions/establish-external-stock-correlation.action.ts @@ -0,0 +1,157 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug establish-external-stock-correlation +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; + +import { + EstablishExternalStockCorrelationErrorSchema, + EstablishExternalStockCorrelationPayloadSchema, + EstablishExternalStockCorrelationResultSchema, +} from '../../shared/actions/establish-external-stock-correlation.ts'; +import type { EstablishExternalStockCorrelationPayload } from '../../shared/actions/establish-external-stock-correlation.ts'; +import { + ExternalStockCorrelationInstantSchema, + ExternalStockTargetSchema, + InventoryBackendOriginSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- This Action composes the owner-local pure lifecycle with transaction-scoped persistence; expires: 2027-03-31. + makeExternalStockCorrelationLifecycle, +} from '../../shared/domain/external-stock-correlation.ts'; +import type { ExternalStockCorrelationPersistence } from '../../shared/domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationRejected } from '../../shared/domain/external-stock-correlation-rejected.ts'; +import { CustomerConfigurationIdSchema } from '../../shared/inventory-launch-scope.ts'; +import { ExternalStockCorrelationRefSchema } from '../../shared/resources/external-stock-correlation.ts'; +import { externalStockCorrelationPersistenceForScope } from '../persistence/external-stock-correlation-repository.ts'; + +export { + EstablishExternalStockCorrelationErrorSchema, + EstablishExternalStockCorrelationPayloadSchema, + EstablishExternalStockCorrelationResultSchema, +} from '../../shared/actions/establish-external-stock-correlation.ts'; + +const ACTION_KEY = 'commerce.inventory.establish-external-stock-correlation'; +const MODULE_KEY = 'commerce.inventory'; +const MANAGE_PERMISSION = 'inventory.external_stock_correlation.manage'; +const domainEvents = {} as const; + +export const EstablishExternalStockCorrelationAuditEvidenceSchema = Schema.Struct({ + correlationRef: ExternalStockCorrelationRefSchema, + customerConfigurationId: CustomerConfigurationIdSchema, + effectiveAt: ExternalStockCorrelationInstantSchema, + issuer: InventoryBackendOriginSchema, + operation: Schema.Literal('ESTABLISHED'), + ownerEvidenceRef: EstablishExternalStockCorrelationPayloadSchema.fields.ownerEvidenceRef, + target: ExternalStockTargetSchema, +}); + +const tenantMismatch = (payload: EstablishExternalStockCorrelationPayload, tenantId: string): boolean => + payload.correlationRef.tenantId !== tenantId || + payload.externalKey.tenantId !== tenantId || + payload.target.ref.tenantId !== tenantId; + +export const handleEstablishExternalStockCorrelation = Effect.fn('EstablishExternalStockCorrelationAction.handle')( + function* handle( + payload: EstablishExternalStockCorrelationPayload, + context: ActionHandlerContext, + ) { + if (tenantMismatch(payload, context.scope.tenantId)) { + return yield* new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef: payload.correlationRef, + reason: 'TENANT_SCOPE_MISMATCH', + }); + } + const correlation = yield* makeExternalStockCorrelationLifecycle(context.services, { + makeCorrelationId: () => payload.correlationRef.resourceId, + }).establish({ + effectiveFrom: payload.effectiveFrom, + externalKey: payload.externalKey, + ownerEvidenceRef: payload.ownerEvidenceRef, + target: payload.target, + }); + if ( + correlation.correlationRef.tenantId !== payload.correlationRef.tenantId || + correlation.correlationRef.resourceId !== payload.correlationRef.resourceId + ) { + return yield* new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef: payload.correlationRef, + reason: 'CORRELATION_IDENTITY_CONFLICT', + }); + } + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `external-stock-correlation:establish:${payload.correlationRef.resourceId}`, + resultCount: 0, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.correlationRef.resourceId, + targetResourceType: payload.correlationRef.resourceType, + }); + yield* context.recordAuditEvidence({ + correlationRef: correlation.correlationRef, + customerConfigurationId: correlation.externalKey.customerConfigurationId, + effectiveAt: correlation.effectivePeriod.from, + issuer: correlation.externalKey.issuer, + operation: 'ESTABLISHED', + ownerEvidenceRef: correlation.ownerEvidenceRef, + target: correlation.target, + }); + return { correlation }; + }, +); + +export const establishExternalStockCorrelationAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: EstablishExternalStockCorrelationAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: MANAGE_PERMISSION, + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.correlationRef.moduleId, + resourceId: payload.correlationRef.resourceId, + resourceType: payload.correlationRef.resourceType, + }, + tenantId: tenantMismatch(payload, scope.tenantId) ? '' : scope.tenantId, + }, + })), + domainErrorSchema: EstablishExternalStockCorrelationErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: EstablishExternalStockCorrelationPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.correlationRef, + })), + resultSchema: EstablishExternalStockCorrelationResultSchema, + schemaVersion: '1', + }, + handleEstablishExternalStockCorrelation, + (transaction, scope) => Effect.succeed(externalStockCorrelationPersistenceForScope(transaction, scope)), +); + +// +// diff --git a/app/verticals/inventory/src/actions/establish-stock-sharing-eligibility.action.ts b/app/verticals/inventory/src/actions/establish-stock-sharing-eligibility.action.ts new file mode 100644 index 000000000..37f7db63a --- /dev/null +++ b/app/verticals/inventory/src/actions/establish-stock-sharing-eligibility.action.ts @@ -0,0 +1,128 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug establish-stock-sharing-eligibility +import { randomUUID } from 'node:crypto'; + +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; + +import { + EstablishStockSharingEligibilityPayloadSchema, + EstablishStockSharingEligibilityResultSchema, + StockSharingEligibilityLifecycleAuditEvidenceSchema, + StockSharingEligibilityLifecycleErrorSchema, + StockSharingEligibilityLifecycleRejected, +} from '../../shared/actions/establish-stock-sharing-eligibility.ts'; +import type { EstablishStockSharingEligibilityPayload } from '../../shared/actions/establish-stock-sharing-eligibility.ts'; +import type { StockSharingEligibilityActionService } from '../services/stock-sharing-eligibility-action.service.ts'; +import { + stockSharingEligibilityActionServiceForScope, + stockSharingEligibilityAuditEvidence, +} from '../services/stock-sharing-eligibility-action.service.ts'; + +const ACTION_KEY = 'commerce.inventory.establish-stock-sharing-eligibility'; +const EVENT_TYPE = 'commerce.inventory.stock-sharing-eligibility-established.v1'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = { + [EVENT_TYPE]: Schema.Struct({ relation: EstablishStockSharingEligibilityResultSchema }), +} as const; + +const trustedLegalEntity = (legalEntityId: string | undefined) => + legalEntityId === undefined + ? Effect.fail( + new StockSharingEligibilityLifecycleRejected({ + code: 'stock_sharing_eligibility_lifecycle_rejected', + reason: 'TRUSTED_LEGAL_ENTITY_MISMATCH', + }), + ) + : Effect.succeed(legalEntityId); + +export const handleEstablishStockSharingEligibility = Effect.fn('EstablishStockSharingEligibilityAction.handle')( + function* handle( + payload: EstablishStockSharingEligibilityPayload, + context: ActionHandlerContext, + ) { + const legalEntityId = yield* trustedLegalEntity(context.scope.legalEntityId); + const relation = yield* context.services.establish(payload, legalEntityId); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `stock-sharing-eligibility:${relation.ref.resourceId}:establish`, + resultCount: 0, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: relation.scope.positionRef.resourceId, + targetResourceType: relation.scope.positionRef.resourceType, + }); + yield* context.addDomainEvent({ + eventType: EVENT_TYPE, + payloadJson: { relation }, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: relation.ref.resourceId, + subjectResourceType: relation.ref.resourceType, + }); + yield* context.recordAuditEvidence(stockSharingEligibilityAuditEvidence(relation, 'ESTABLISH')); + return relation; + }, +); + +export const establishStockSharingEligibilityAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.establish-stock-sharing-eligibility.access.v1', + }, + actionKey: ACTION_KEY, + auditEvidenceSchema: StockSharingEligibilityLifecycleAuditEvidenceSchema, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.stock_sharing_eligibility.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.scope.positionRef.moduleId, + resourceId: payload.scope.positionRef.resourceId, + resourceType: payload.scope.positionRef.resourceType, + }, + tenantId: payload.scope.positionRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: StockSharingEligibilityLifecycleErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: EstablishStockSharingEligibilityPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.scope.positionRef, + })), + resultSchema: EstablishStockSharingEligibilityResultSchema, + schemaVersion: '1', + }, + handleEstablishStockSharingEligibility, + (transaction, scope) => stockSharingEligibilityActionServiceForScope(transaction, scope, randomUUID), +); + +export { + EstablishStockSharingEligibilityPayloadSchema, + EstablishStockSharingEligibilityResultSchema, +} from '../../shared/actions/establish-stock-sharing-eligibility.ts'; +export type { EstablishStockSharingEligibilityPayload } from '../../shared/actions/establish-stock-sharing-eligibility.ts'; + +// +// diff --git a/app/verticals/inventory/src/actions/import-source-assertion.action.ts b/app/verticals/inventory/src/actions/import-source-assertion.action.ts new file mode 100644 index 000000000..0a5d97d3e --- /dev/null +++ b/app/verticals/inventory/src/actions/import-source-assertion.action.ts @@ -0,0 +1,132 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug import-source-assertion +/* oxlint-disable unicorn/no-array-method-this-argument -- Effect.forEach's curried overload takes concurrency options, not Array#forEach thisArg; expires: 2027-03-31. */ +import type { ActionHandlerContext } from '@app/core-runtime'; +import { defineAction, defineActionBusinessPermission, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; + +import { + ImportSourceAssertionErrorSchema, + ImportSourceAssertionPayloadSchema, + ImportSourceAssertionResultSchema, + InventorySourceImportRequestRejected, +} from '../../shared/actions/import-source-assertion.ts'; +import type { ImportSourceAssertionPayload } from '../../shared/actions/import-source-assertion.ts'; +import { InventorySourceImportActionInvocationIdSchema } from '../../shared/domain/inventory-source-import-outcome.ts'; +import type { InventorySourceImportOperations } from '../services/inventory-source-import.service.ts'; +import { inventorySourceImportService } from '../services/inventory-source-import.service.ts'; + +export { + ImportSourceAssertionErrorSchema, + ImportSourceAssertionPayloadSchema, + ImportSourceAssertionResultSchema, +} from '../../shared/actions/import-source-assertion.ts'; + +const ACTION_KEY = 'commerce.inventory.import-source-assertion'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = {} as const; + +const sameRef = ( + left: ImportSourceAssertionPayload['authorizationTargetRef'], + right: ImportSourceAssertionPayload['authorizationTargetRef'], +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +export const handleImportSourceAssertion = Effect.fn('ImportSourceAssertionAction.handle')(function* handle( + payload: ImportSourceAssertionPayload, + context: ActionHandlerContext, +) { + if ( + payload.authorizationTargetRef.tenantId !== context.scope.tenantId || + payload.items.some((proposal) => proposal.positionRef.tenantId !== context.scope.tenantId) + ) { + return yield* new InventorySourceImportRequestRejected({ + code: 'inventory_source_import_request_rejected', + reason: 'Every Inventory Source Assertion must belong to the trusted Tenant', + }); + } + if (payload.items.some((proposal) => !sameRef(proposal.positionRef, payload.authorizationTargetRef))) { + return yield* new InventorySourceImportRequestRejected({ + code: 'inventory_source_import_request_rejected', + reason: 'Every Inventory Source Assertion must match the exact authorization target Position', + }); + } + const actionInvocationId = yield* Schema.decodeEffect(InventorySourceImportActionInvocationIdSchema)( + context.actionInvocationId, + ).pipe(Effect.orDie); + const result = yield* context.services.importBatch({ + actionInvocationId, + payload, + }); + const positionCounts = new Map(); + for (const { positionRef } of payload.items) { + const existing = positionCounts.get(positionRef.resourceId); + positionCounts.set(positionRef.resourceId, { + count: (existing?.count ?? 0) + 1, + resourceId: positionRef.resourceId, + }); + } + yield* Effect.forEach( + ({ count, resourceId }: { readonly count: number; readonly resourceId: string }) => + context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-source-import:${resourceId}`, + resultCount: count, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: resourceId, + targetResourceType: 'commerce.inventory.stock-position', + }), + { concurrency: 1 }, + )(positionCounts.values()); + return result; +}); + +export const importSourceAssertionAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.import-source-assertion.access.v1', + }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.migration.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.authorizationTargetRef.moduleId, + resourceId: payload.authorizationTargetRef.resourceId, + resourceType: payload.authorizationTargetRef.resourceType, + }, + tenantId: payload.authorizationTargetRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: ImportSourceAssertionErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: ImportSourceAssertionPayloadSchema, + policies: [], + resultSchema: ImportSourceAssertionResultSchema, + schemaVersion: '1', + }, + handleImportSourceAssertion, + (transaction, scope) => Effect.succeed(inventorySourceImportService(transaction, scope)), +); + +// +// +/* oxlint-enable unicorn/no-array-method-this-argument */ diff --git a/app/verticals/inventory/src/actions/recover-inventory-effect.action.ts b/app/verticals/inventory/src/actions/recover-inventory-effect.action.ts new file mode 100644 index 000000000..f28adc630 --- /dev/null +++ b/app/verticals/inventory/src/actions/recover-inventory-effect.action.ts @@ -0,0 +1,288 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug recover-inventory-effect +/* oxlint-disable anti-slop-effect/no-service-constructor-imports, effect-native/no-dependency-parameters -- The generated Action factory constructs and binds owner-local transaction services once; expires: 2027-03-31. */ +import { createHash } from 'node:crypto'; + +import type { ActionHandlerContext, ActionRegistration } from '@app/core-runtime'; +import { defineAction, defineActionBusinessPermission, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import type { Effect as EffectType } from 'effect'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + RecoverInventoryEffectActionRejected, + RecoverInventoryEffectErrorSchema, + RecoverInventoryEffectPayloadSchema, + RecoverInventoryEffectResultSchema, +} from '../../shared/actions/recover-inventory-effect.ts'; +import type { + RecoverInventoryEffectPayload, + RecoverInventoryEffectResult, + RecoverInventoryEffectTargetRef, +} from '../../shared/actions/recover-inventory-effect.ts'; +import type { InventoryEffectRecoveryRequest } from '../../shared/domain/inventory-effect-recovery.ts'; +import type { InventoryEffectLedgerIntent } from '../../shared/domain/inventory-effect-ledger.ts'; +import { EstablishedReservationCreateEffectSchema } from '../../shared/domain/inventory-reservation-create.ts'; +import { ReservationAuthorityEffectIdSchema } from '../../shared/domain/reservation-issuer-failure-fields.ts'; +import { OutboxPayloadSchema as ReservationConfirmationIssuanceRequestedPayloadSchema } from '../../shared/outbox/commerce-inventory-reservation-confirmation-issuance-requested-v1.ts'; +import { + ReservationConfirmationIdSchema, + ReservationConfirmationRefSchema, +} from '../../shared/resources/reservation-confirmation.ts'; +import { commitmentProtectionPersistenceForScope } from '../persistence/commitment-protection-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { inventoryObligationPersistenceForScope } from '../persistence/inventory-obligation-repository.ts'; +import { physicalStockEffectPersistenceForScope } from '../persistence/physical-stock-effect-repository.ts'; +import { reservationCreateEffectPersistenceForScope } from '../persistence/reservation-create-effect-repository.ts'; +import { reservationReleaseEffectPersistenceForScope } from '../persistence/reservation-release-effect-repository.ts'; +import type { InventoryEffectRecoveryAuthority } from '../services/inventory-effect-recovery-authority.ts'; +import { InventoryEffectRecoveryAuthorityPort } from '../services/inventory-effect-recovery-authority.ts'; +import type { + InventoryEffectRecoveryError, + InventoryEffectRecoveryRecordReader, + InventoryEffectRecoveryService, +} from '../services/inventory-effect-recovery.service.ts'; +import { + makeInventoryEffectRecoveryOwnerPersistence, + makeInventoryEffectRecoveryService, +} from '../services/inventory-effect-recovery.service.ts'; +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +import { createCreateInventoryReservationCommerceInventoryReservationConfirmationIssuanceRequestedV1OutboxMessage as createConfirmationIssuanceOutboxMessage } from './create-inventory-reservation-commerce-inventory-reservation-confirmation-issuance-requested-v1.outbox-message.ts'; + +export { + RecoverInventoryEffectErrorSchema, + RecoverInventoryEffectPayloadSchema, + RecoverInventoryEffectResultSchema, +} from '../../shared/actions/recover-inventory-effect.ts'; + +const ACTION_KEY = 'commerce.inventory.recover-inventory-effect'; +const MODULE_KEY = 'commerce.inventory'; +const CONFIRMATION_ISSUANCE_REQUESTED_EVENT = + 'commerce.inventory.reservation-confirmation-issuance-requested.v1' as const; +const domainEvents = { + [CONFIRMATION_ISSUANCE_REQUESTED_EVENT]: ReservationConfirmationIssuanceRequestedPayloadSchema, +} as const; + +interface TrustedRecoveryScope { + readonly legalEntityId: string; + readonly tenantId: string; +} + +export type RecoverInventoryEffectServices = Readonly<{ + recover: ( + payload: RecoverInventoryEffectPayload, + scope: TrustedRecoveryScope, + ) => EffectType.Effect< + RecoverInventoryEffectResult, + InventoryEffectRecoveryError | RecoverInventoryEffectActionRejected + >; +}>; + +const actionRejected = ( + effectId: RecoverInventoryEffectPayload['effectId'], + reason: RecoverInventoryEffectActionRejected['reason'], +) => + new RecoverInventoryEffectActionRejected({ + code: 'recover_inventory_effect_action_rejected', + effectId, + reason, + }); + +const targetForIntent = (intent: InventoryEffectLedgerIntent): RecoverInventoryEffectTargetRef => + Match.value(intent).pipe( + Match.tag('RESERVATION_CREATE', ({ request }) => request.reservation.ref), + Match.tag('RESERVATION_RELEASE', ({ request }) => request.reservation.ref), + Match.tag('ESTABLISH_COMMITMENT_PROTECTION', ({ request }) => request.protectionRef), + Match.tag('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', ({ request }) => request.positionRef), + Match.exhaustive, + ); + +const legalEntityForIntent = (intent: InventoryEffectLedgerIntent): string => + Match.value(intent).pipe( + Match.tag('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', ({ request }) => + String(request.legalEntityId), + ), + Match.tag('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', ({ request }) => String(request.legalEntityId)), + Match.exhaustive, + ); + +const sameTarget = (left: RecoverInventoryEffectTargetRef, right: RecoverInventoryEffectTargetRef) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const deterministicUuid = (seed: string) => { + const digest = createHash('sha256').update(seed).digest('hex'); + return `${digest.slice(0, 8)}-${digest.slice(8, 12)}-5${digest.slice(13, 16)}-8${digest.slice(17, 20)}-${digest.slice(20, 32)}`; +}; + +const confirmationIssuanceFor = (result: RecoverInventoryEffectResult) => { + const { record } = result; + const resolution = record?.resolution; + if (resolution === null || resolution === undefined) { + return null; + } + return Match.value(resolution).pipe( + Match.tag('RESERVATION_CREATE', ({ effect }) => { + if (!Schema.is(EstablishedReservationCreateEffectSchema)(effect)) { + return null; + } + const { request, reservation } = effect; + const confirmationId = deterministicUuid( + `${reservation.ref.tenantId}\u0000${reservation.ref.resourceId}\u0000${reservation.origin.attemptId}\u0000reservation-confirmation`, + ); + return { + request: { + confirmationRef: ReservationConfirmationRefSchema.make({ + moduleId: MODULE_KEY, + resourceId: ReservationConfirmationIdSchema.make(confirmationId), + resourceType: 'commerce.inventory.reservation-confirmation', + tenantId: reservation.ref.tenantId, + }), + effectId: ReservationAuthorityEffectIdSchema.make(`reservation-confirmation:${confirmationId}`), + legalEntityId: request.legalEntityId, + mutationId: request.mutationId, + reservation, + sourceActionInvocationId: request.sourceActionInvocationId, + }, + }; + }), + Match.orElse(() => null), + ); +}; + +export const makeRecoverInventoryEffectActionService = (dependencies: { + readonly records: InventoryEffectRecoveryRecordReader; + readonly recovery: InventoryEffectRecoveryService; +}): RecoverInventoryEffectServices => ({ + recover: Effect.fn('RecoverInventoryEffectActionService.recover')(function* recover(payload, scope) { + const current = yield* dependencies.records.read(payload.effectId); + if (Option.isSome(current)) { + const original = current.value; + if ( + original.tenantId !== scope.tenantId || + legalEntityForIntent(original.intent) !== scope.legalEntityId || + !sameTarget(targetForIntent(original.intent), payload.targetRef) + ) { + return yield* actionRejected(payload.effectId, 'ORIGINAL_EFFECT_SCOPE_MISMATCH'); + } + } + const request: InventoryEffectRecoveryRequest = { + effectId: payload.effectId, + expectedKind: payload.expectedKind, + tenantId: scope.tenantId, + }; + return yield* dependencies.recovery.recover(request); + }), +}); + +export const handleRecoverInventoryEffect = Effect.fn('RecoverInventoryEffectAction.handle')(function* handle( + payload: RecoverInventoryEffectPayload, + context: ActionHandlerContext, +) { + if (context.scope.legalEntityId === undefined) { + return yield* actionRejected(payload.effectId, 'TRUSTED_LEGAL_ENTITY_REQUIRED'); + } + const result = yield* context.services.recover(payload, { + legalEntityId: context.scope.legalEntityId, + tenantId: context.scope.tenantId, + }); + const resultCount = Match.value(result).pipe( + Match.tag('INDETERMINATE', ({ record }) => (record === undefined ? 0 : 1)), + Match.orElse(() => 1), + ); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-effect-recovery:${payload.effectId}`, + resultCount, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.targetRef.resourceId, + targetResourceType: payload.targetRef.resourceType, + }); + const confirmationIssuance = confirmationIssuanceFor(result); + if (confirmationIssuance !== null) { + const event = yield* context.addDomainEvent({ + eventType: CONFIRMATION_ISSUANCE_REQUESTED_EVENT, + payloadJson: confirmationIssuance, + producerModuleKey: MODULE_KEY, + subjectModuleKey: payload.targetRef.moduleId, + subjectResourceId: payload.targetRef.resourceId, + subjectResourceType: payload.targetRef.resourceType, + }); + yield* context.addOutboxMessage(event, createConfirmationIssuanceOutboxMessage(confirmationIssuance)); + } + return result; +}); + +export const recoverInventoryEffectAction: ActionRegistration< + typeof RecoverInventoryEffectPayloadSchema, + typeof RecoverInventoryEffectResultSchema, + typeof RecoverInventoryEffectErrorSchema, + typeof domainEvents, + 'commerce.inventory', + RecoverInventoryEffectServices, + InventoryEffectRecoveryAuthority +> = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: `${ACTION_KEY}.access.v1`, + }, + actionKey: ACTION_KEY, + auditProfile: 'sensitive', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.recovery.execute', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.targetRef.moduleId, + resourceId: payload.targetRef.resourceId, + resourceType: payload.targetRef.resourceType, + }, + tenantId: payload.targetRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: RecoverInventoryEffectErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: RecoverInventoryEffectPayloadSchema, + policies: [], + resultSchema: RecoverInventoryEffectResultSchema, + schemaVersion: '1', + }, + handleRecoverInventoryEffect, + (transaction, scope) => { + const records = inventoryEffectLedgerPersistenceForScope(transaction, scope); + return InventoryEffectRecoveryAuthorityPort.pipe( + Effect.flatMap((authority) => + makeInventoryEffectRecoveryService({ + authority, + ledger: makeInventoryEffectLedgerService(records, DateTime.now.pipe(Effect.map(DateTime.formatIso))), + owners: makeInventoryEffectRecoveryOwnerPersistence({ + creates: reservationCreateEffectPersistenceForScope(transaction, scope), + obligations: inventoryObligationPersistenceForScope(transaction, scope), + physicalEffects: physicalStockEffectPersistenceForScope(transaction, scope), + protections: commitmentProtectionPersistenceForScope(transaction, scope), + releases: reservationReleaseEffectPersistenceForScope(transaction, scope), + }), + records, + }), + ), + Effect.map((recovery) => makeRecoverInventoryEffectActionService({ records, recovery })), + ); + }, +); + +// +// diff --git a/app/verticals/inventory/src/actions/release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts b/app/verticals/inventory/src/actions/release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts new file mode 100644 index 000000000..91cc772d5 --- /dev/null +++ b/app/verticals/inventory/src/actions/release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.release-inventory-reservation +// @ontos-outbox-topic commerce.inventory.inventory-reservation-release-requested.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-inventory-reservation-release-requested-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-inventory-reservation-release-requested-v1'; + +export { + OutboxPayloadSchema as ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxPayloadSchema, + outboxProducerModuleKey as ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxProducerModuleKey, + outboxTopic as ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-inventory-reservation-release-requested-v1'; +export type { OutboxPayload as ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-inventory-reservation-release-requested-v1'; + +export const createReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/release-inventory-reservation.action.ts b/app/verticals/inventory/src/actions/release-inventory-reservation.action.ts new file mode 100644 index 000000000..e48f5ff9e --- /dev/null +++ b/app/verticals/inventory/src/actions/release-inventory-reservation.action.ts @@ -0,0 +1,170 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug release-inventory-reservation +/* oxlint-disable anti-slop-effect/no-service-constructor-imports -- The generated Action factory constructs owner-local services and repositories inside its transaction scope; expires: 2027-03-31. */ +import { randomUUID } from 'node:crypto'; + +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect, Schema } from 'effect'; + +import { + ReleaseInventoryReservationErrorSchema, + ReleaseInventoryReservationPayloadSchema, + ReleaseInventoryReservationResultSchema, +} from '../../shared/actions/release-inventory-reservation.ts'; +import type { ReleaseInventoryReservationPayload } from '../../shared/actions/release-inventory-reservation.ts'; +import { ReservationReleaseMutationIdSchema } from '../../shared/domain/inventory-reservation-release.ts'; +import { ActionInvocationIdSchema, LegalEntityIdSchema } from '../../shared/domain/physical-stock-effect.ts'; +import { OutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-inventory-reservation-release-requested-v1.ts'; +import { inventoryObligationPersistenceForScope } from '../persistence/inventory-obligation-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { reservationReleaseEffectPersistenceForScope } from '../persistence/reservation-release-effect-repository.ts'; +import type { InventoryReservationReleaseService } from '../services/inventory-reservation-release.service.ts'; +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +import { + makeInventoryReservationReleaseService, + reservationReleaseUnavailable, +} from '../services/inventory-reservation-release.service.ts'; +import { createReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxMessage as createOutboxMessage } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; + +export { + ReleaseInventoryReservationErrorSchema, + ReleaseInventoryReservationPayloadSchema, + ReleaseInventoryReservationResultSchema, +} from '../../shared/actions/release-inventory-reservation.ts'; + +const ACTION_KEY = 'commerce.inventory.release-inventory-reservation'; +const MODULE_KEY = 'commerce.inventory'; +const REQUESTED_EVENT = 'commerce.inventory.inventory-reservation-release-requested.v1'; +const domainEvents = { [REQUESTED_EVENT]: OutboxPayloadSchema } as const; + +export const handleReleaseInventoryReservation = Effect.fn('ReleaseInventoryReservationAction.handle')(function* handle( + payload: ReleaseInventoryReservationPayload, + context: ActionHandlerContext, +) { + const { legalEntityId } = context.scope; + if (legalEntityId === undefined) { + return yield* reservationReleaseUnavailable( + payload.releaseEffectId, + 'Release requires a trusted Legal Entity scope', + ); + } + const trustedLegalEntityId = yield* Schema.decodeEffect(LegalEntityIdSchema)(legalEntityId).pipe( + Effect.mapError((cause) => + reservationReleaseUnavailable(payload.releaseEffectId, 'Trusted Legal Entity identity is invalid', cause), + ), + ); + const sourceActionInvocationId = yield* Schema.decodeEffect(ActionInvocationIdSchema)( + context.actionInvocationId, + ).pipe( + Effect.mapError((cause) => + reservationReleaseUnavailable(payload.releaseEffectId, 'Action Invocation identity is invalid', cause), + ), + ); + const decision = yield* context.services.request(payload, { + actionInvocationId: sourceActionInvocationId, + legalEntityId: trustedLegalEntityId, + requestedAt: DateTime.formatIso(yield* DateTime.now), + tenantId: context.scope.tenantId, + }); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-reservation-release:${payload.releaseEffectId}`, + resultCount: decision.dispatchRequested ? 0 : 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.reservationRef.resourceId, + targetResourceType: payload.reservationRef.resourceType, + }); + if (decision.dispatchRequested) { + const eventPayload = { request: decision.result.effect.request }; + const event = yield* context.addDomainEvent({ + eventType: REQUESTED_EVENT, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: payload.reservationRef.resourceId, + subjectResourceType: payload.reservationRef.resourceType, + }); + yield* context.addOutboxMessage(event, createOutboxMessage(eventPayload)); + } + return decision.result; +}); + +export const releaseInventoryReservationAction = defineAction( + { + accessEvidencePolicy: { captureMode: 'metadata_only', policyKey: `${ACTION_KEY}.access.v1` }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.reservation.release', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.reservationRef.moduleId, + resourceId: payload.reservationRef.resourceId, + resourceType: payload.reservationRef.resourceType, + }, + tenantId: payload.reservationRef.tenantId, + }, + })), + domainErrorSchema: ReleaseInventoryReservationErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: ReleaseInventoryReservationPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.reservationRef, + })), + resultSchema: ReleaseInventoryReservationResultSchema, + schemaVersion: '1', + }, + handleReleaseInventoryReservation, + (transaction, scope) => { + const obligationPersistence = inventoryObligationPersistenceForScope(transaction, scope); + return Effect.succeed( + makeInventoryReservationReleaseService({ + effects: reservationReleaseEffectPersistenceForScope(transaction, scope), + ledger: makeInventoryEffectLedgerService( + inventoryEffectLedgerPersistenceForScope(transaction, scope), + DateTime.now.pipe(Effect.map(DateTime.formatIso)), + ), + makeMutationId: () => ReservationReleaseMutationIdSchema.make(randomUUID()), + obligations: { + read: (ref) => + obligationPersistence + .read(ref) + .pipe( + Effect.mapError((cause) => + reservationReleaseUnavailable(undefined, 'Inventory Reservation is unavailable', cause), + ), + ), + }, + }), + ); + }, +); + +// +export { createReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxMessage } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; +export { ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxPayloadSchema } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; +export { ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxProducerModuleKey } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; +export { ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxTopic } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; +export type { ReleaseInventoryReservationCommerceInventoryInventoryReservationReleaseRequestedV1OutboxPayload } from './release-inventory-reservation-commerce-inventory-inventory-reservation-release-requested-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/actions/resolve-inventory-source-conflict.action.ts b/app/verticals/inventory/src/actions/resolve-inventory-source-conflict.action.ts new file mode 100644 index 000000000..7d64d9dbe --- /dev/null +++ b/app/verticals/inventory/src/actions/resolve-inventory-source-conflict.action.ts @@ -0,0 +1,119 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug resolve-inventory-source-conflict +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { Effect } from 'effect'; + +import { + ResolveInventorySourceConflictErrorSchema, + ResolveInventorySourceConflictPayloadSchema, + ResolveInventorySourceConflictResultSchema, +} from '../../shared/actions/resolve-inventory-source-conflict.ts'; +import type { ResolveInventorySourceConflictPayload } from '../../shared/actions/resolve-inventory-source-conflict.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core composes the owner-local resolver inside this generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeExternalStockCorrelationResolver } from '../../shared/domain/external-stock-correlation.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { externalStockCorrelationPersistenceForScope } from '../persistence/external-stock-correlation-repository.ts'; +import { inventorySourceAssertionPersistenceForScope } from '../persistence/inventory-source-assertion-repository.ts'; +import { inventorySourceConflictPersistenceForScope } from '../persistence/inventory-source-conflict-repository.ts'; +import { stockPositionPersistenceForScope } from '../persistence/stock-position-repository.ts'; +import type { InventorySourceConflictService } from '../services/inventory-source-conflict.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makeInventorySourceConflictService } from '../services/inventory-source-conflict.service.ts'; + +export { + ResolveInventorySourceConflictErrorSchema, + ResolveInventorySourceConflictPayloadSchema, + ResolveInventorySourceConflictResultSchema, +} from '../../shared/actions/resolve-inventory-source-conflict.ts'; + +const ACTION_KEY = 'commerce.inventory.resolve-inventory-source-conflict'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = {} as const; + +export const handleResolveInventorySourceConflict = Effect.fn('ResolveInventorySourceConflictAction.handle')( + function* handle( + payload: ResolveInventorySourceConflictPayload, + context: ActionHandlerContext, + ) { + const conflict = yield* context.services.resolve(payload, { + principalId: context.scope.principalId, + tenantId: context.scope.tenantId, + }); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-source-conflict:${payload.conflictRef.resourceId}`, + resultCount: 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.conflictRef.resourceId, + targetResourceType: payload.conflictRef.resourceType, + }); + return { conflict }; + }, +); + +export const resolveInventorySourceConflictAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.resolve-inventory-source-conflict.access.v1', + }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.recovery.execute', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.conflictRef.moduleId, + resourceId: payload.conflictRef.resourceId, + resourceType: payload.conflictRef.resourceType, + }, + tenantId: payload.conflictRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: ResolveInventorySourceConflictErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: ResolveInventorySourceConflictPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.conflictRef, + })), + resultSchema: ResolveInventorySourceConflictResultSchema, + schemaVersion: '1', + }, + handleResolveInventorySourceConflict, + (transaction, scope) => + Effect.succeed( + makeInventorySourceConflictService({ + assertions: inventorySourceAssertionPersistenceForScope(transaction, scope), + backendConfigurations: inventoryBackendConfigurationPersistenceForScope(transaction, scope), + conflicts: inventorySourceConflictPersistenceForScope(transaction, scope), + correlations: makeExternalStockCorrelationResolver( + externalStockCorrelationPersistenceForScope(transaction, scope), + ), + positions: stockPositionPersistenceForScope(transaction, scope), + }), + ), +); + +// +// diff --git a/app/verticals/inventory/src/actions/select-inventory-backend.action.ts b/app/verticals/inventory/src/actions/select-inventory-backend.action.ts new file mode 100644 index 000000000..3cddf8f8f --- /dev/null +++ b/app/verticals/inventory/src/actions/select-inventory-backend.action.ts @@ -0,0 +1,100 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug select-inventory-backend +import type { ActionHandlerContext } from '@app/core-runtime'; +import { defineAction, defineActionBusinessPermission, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect } from 'effect'; + +import { + SelectInventoryBackendPayloadSchema, + SelectInventoryBackendResultSchema, +} from '../../shared/actions/select-inventory-backend.ts'; +import type { SelectInventoryBackendPayload } from '../../shared/actions/select-inventory-backend.ts'; +import { SelectInventoryBackendErrorSchema } from '../../shared/domain/inventory-backend-configuration.ts'; +import type { InventoryBackendConfigurationService } from '../services/inventory-backend-configuration.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the Action scope gate; expires: 2027-03-31. +import { makeInventoryBackendConfigurationService } from '../services/inventory-backend-configuration.service.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { inventorySourceAssertionPersistenceForScope } from '../persistence/inventory-source-assertion-repository.ts'; +import { inventorySourceConflictPersistenceForScope } from '../persistence/inventory-source-conflict-repository.ts'; +import { stockPositionPersistenceForScope } from '../persistence/stock-position-repository.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- This Action composes the owner-local conflict registrar in the same transaction so the declared non-success result commits its evidence; expires: 2027-03-31. +import { makeInventorySourceConflictService } from '../services/inventory-source-conflict.service.ts'; + +type Services = InventoryBackendConfigurationService; +const ACTION_KEY = 'commerce.inventory.select-inventory-backend'; +const MODULE_KEY = 'commerce.inventory'; +const domainEvents = {} as const; + +export const handleSelectInventoryBackend = Effect.fn('SelectInventoryBackendAction.handle')(function* handle( + payload: SelectInventoryBackendPayload, + context: ActionHandlerContext, +) { + const result = yield* context.services.select(payload, context.scope.tenantId); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `inventory-backend-configuration:${payload.customerConfigurationId}`, + resultCount: result.outcome === 'SELECTED' ? 0 : 1, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: result.configuration.configurationId, + targetResourceType: 'commerce.inventory.inventory-backend-configuration', + }); + return result; +}); + +export const selectInventoryBackendAction = defineAction( + { + accessEvidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.select-inventory-backend.access.v1', + }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload, scope) => ({ + permission: 'inventory.migration.manage', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.authorizationTargetRef.moduleId, + resourceId: payload.authorizationTargetRef.resourceId, + resourceType: payload.authorizationTargetRef.resourceType, + }, + tenantId: payload.authorizationTargetRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + })), + domainErrorSchema: SelectInventoryBackendErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + payloadSchema: SelectInventoryBackendPayloadSchema, + policies: [], + resultSchema: SelectInventoryBackendResultSchema, + schemaVersion: '1', + }, + handleSelectInventoryBackend, + (transaction, scope) => + Effect.sync(() => { + const backendConfigurations = inventoryBackendConfigurationPersistenceForScope(transaction, scope); + return makeInventoryBackendConfigurationService( + backendConfigurations, + makeInventorySourceConflictService({ + assertions: inventorySourceAssertionPersistenceForScope(transaction, scope), + backendConfigurations, + conflicts: inventorySourceConflictPersistenceForScope(transaction, scope), + positions: stockPositionPersistenceForScope(transaction, scope), + }), + ); + }), +); + +// +// diff --git a/app/verticals/inventory/src/actions/stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts b/app/verticals/inventory/src/actions/stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts new file mode 100644 index 000000000..4f9247b88 --- /dev/null +++ b/app/verticals/inventory/src/actions/stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.stock-issue +// @ontos-outbox-topic commerce.inventory.stock-issue-requested.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-stock-issue-requested-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-stock-issue-requested-v1'; + +export { + OutboxPayloadSchema as StockIssueCommerceInventoryStockIssueRequestedV1OutboxPayloadSchema, + outboxProducerModuleKey as StockIssueCommerceInventoryStockIssueRequestedV1OutboxProducerModuleKey, + outboxTopic as StockIssueCommerceInventoryStockIssueRequestedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-stock-issue-requested-v1'; +export type { OutboxPayload as StockIssueCommerceInventoryStockIssueRequestedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-stock-issue-requested-v1'; + +export const createStockIssueCommerceInventoryStockIssueRequestedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/stock-issue.action.ts b/app/verticals/inventory/src/actions/stock-issue.action.ts new file mode 100644 index 000000000..5e58c32d6 --- /dev/null +++ b/app/verticals/inventory/src/actions/stock-issue.action.ts @@ -0,0 +1,136 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug stock-issue +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect } from 'effect'; + +import { + StockIssueErrorSchema, + StockIssuePayloadSchema, + StockIssueResultSchema, +} from '../../shared/actions/stock-issue.ts'; +import type { StockIssuePayload } from '../../shared/actions/stock-issue.ts'; +import { OutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-stock-issue-requested-v1.ts'; +import { PhysicalStockEffectRejected } from '../../shared/domain/physical-stock-effect.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { physicalStockEffectPersistenceForScope } from '../persistence/physical-stock-effect-repository.ts'; +import { stockPositionPersistenceForScope } from '../persistence/stock-position-repository.ts'; +import type { PhysicalStockEffectRequestService } from '../services/physical-stock-effects.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- The generated owner Action factory constructs the transaction-scoped ledger service; expires: 2027-03-31. +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makePhysicalStockEffectRequestService } from '../services/physical-stock-effects.service.ts'; +import { createStockIssueCommerceInventoryStockIssueRequestedV1OutboxMessage as createOutboxMessage } from './stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts'; + +const ACTION_KEY = 'commerce.inventory.stock-issue'; +const MODULE_KEY = 'commerce.inventory'; +const EVENT_TYPE = 'commerce.inventory.stock-issue-requested.v1'; +const domainEvents = { [EVENT_TYPE]: OutboxPayloadSchema } as const; + +export const handleStockIssue = Effect.fn('StockIssueAction.handle')(function* handle( + payload: StockIssuePayload, + context: ActionHandlerContext, +) { + if (context.scope.legalEntityId === undefined) { + return yield* new PhysicalStockEffectRejected({ + code: 'physical_stock_effect_rejected', + effectId: payload.effectId, + reason: 'TENANT_SCOPE_MISMATCH', + }); + } + const result = yield* context.services.request('ISSUE', payload, { + actionInvocationId: context.actionInvocationId, + legalEntityId: context.scope.legalEntityId, + tenantId: context.scope.tenantId, + }); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `physical-stock-effect:${payload.effectId}`, + resultCount: result.outcome === 'EXACT_REPLAY' ? 1 : 0, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.positionRef.resourceId, + targetResourceType: payload.positionRef.resourceType, + }); + if (result.outcome === 'REQUESTED') { + const eventPayload = { request: result.effect.request }; + const event = yield* context.addDomainEvent({ + eventType: EVENT_TYPE, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: payload.positionRef.resourceId, + subjectResourceType: payload.positionRef.resourceType, + }); + yield* context.addOutboxMessage(event, createOutboxMessage(eventPayload)); + } + return result; +}); + +export const stockIssueAction = defineAction( + { + accessEvidencePolicy: { captureMode: 'metadata_only', policyKey: `${ACTION_KEY}.access.v1` }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.stock.issue', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.positionRef.moduleId, + resourceId: payload.positionRef.resourceId, + resourceType: payload.positionRef.resourceType, + }, + tenantId: payload.positionRef.tenantId, + }, + })), + domainErrorSchema: StockIssueErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: StockIssuePayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.positionRef, + })), + resultSchema: StockIssueResultSchema, + schemaVersion: '1', + }, + handleStockIssue, + (transaction, scope) => + Effect.succeed( + makePhysicalStockEffectRequestService({ + backendConfigurations: inventoryBackendConfigurationPersistenceForScope(transaction, scope), + effects: physicalStockEffectPersistenceForScope(transaction, scope), + ledger: makeInventoryEffectLedgerService( + inventoryEffectLedgerPersistenceForScope(transaction, scope), + DateTime.now.pipe(Effect.map(DateTime.formatIso)), + ), + positions: stockPositionPersistenceForScope(transaction, scope), + }), + ), +); + +// +export { createStockIssueCommerceInventoryStockIssueRequestedV1OutboxMessage } from './stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts'; +export { StockIssueCommerceInventoryStockIssueRequestedV1OutboxPayloadSchema } from './stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts'; +export { StockIssueCommerceInventoryStockIssueRequestedV1OutboxProducerModuleKey } from './stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts'; +export { StockIssueCommerceInventoryStockIssueRequestedV1OutboxTopic } from './stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts'; +export type { StockIssueCommerceInventoryStockIssueRequestedV1OutboxPayload } from './stock-issue-commerce-inventory-stock-issue-requested-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/actions/stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts b/app/verticals/inventory/src/actions/stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts new file mode 100644 index 000000000..49e33d2c8 --- /dev/null +++ b/app/verticals/inventory/src/actions/stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts @@ -0,0 +1,24 @@ +// @generated by OntOS Codesmith Outbox Message v2 +// @ontos-outbox-action commerce.inventory.stock-receipt +// @ontos-outbox-topic commerce.inventory.stock-receipt-requested.v1 +import type { OutboxMessage } from '@app/core-runtime'; +import { + outboxProducerModuleKey, + outboxTopic, +} from '@app/inventory/outbox/commerce-inventory-stock-receipt-requested-v1'; +import type { OutboxPayload } from '@app/inventory/outbox/commerce-inventory-stock-receipt-requested-v1'; + +export { + OutboxPayloadSchema as StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxPayloadSchema, + outboxProducerModuleKey as StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxProducerModuleKey, + outboxTopic as StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxTopic, +} from '@app/inventory/outbox/commerce-inventory-stock-receipt-requested-v1'; +export type { OutboxPayload as StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxPayload } from '@app/inventory/outbox/commerce-inventory-stock-receipt-requested-v1'; + +export const createStockReceiptCommerceInventoryStockReceiptRequestedV1OutboxMessage = ( + payload: OutboxPayload, +): OutboxMessage => ({ + payloadJson: payload, + producerModuleKey: outboxProducerModuleKey, + topic: outboxTopic, +}); diff --git a/app/verticals/inventory/src/actions/stock-receipt.action.ts b/app/verticals/inventory/src/actions/stock-receipt.action.ts new file mode 100644 index 000000000..306986dff --- /dev/null +++ b/app/verticals/inventory/src/actions/stock-receipt.action.ts @@ -0,0 +1,136 @@ +// @generated by OntOS Codesmith Action v1 +// @ontos-action-owner commerce.inventory +// @ontos-action-slug stock-receipt +import type { ActionHandlerContext } from '@app/core-runtime'; +import { + defineAction, + defineActionBusinessPermission, + defineActionResourcePermission, + defineTenantModuleEntrypoint, +} from '@app/core-runtime'; +import { DateTime, Effect } from 'effect'; + +import { + StockReceiptErrorSchema, + StockReceiptPayloadSchema, + StockReceiptResultSchema, +} from '../../shared/actions/stock-receipt.ts'; +import type { StockReceiptPayload } from '../../shared/actions/stock-receipt.ts'; +import { OutboxPayloadSchema } from '../../shared/outbox/commerce-inventory-stock-receipt-requested-v1.ts'; +import { PhysicalStockEffectRejected } from '../../shared/domain/physical-stock-effect.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { physicalStockEffectPersistenceForScope } from '../persistence/physical-stock-effect-repository.ts'; +import { stockPositionPersistenceForScope } from '../persistence/stock-position-repository.ts'; +import type { PhysicalStockEffectRequestService } from '../services/physical-stock-effects.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- The generated owner Action factory constructs the transaction-scoped ledger service; expires: 2027-03-31. +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local constructor only inside the generated transaction-scoped Action factory; expires: 2027-03-31. +import { makePhysicalStockEffectRequestService } from '../services/physical-stock-effects.service.ts'; +import { createStockReceiptCommerceInventoryStockReceiptRequestedV1OutboxMessage as createOutboxMessage } from './stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts'; + +const ACTION_KEY = 'commerce.inventory.stock-receipt'; +const MODULE_KEY = 'commerce.inventory'; +const EVENT_TYPE = 'commerce.inventory.stock-receipt-requested.v1'; +const domainEvents = { [EVENT_TYPE]: OutboxPayloadSchema } as const; + +export const handleStockReceipt = Effect.fn('StockReceiptAction.handle')(function* handle( + payload: StockReceiptPayload, + context: ActionHandlerContext, +) { + if (context.scope.legalEntityId === undefined) { + return yield* new PhysicalStockEffectRejected({ + code: 'physical_stock_effect_rejected', + effectId: payload.effectId, + reason: 'TENANT_SCOPE_MISMATCH', + }); + } + const result = yield* context.services.request('RECEIPT', payload, { + actionInvocationId: context.actionInvocationId, + legalEntityId: context.scope.legalEntityId, + tenantId: context.scope.tenantId, + }); + yield* context.recordDataAccess({ + accessKind: 'read', + queryHash: `physical-stock-effect:${payload.effectId}`, + resultCount: result.outcome === 'EXACT_REPLAY' ? 1 : 0, + servingModuleKey: MODULE_KEY, + targetModuleKey: MODULE_KEY, + targetResourceId: payload.positionRef.resourceId, + targetResourceType: payload.positionRef.resourceType, + }); + if (result.outcome === 'REQUESTED') { + const eventPayload = { request: result.effect.request }; + const event = yield* context.addDomainEvent({ + eventType: EVENT_TYPE, + payloadJson: eventPayload, + producerModuleKey: MODULE_KEY, + subjectModuleKey: MODULE_KEY, + subjectResourceId: payload.positionRef.resourceId, + subjectResourceType: payload.positionRef.resourceType, + }); + yield* context.addOutboxMessage(event, createOutboxMessage(eventPayload)); + } + return result; +}); + +export const stockReceiptAction = defineAction( + { + accessEvidencePolicy: { captureMode: 'metadata_only', policyKey: `${ACTION_KEY}.access.v1` }, + actionKey: ACTION_KEY, + auditProfile: 'standard', + businessPermission: defineActionBusinessPermission((payload) => ({ + permission: 'inventory.stock.receipt', + target: { + kind: 'inventory_resource', + resource: { + moduleId: payload.positionRef.moduleId, + resourceId: payload.positionRef.resourceId, + resourceType: payload.positionRef.resourceType, + }, + tenantId: payload.positionRef.tenantId, + }, + })), + domainErrorSchema: StockReceiptErrorSchema, + domainEvents, + entrypoint: defineTenantModuleEntrypoint({ + access: 'write', + authorization: { kind: 'action_execution', provisioning: 'explicit' }, + entrypointKey: ACTION_KEY, + moduleKey: MODULE_KEY, + role: 'action', + }), + idempotency: 'required', + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + payloadSchema: StockReceiptPayloadSchema, + policies: [], + resourcePermission: defineActionResourcePermission((payload) => ({ + permission: 'write', + resource: payload.positionRef, + })), + resultSchema: StockReceiptResultSchema, + schemaVersion: '1', + }, + handleStockReceipt, + (transaction, scope) => + Effect.succeed( + makePhysicalStockEffectRequestService({ + backendConfigurations: inventoryBackendConfigurationPersistenceForScope(transaction, scope), + effects: physicalStockEffectPersistenceForScope(transaction, scope), + ledger: makeInventoryEffectLedgerService( + inventoryEffectLedgerPersistenceForScope(transaction, scope), + DateTime.now.pipe(Effect.map(DateTime.formatIso)), + ), + positions: stockPositionPersistenceForScope(transaction, scope), + }), + ), +); + +// +export { createStockReceiptCommerceInventoryStockReceiptRequestedV1OutboxMessage } from './stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts'; +export { StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxPayloadSchema } from './stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts'; +export { StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxProducerModuleKey } from './stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts'; +export { StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxTopic } from './stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts'; +export type { StockReceiptCommerceInventoryStockReceiptRequestedV1OutboxPayload } from './stock-receipt-commerce-inventory-stock-receipt-requested-v1.outbox-message.ts'; +// diff --git a/app/verticals/inventory/src/api/action-gateway.ts b/app/verticals/inventory/src/api/action-gateway.ts new file mode 100644 index 000000000..855827190 --- /dev/null +++ b/app/verticals/inventory/src/api/action-gateway.ts @@ -0,0 +1,20 @@ +// @generated by OntOS Codesmith MicroVertical Action Boundary v1 +// @ontos-action-boundary-owner inventory +// @ontos-action-boundary-audience inventory +import { issueGatewayContext, makeOperationGateway as makeSharedOperationGateway } from '@app/shared-contracts'; +import type { + GatewayContextClientError, + OperationGatewayIssuer as SharedOperationGatewayIssuer, +} from '@app/shared-contracts'; + +export const ACTION_GATEWAY_AUDIENCE = 'inventory' as const; + +export type OperationGatewayIssuer = SharedOperationGatewayIssuer< + typeof ACTION_GATEWAY_AUDIENCE, + GatewayContextClientError +>; + +export const makeOperationGateway = (acquire: OperationGatewayIssuer = issueGatewayContext) => + makeSharedOperationGateway(ACTION_GATEWAY_AUDIENCE, acquire); + +export const operationGateway = makeOperationGateway(); diff --git a/app/verticals/inventory/src/api/catalog-to-stock-binding-resolution-client.ts b/app/verticals/inventory/src/api/catalog-to-stock-binding-resolution-client.ts new file mode 100644 index 000000000..10188f4b7 --- /dev/null +++ b/app/verticals/inventory/src/api/catalog-to-stock-binding-resolution-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { CatalogToStockBindingResolutionApi } from '../../shared/apis/catalog-to-stock-binding-resolution.ts'; +import type { CatalogToStockBindingResolutionRequest } from '../../shared/apis/catalog-to-stock-binding-resolution.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface CatalogToStockBindingResolutionClientOptions { + readonly baseUrl?: string | URL; +} + +type CatalogToStockBindingResolutionAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: CatalogToStockBindingResolutionClientOptions, +]; + +type CatalogToStockBindingResolutionOperationInvocation = readonly [ + requestCorrelation: string, + options?: CatalogToStockBindingResolutionClientOptions, +]; + +const catalogToStockBindingResolutionClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: CatalogToStockBindingResolutionClientOptions, +) => + makeGovernedEffectBffClient( + { + api: CatalogToStockBindingResolutionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeCatalogToStockBindingResolutionWithAuthorization = ( + payload: CatalogToStockBindingResolutionRequest, + ...[credential, requestCorrelation, options = {}]: CatalogToStockBindingResolutionAuthorizedInvocation +) => + catalogToStockBindingResolutionClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.catalogToStockBindingResolution.execute({ payload })), + ); + +export const executeCatalogToStockBindingResolution = ( + payload: CatalogToStockBindingResolutionRequest, + ...[requestCorrelation, options = {}]: CatalogToStockBindingResolutionOperationInvocation +) => + operationGateway.invoke((credential) => + executeCatalogToStockBindingResolutionWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/catalog-to-stock-binding-resolution.read.ts b/app/verticals/inventory/src/api/catalog-to-stock-binding-resolution.read.ts new file mode 100644 index 000000000..263ad2bbb --- /dev/null +++ b/app/verticals/inventory/src/api/catalog-to-stock-binding-resolution.read.ts @@ -0,0 +1,144 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Option, Schema } from 'effect'; +import { + CatalogToStockBindingResolutionRequestSchema, + CatalogToStockBindingResolutionResponseSchema, +} from '../../shared/apis/catalog-to-stock-binding-resolution.ts'; +import type { CatalogToStockBindingResolutionRequest } from '../../shared/apis/catalog-to-stock-binding-resolution.ts'; +import { + CatalogToStockBindingResolutionFailure, + failCatalogToStockBindingResolution, +} from '../../shared/domain/catalog-to-stock-binding-resolution.ts'; +import { CatalogToStockBindingUnavailable } from '../../shared/domain/catalog-to-stock-binding-unavailable.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this exact resolver inside the generated transaction-scoped owner factory after the governed Read scope gate; expires: 2027-03-31. +import { makeCatalogToStockBindingResolver } from '../../shared/domain/catalog-to-stock-binding.ts'; +import { InventoryBackendConfigurationPersistenceUnavailable } from '../../shared/domain/inventory-backend-configuration-persistence-unavailable.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +// oxlint-disable anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the governed Read scope gate; expires: 2027-03-31. +import { + catalogToStockBindingStockItemReader, + makeDrizzleCatalogToStockBindingPersistence, +} from '../persistence/catalog-to-stock-binding-repository.ts'; +// oxlint-enable anti-slop-effect/no-service-constructor-imports +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the governed Read scope gate; expires: 2027-03-31. +import { makeDrizzleStockItemRepository } from '../persistence/stock-item-repository.ts'; + +export const CatalogToStockBindingResolutionDomainErrorSchema = Schema.Union([ + CatalogToStockBindingResolutionFailure, + CatalogToStockBindingUnavailable, + InventoryBackendConfigurationPersistenceUnavailable, +]); +export type CatalogToStockBindingResolutionDomainError = typeof CatalogToStockBindingResolutionDomainErrorSchema.Type; + +interface CatalogToStockBindingResolutionServices { + readonly findCurrentConfiguration: ReturnType['findCurrent']; + readonly resolve: ReturnType['resolve']; +} + +const MODULE_KEY = 'commerce.inventory'; + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Catalog-to-Stock Binding was not found in the trusted Customer Configuration scope', + }); + +const mapResolutionFailure = (error: CatalogToStockBindingResolutionFailure) => + error.outcome === 'MISSING' ? notFound() : error; + +const mapResolutionError = (error: CatalogToStockBindingResolutionFailure | CatalogToStockBindingUnavailable) => + Schema.is(CatalogToStockBindingResolutionFailure)(error) ? mapResolutionFailure(error) : error; + +/** + * Before resolution there is no binding identity for the caller to know. The + * requested exact Catalog Selection therefore supplies the stable + * authorization subject, while the trusted operation scope supplies Tenant. + */ +export const catalogToStockBindingResolutionPermissionTarget = ( + input: CatalogToStockBindingResolutionRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => ({ + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource: { + moduleId: MODULE_KEY, + resourceId: input.demand.catalogSelection.productRef.resourceId, + resourceType: 'commerce.inventory.catalog-to-stock-binding', + }, + tenantId: input.demand.catalogSelection.productRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', +}); + +const catalogToStockBindingResolutionEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.catalog-to-stock-binding-resolution', + moduleKey: 'commerce.inventory', + role: 'api', +}); + +export const catalogToStockBindingResolutionRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: CatalogToStockBindingResolutionDomainErrorSchema, + entrypoint: catalogToStockBindingResolutionEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.catalog-to-stock-binding-resolution.evidence.v1', + }, + inputSchema: CatalogToStockBindingResolutionRequestSchema, + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.catalog-to-stock-binding-resolution', + resultSchema: CatalogToStockBindingResolutionResponseSchema, + schemaVersion: '1', + }, + ( + input: CatalogToStockBindingResolutionRequest, + context: ReadHandlerContext, + ) => { + if (input.demand.catalogSelection.productRef.tenantId !== context.scope.tenantId) { + return Effect.fail(notFound()); + } + return context.services.findCurrentConfiguration(input.customerConfigurationId).pipe( + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(notFound()), + onSome: (configuration) => + configuration.tenantId !== context.scope.tenantId || + configuration.customerConfigurationId !== input.customerConfigurationId + ? Effect.fail(notFound()) + : context.services.resolve(input.demand).pipe( + Effect.catchTag('CatalogToStockBindingRejected', failCatalogToStockBindingResolution), + Effect.mapError(mapResolutionError), + Effect.map((resolution) => ({ + evidence: { resultCount: 1 }, + result: { + customerConfigurationId: input.customerConfigurationId, + outcome: 'RESOLVED' as const, + resolution, + }, + })), + ), + }), + ), + ); + }, + (transaction, scope) => { + const bindings = makeDrizzleCatalogToStockBindingPersistence(transaction); + const stockItems = makeDrizzleStockItemRepository(transaction); + return Effect.succeed({ + findCurrentConfiguration: inventoryBackendConfigurationPersistenceForScope(transaction, scope).findCurrent, + resolve: makeCatalogToStockBindingResolver(bindings, catalogToStockBindingStockItemReader(stockItems)).resolve, + }); + }, + catalogToStockBindingResolutionPermissionTarget, +); diff --git a/app/verticals/inventory/src/api/change-stock-sharing-eligibility-action-client.ts b/app/verticals/inventory/src/api/change-stock-sharing-eligibility-action-client.ts new file mode 100644 index 000000000..85c916b9e --- /dev/null +++ b/app/verticals/inventory/src/api/change-stock-sharing-eligibility-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug change-stock-sharing-eligibility +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + ChangeStockSharingEligibilityActionApi, + ChangeStockSharingEligibilityPayloadSchema, +} from '../../shared/apis/change-stock-sharing-eligibility-action.ts'; +import type { ChangeStockSharingEligibilityPayload } from '../../shared/actions/change-stock-sharing-eligibility.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface ChangeStockSharingEligibilityActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: ChangeStockSharingEligibilityActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: ChangeStockSharingEligibilityActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: ChangeStockSharingEligibilityActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: ChangeStockSharingEligibilityActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeChangeStockSharingEligibilityWithAuthorization = ( + payload: ChangeStockSharingEligibilityPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(ChangeStockSharingEligibilityPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.changeStockSharingEligibilityAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeChangeStockSharingEligibility = ( + payload: ChangeStockSharingEligibilityPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeChangeStockSharingEligibilityWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/commitment-protection-verification-client.ts b/app/verticals/inventory/src/api/commitment-protection-verification-client.ts new file mode 100644 index 000000000..2c939de3a --- /dev/null +++ b/app/verticals/inventory/src/api/commitment-protection-verification-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { CommitmentProtectionVerificationApi } from '../../shared/apis/commitment-protection-verification.ts'; +import type { CommitmentProtectionVerificationRequest } from '../../shared/apis/commitment-protection-verification.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface CommitmentProtectionVerificationClientOptions { + readonly baseUrl?: string | URL; +} + +type CommitmentProtectionVerificationAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: CommitmentProtectionVerificationClientOptions, +]; + +type CommitmentProtectionVerificationOperationInvocation = readonly [ + requestCorrelation: string, + options?: CommitmentProtectionVerificationClientOptions, +]; + +const commitmentProtectionVerificationClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: CommitmentProtectionVerificationClientOptions, +) => + makeGovernedEffectBffClient( + { + api: CommitmentProtectionVerificationApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeCommitmentProtectionVerificationWithAuthorization = ( + payload: CommitmentProtectionVerificationRequest, + ...[credential, requestCorrelation, options = {}]: CommitmentProtectionVerificationAuthorizedInvocation +) => + commitmentProtectionVerificationClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.commitmentProtectionVerification.execute({ payload })), + ); + +export const executeCommitmentProtectionVerification = ( + payload: CommitmentProtectionVerificationRequest, + ...[requestCorrelation, options = {}]: CommitmentProtectionVerificationOperationInvocation +) => + operationGateway.invoke((credential) => + executeCommitmentProtectionVerificationWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/commitment-protection-verification.read.ts b/app/verticals/inventory/src/api/commitment-protection-verification.read.ts new file mode 100644 index 000000000..7a3a30bfb --- /dev/null +++ b/app/verticals/inventory/src/api/commitment-protection-verification.read.ts @@ -0,0 +1,136 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Option, Schema } from 'effect'; +import { + CommitmentProtectionVerificationRequestSchema, + CommitmentProtectionVerificationResponseSchema, +} from '../../shared/apis/commitment-protection-verification.ts'; +import type { + CommitmentProtectionVerificationRequest, + CommitmentProtectionVerificationResponse, +} from '../../shared/apis/commitment-protection-verification.ts'; +import { + CommitmentProtectionRejected, + CommitmentProtectionUnavailable, +} from '../../shared/domain/commitment-protection.ts'; +import type { CommitmentProtectionPersistence } from '../../shared/domain/commitment-protection.ts'; +import { commitmentProtectionPersistenceForScope } from '../persistence/commitment-protection-repository.ts'; + +export const CommitmentProtectionVerificationDomainErrorSchema = Schema.Union([ + CommitmentProtectionRejected, + CommitmentProtectionUnavailable, +]); +export type CommitmentProtectionVerificationDomainError = typeof CommitmentProtectionVerificationDomainErrorSchema.Type; + +const MODULE_KEY = 'commerce.inventory'; + +const sameResourceRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Commitment Protection was not found', + }); + +export const commitmentProtectionVerificationPermissionTarget = ( + input: CommitmentProtectionVerificationRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => ({ + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource: input.protectionRef, + tenantId: input.protectionRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', +}); + +const commitmentProtectionVerificationEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.commitment-protection-verification', + moduleKey: MODULE_KEY, + role: 'api', +}); + +export const commitmentProtectionVerificationRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: CommitmentProtectionVerificationDomainErrorSchema, + entrypoint: commitmentProtectionVerificationEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.commitment-protection-verification.evidence.v1', + }, + inputSchema: CommitmentProtectionVerificationRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.commitment-protection-verification', + resultSchema: CommitmentProtectionVerificationResponseSchema, + schemaVersion: '1', + }, + (input: CommitmentProtectionVerificationRequest, context: ReadHandlerContext) => { + if ( + input.protectionRef.tenantId !== context.scope.tenantId || + input.reservationRef.tenantId !== context.scope.tenantId + ) { + return Effect.fail(notFound()); + } + return context.services.findByRef(input.protectionRef).pipe( + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(notFound()), + onSome: Effect.succeed, + }), + ), + Effect.flatMap((protection) => { + if ( + protection.confirmation.reservation.origin.attemptId !== input.attemptId || + !sameResourceRef(protection.confirmation.reservation.ref, input.reservationRef) + ) { + return Effect.fail( + new CommitmentProtectionRejected({ + code: 'commitment_protection_rejected', + effectId: protection.authorityEvidence.effectId, + reason: 'CONFIRMATION_SCOPE_MISMATCH', + }), + ); + } + const result: CommitmentProtectionVerificationResponse = + protection.health.state === 'PROTECTED' + ? { _tag: 'PROTECTED', nextStep: 'CONTINUE', protection } + : { + _tag: 'AT_RISK', + nextStep: 'RECONCILE', + protection, + reconciliationRequired: true, + }; + return Effect.succeed({ evidence: { resultCount: 1 }, result }); + }), + ); + }, + (transaction, scope) => Effect.succeed(commitmentProtectionPersistenceForScope(transaction, scope)), + commitmentProtectionVerificationPermissionTarget, +); diff --git a/app/verticals/inventory/src/api/compensate-inventory-pre-commit-action-client.ts b/app/verticals/inventory/src/api/compensate-inventory-pre-commit-action-client.ts new file mode 100644 index 000000000..1fd26e499 --- /dev/null +++ b/app/verticals/inventory/src/api/compensate-inventory-pre-commit-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug compensate-inventory-pre-commit +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + CompensateInventoryPreCommitActionApi, + CompensateInventoryPreCommitPayloadSchema, +} from '../../shared/apis/compensate-inventory-pre-commit-action.ts'; +import type { CompensateInventoryPreCommitPayload } from '../../shared/actions/compensate-inventory-pre-commit.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface CompensateInventoryPreCommitActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: CompensateInventoryPreCommitActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: CompensateInventoryPreCommitActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: CompensateInventoryPreCommitActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: CompensateInventoryPreCommitActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeCompensateInventoryPreCommitWithAuthorization = ( + payload: CompensateInventoryPreCommitPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(CompensateInventoryPreCommitPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.compensateInventoryPreCommitAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeCompensateInventoryPreCommit = ( + payload: CompensateInventoryPreCommitPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeCompensateInventoryPreCommitWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/correct-catalog-to-stock-binding-action-client.ts b/app/verticals/inventory/src/api/correct-catalog-to-stock-binding-action-client.ts new file mode 100644 index 000000000..883a2639f --- /dev/null +++ b/app/verticals/inventory/src/api/correct-catalog-to-stock-binding-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-catalog-to-stock-binding +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + CorrectCatalogToStockBindingActionApi, + CorrectCatalogToStockBindingPayloadSchema, +} from '../../shared/apis/correct-catalog-to-stock-binding-action.ts'; +import type { CorrectCatalogToStockBindingPayload } from '../../shared/actions/correct-catalog-to-stock-binding.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface CorrectCatalogToStockBindingActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: CorrectCatalogToStockBindingActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: CorrectCatalogToStockBindingActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: CorrectCatalogToStockBindingActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: CorrectCatalogToStockBindingActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeCorrectCatalogToStockBindingWithAuthorization = ( + payload: CorrectCatalogToStockBindingPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(CorrectCatalogToStockBindingPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.correctCatalogToStockBindingAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeCorrectCatalogToStockBinding = ( + payload: CorrectCatalogToStockBindingPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeCorrectCatalogToStockBindingWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/correct-external-stock-correlation-action-client.ts b/app/verticals/inventory/src/api/correct-external-stock-correlation-action-client.ts new file mode 100644 index 000000000..b4ab0b4bd --- /dev/null +++ b/app/verticals/inventory/src/api/correct-external-stock-correlation-action-client.ts @@ -0,0 +1,74 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-external-stock-correlation +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + CorrectExternalStockCorrelationActionApi, + CorrectExternalStockCorrelationPayloadSchema, +} from '../../shared/apis/correct-external-stock-correlation-action.ts'; +import type { CorrectExternalStockCorrelationPayload } from '../../shared/actions/correct-external-stock-correlation.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface CorrectExternalStockCorrelationActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: CorrectExternalStockCorrelationActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: CorrectExternalStockCorrelationActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: CorrectExternalStockCorrelationActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { + api: CorrectExternalStockCorrelationActionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeCorrectExternalStockCorrelationWithAuthorization = ( + payload: CorrectExternalStockCorrelationPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(CorrectExternalStockCorrelationPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.correctExternalStockCorrelationAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeCorrectExternalStockCorrelation = ( + payload: CorrectExternalStockCorrelationPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeCorrectExternalStockCorrelationWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/correct-stock-position-action-client.ts b/app/verticals/inventory/src/api/correct-stock-position-action-client.ts new file mode 100644 index 000000000..71a2e4af2 --- /dev/null +++ b/app/verticals/inventory/src/api/correct-stock-position-action-client.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug correct-stock-position +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + CorrectStockPositionActionApi, + CorrectStockPositionPayloadSchema, +} from '../../shared/apis/correct-stock-position-action.ts'; +import type { CorrectStockPositionPayload } from '../../shared/actions/correct-stock-position.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface CorrectStockPositionActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: CorrectStockPositionActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: CorrectStockPositionActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: CorrectStockPositionActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: CorrectStockPositionActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeCorrectStockPositionWithAuthorization = ( + payload: CorrectStockPositionPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(CorrectStockPositionPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.correctStockPositionAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeCorrectStockPosition = ( + payload: CorrectStockPositionPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => executeCorrectStockPositionWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/create-inventory-reservation-action-client.ts b/app/verticals/inventory/src/api/create-inventory-reservation-action-client.ts new file mode 100644 index 000000000..781fd445f --- /dev/null +++ b/app/verticals/inventory/src/api/create-inventory-reservation-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug create-inventory-reservation +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + CreateInventoryReservationActionApi, + CreateInventoryReservationPayloadSchema, +} from '../../shared/apis/create-inventory-reservation-action.ts'; +import type { CreateInventoryReservationPayload } from '../../shared/actions/create-inventory-reservation.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface CreateInventoryReservationActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: CreateInventoryReservationActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: CreateInventoryReservationActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: CreateInventoryReservationActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: CreateInventoryReservationActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeCreateInventoryReservationWithAuthorization = ( + payload: CreateInventoryReservationPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(CreateInventoryReservationPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.createInventoryReservationAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeCreateInventoryReservation = ( + payload: CreateInventoryReservationPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeCreateInventoryReservationWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/current-stock-evidence-for-availability-client.ts b/app/verticals/inventory/src/api/current-stock-evidence-for-availability-client.ts new file mode 100644 index 000000000..cfc29816d --- /dev/null +++ b/app/verticals/inventory/src/api/current-stock-evidence-for-availability-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { CurrentStockEvidenceForAvailabilityApi } from '../../shared/apis/current-stock-evidence-for-availability.ts'; +import type { CurrentStockEvidenceForAvailabilityRequest } from '../../shared/apis/current-stock-evidence-for-availability.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface CurrentStockEvidenceForAvailabilityClientOptions { + readonly baseUrl?: string | URL; +} + +type CurrentStockEvidenceForAvailabilityAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: CurrentStockEvidenceForAvailabilityClientOptions, +]; + +type CurrentStockEvidenceForAvailabilityOperationInvocation = readonly [ + requestCorrelation: string, + options?: CurrentStockEvidenceForAvailabilityClientOptions, +]; + +const currentStockEvidenceForAvailabilityClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: CurrentStockEvidenceForAvailabilityClientOptions, +) => + makeGovernedEffectBffClient( + { + api: CurrentStockEvidenceForAvailabilityApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeCurrentStockEvidenceForAvailabilityWithAuthorization = ( + payload: CurrentStockEvidenceForAvailabilityRequest, + ...[credential, requestCorrelation, options = {}]: CurrentStockEvidenceForAvailabilityAuthorizedInvocation +) => + currentStockEvidenceForAvailabilityClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.currentStockEvidenceForAvailability.execute({ payload })), + ); + +export const executeCurrentStockEvidenceForAvailability = ( + payload: CurrentStockEvidenceForAvailabilityRequest, + ...[requestCorrelation, options = {}]: CurrentStockEvidenceForAvailabilityOperationInvocation +) => + operationGateway.invoke((credential) => + executeCurrentStockEvidenceForAvailabilityWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/current-stock-evidence-for-availability.read.ts b/app/verticals/inventory/src/api/current-stock-evidence-for-availability.read.ts new file mode 100644 index 000000000..7e9b576d3 --- /dev/null +++ b/app/verticals/inventory/src/api/current-stock-evidence-for-availability.read.ts @@ -0,0 +1,104 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; +import { + CurrentStockEvidenceForAvailabilityRequestSchema, + CurrentStockEvidenceForAvailabilityResponseSchema, +} from '../../shared/apis/current-stock-evidence-for-availability.ts'; +import type { CurrentStockEvidenceForAvailabilityRequest } from '../../shared/apis/current-stock-evidence-for-availability.ts'; +import { + CurrentStockEvidenceForAvailabilityRejected, + CurrentStockEvidenceForAvailabilityUnavailable, +} from '../../shared/domain/current-stock-evidence-for-availability.ts'; +import { currentStockEvidenceForAvailabilityDependenciesForScope } from '../persistence/current-stock-evidence-for-availability-repository.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the governed Read scope gate; expires: 2027-03-31. +import { makeCurrentStockEvidenceForAvailabilityService } from '../services/current-stock-evidence-for-availability.service.ts'; + +type CurrentStockEvidenceForAvailabilityService = ReturnType; + +export const CurrentStockEvidenceForAvailabilityDomainErrorSchema = Schema.Union([ + CurrentStockEvidenceForAvailabilityRejected, + CurrentStockEvidenceForAvailabilityUnavailable, +]); +export type CurrentStockEvidenceForAvailabilityDomainError = + typeof CurrentStockEvidenceForAvailabilityDomainErrorSchema.Type; + +const MODULE_KEY = 'commerce.inventory'; + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Stock Position was not found', + }); + +const mapReadFailure = (error: CurrentStockEvidenceForAvailabilityDomainError) => + Schema.is(CurrentStockEvidenceForAvailabilityRejected)(error) && error.reason === 'POSITION_NOT_FOUND' + ? notFound() + : error; + +export const currentStockEvidenceForAvailabilityPermissionTarget = ( + input: CurrentStockEvidenceForAvailabilityRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => ({ + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource: { + moduleId: input.positionRef.moduleId, + resourceId: input.positionRef.resourceId, + resourceType: input.positionRef.resourceType, + }, + tenantId: input.positionRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', +}); + +const currentStockEvidenceForAvailabilityEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.current-stock-evidence-for-availability', + moduleKey: 'commerce.inventory', + role: 'api', +}); + +export const currentStockEvidenceForAvailabilityRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: CurrentStockEvidenceForAvailabilityDomainErrorSchema, + entrypoint: currentStockEvidenceForAvailabilityEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.current-stock-evidence-for-availability.evidence.v1', + }, + inputSchema: CurrentStockEvidenceForAvailabilityRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.current-stock-evidence-for-availability', + resultSchema: CurrentStockEvidenceForAvailabilityResponseSchema, + schemaVersion: '1', + }, + ( + input: CurrentStockEvidenceForAvailabilityRequest, + context: ReadHandlerContext, + ) => { + if (input.positionRef.tenantId !== context.scope.tenantId) { + return Effect.fail(notFound()); + } + return context.services.read(input.positionRef).pipe( + Effect.mapError(mapReadFailure), + Effect.map((evidence) => ({ evidence: { resultCount: 1 }, result: { evidence } })), + ); + }, + (transaction, scope) => + Effect.succeed( + makeCurrentStockEvidenceForAvailabilityService( + currentStockEvidenceForAvailabilityDependenciesForScope(transaction, scope), + ), + ), + currentStockEvidenceForAvailabilityPermissionTarget, +); diff --git a/app/verticals/inventory/src/api/end-catalog-to-stock-binding-action-client.ts b/app/verticals/inventory/src/api/end-catalog-to-stock-binding-action-client.ts new file mode 100644 index 000000000..b21d65be6 --- /dev/null +++ b/app/verticals/inventory/src/api/end-catalog-to-stock-binding-action-client.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-catalog-to-stock-binding +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EndCatalogToStockBindingActionApi, + EndCatalogToStockBindingPayloadSchema, +} from '../../shared/apis/end-catalog-to-stock-binding-action.ts'; +import type { EndCatalogToStockBindingPayload } from '../../shared/actions/end-catalog-to-stock-binding.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EndCatalogToStockBindingActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EndCatalogToStockBindingActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: EndCatalogToStockBindingActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EndCatalogToStockBindingActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: EndCatalogToStockBindingActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeEndCatalogToStockBindingWithAuthorization = ( + payload: EndCatalogToStockBindingPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EndCatalogToStockBindingPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.endCatalogToStockBindingAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEndCatalogToStockBinding = ( + payload: EndCatalogToStockBindingPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => executeEndCatalogToStockBindingWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/end-external-stock-correlation-action-client.ts b/app/verticals/inventory/src/api/end-external-stock-correlation-action-client.ts new file mode 100644 index 000000000..575330738 --- /dev/null +++ b/app/verticals/inventory/src/api/end-external-stock-correlation-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-external-stock-correlation +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EndExternalStockCorrelationActionApi, + EndExternalStockCorrelationPayloadSchema, +} from '../../shared/apis/end-external-stock-correlation-action.ts'; +import type { EndExternalStockCorrelationPayload } from '../../shared/actions/end-external-stock-correlation.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EndExternalStockCorrelationActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EndExternalStockCorrelationActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: EndExternalStockCorrelationActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EndExternalStockCorrelationActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: EndExternalStockCorrelationActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeEndExternalStockCorrelationWithAuthorization = ( + payload: EndExternalStockCorrelationPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EndExternalStockCorrelationPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.endExternalStockCorrelationAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEndExternalStockCorrelation = ( + payload: EndExternalStockCorrelationPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeEndExternalStockCorrelationWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/end-stock-sharing-eligibility-action-client.ts b/app/verticals/inventory/src/api/end-stock-sharing-eligibility-action-client.ts new file mode 100644 index 000000000..87a6dff65 --- /dev/null +++ b/app/verticals/inventory/src/api/end-stock-sharing-eligibility-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug end-stock-sharing-eligibility +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EndStockSharingEligibilityActionApi, + EndStockSharingEligibilityPayloadSchema, +} from '../../shared/apis/end-stock-sharing-eligibility-action.ts'; +import type { EndStockSharingEligibilityPayload } from '../../shared/actions/end-stock-sharing-eligibility.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EndStockSharingEligibilityActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EndStockSharingEligibilityActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: EndStockSharingEligibilityActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EndStockSharingEligibilityActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: EndStockSharingEligibilityActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeEndStockSharingEligibilityWithAuthorization = ( + payload: EndStockSharingEligibilityPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EndStockSharingEligibilityPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.endStockSharingEligibilityAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEndStockSharingEligibility = ( + payload: EndStockSharingEligibilityPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeEndStockSharingEligibilityWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/establish-catalog-to-stock-binding-action-client.ts b/app/verticals/inventory/src/api/establish-catalog-to-stock-binding-action-client.ts new file mode 100644 index 000000000..86ba79394 --- /dev/null +++ b/app/verticals/inventory/src/api/establish-catalog-to-stock-binding-action-client.ts @@ -0,0 +1,74 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-catalog-to-stock-binding +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EstablishCatalogToStockBindingActionApi, + EstablishCatalogToStockBindingPayloadSchema, +} from '../../shared/apis/establish-catalog-to-stock-binding-action.ts'; +import type { EstablishCatalogToStockBindingPayload } from '../../shared/actions/establish-catalog-to-stock-binding.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EstablishCatalogToStockBindingActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EstablishCatalogToStockBindingActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: EstablishCatalogToStockBindingActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EstablishCatalogToStockBindingActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { + api: EstablishCatalogToStockBindingActionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeEstablishCatalogToStockBindingWithAuthorization = ( + payload: EstablishCatalogToStockBindingPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EstablishCatalogToStockBindingPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.establishCatalogToStockBindingAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEstablishCatalogToStockBinding = ( + payload: EstablishCatalogToStockBindingPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeEstablishCatalogToStockBindingWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/establish-commitment-protection-action-client.ts b/app/verticals/inventory/src/api/establish-commitment-protection-action-client.ts new file mode 100644 index 000000000..5e90afd6b --- /dev/null +++ b/app/verticals/inventory/src/api/establish-commitment-protection-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-commitment-protection +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EstablishCommitmentProtectionActionApi, + EstablishCommitmentProtectionPayloadSchema, +} from '../../shared/apis/establish-commitment-protection-action.ts'; +import type { EstablishCommitmentProtectionPayload } from '../../shared/actions/establish-commitment-protection.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EstablishCommitmentProtectionActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EstablishCommitmentProtectionActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: EstablishCommitmentProtectionActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EstablishCommitmentProtectionActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: EstablishCommitmentProtectionActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeEstablishCommitmentProtectionWithAuthorization = ( + payload: EstablishCommitmentProtectionPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EstablishCommitmentProtectionPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.establishCommitmentProtectionAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEstablishCommitmentProtection = ( + payload: EstablishCommitmentProtectionPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeEstablishCommitmentProtectionWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/establish-external-stock-correlation-action-client.ts b/app/verticals/inventory/src/api/establish-external-stock-correlation-action-client.ts new file mode 100644 index 000000000..f1feb4db5 --- /dev/null +++ b/app/verticals/inventory/src/api/establish-external-stock-correlation-action-client.ts @@ -0,0 +1,74 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-external-stock-correlation +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EstablishExternalStockCorrelationActionApi, + EstablishExternalStockCorrelationPayloadSchema, +} from '../../shared/apis/establish-external-stock-correlation-action.ts'; +import type { EstablishExternalStockCorrelationPayload } from '../../shared/actions/establish-external-stock-correlation.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EstablishExternalStockCorrelationActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EstablishExternalStockCorrelationActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: EstablishExternalStockCorrelationActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EstablishExternalStockCorrelationActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { + api: EstablishExternalStockCorrelationActionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeEstablishExternalStockCorrelationWithAuthorization = ( + payload: EstablishExternalStockCorrelationPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EstablishExternalStockCorrelationPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.establishExternalStockCorrelationAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEstablishExternalStockCorrelation = ( + payload: EstablishExternalStockCorrelationPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeEstablishExternalStockCorrelationWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/establish-stock-sharing-eligibility-action-client.ts b/app/verticals/inventory/src/api/establish-stock-sharing-eligibility-action-client.ts new file mode 100644 index 000000000..7f7167745 --- /dev/null +++ b/app/verticals/inventory/src/api/establish-stock-sharing-eligibility-action-client.ts @@ -0,0 +1,74 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug establish-stock-sharing-eligibility +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + EstablishStockSharingEligibilityActionApi, + EstablishStockSharingEligibilityPayloadSchema, +} from '../../shared/apis/establish-stock-sharing-eligibility-action.ts'; +import type { EstablishStockSharingEligibilityPayload } from '../../shared/actions/establish-stock-sharing-eligibility.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface EstablishStockSharingEligibilityActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: EstablishStockSharingEligibilityActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: EstablishStockSharingEligibilityActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: EstablishStockSharingEligibilityActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { + api: EstablishStockSharingEligibilityActionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeEstablishStockSharingEligibilityWithAuthorization = ( + payload: EstablishStockSharingEligibilityPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(EstablishStockSharingEligibilityPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.establishStockSharingEligibilityAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeEstablishStockSharingEligibility = ( + payload: EstablishStockSharingEligibilityPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeEstablishStockSharingEligibilityWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/import-source-assertion-action-client.ts b/app/verticals/inventory/src/api/import-source-assertion-action-client.ts new file mode 100644 index 000000000..b11c9ca9a --- /dev/null +++ b/app/verticals/inventory/src/api/import-source-assertion-action-client.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug import-source-assertion +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + ImportSourceAssertionActionApi, + ImportSourceAssertionPayloadSchema, +} from '../../shared/apis/import-source-assertion-action.ts'; +import type { ImportSourceAssertionPayload } from '../../shared/actions/import-source-assertion.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface ImportSourceAssertionActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: ImportSourceAssertionActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: ImportSourceAssertionActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: ImportSourceAssertionActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: ImportSourceAssertionActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeImportSourceAssertionWithAuthorization = ( + payload: ImportSourceAssertionPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(ImportSourceAssertionPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.importSourceAssertionAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeImportSourceAssertion = ( + payload: ImportSourceAssertionPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => executeImportSourceAssertionWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/inventory-backend-configuration-current-client.ts b/app/verticals/inventory/src/api/inventory-backend-configuration-current-client.ts new file mode 100644 index 000000000..ba9a9e783 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-backend-configuration-current-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { InventoryBackendConfigurationCurrentApi } from '../../shared/apis/inventory-backend-configuration-current.ts'; +import type { InventoryBackendConfigurationCurrentRequest } from '../../shared/apis/inventory-backend-configuration-current.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface InventoryBackendConfigurationCurrentClientOptions { + readonly baseUrl?: string | URL; +} + +type InventoryBackendConfigurationCurrentAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: InventoryBackendConfigurationCurrentClientOptions, +]; + +type InventoryBackendConfigurationCurrentOperationInvocation = readonly [ + requestCorrelation: string, + options?: InventoryBackendConfigurationCurrentClientOptions, +]; + +const inventoryBackendConfigurationCurrentClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: InventoryBackendConfigurationCurrentClientOptions, +) => + makeGovernedEffectBffClient( + { + api: InventoryBackendConfigurationCurrentApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeInventoryBackendConfigurationCurrentWithAuthorization = ( + payload: InventoryBackendConfigurationCurrentRequest, + ...[credential, requestCorrelation, options = {}]: InventoryBackendConfigurationCurrentAuthorizedInvocation +) => + inventoryBackendConfigurationCurrentClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.inventoryBackendConfigurationCurrent.execute({ payload })), + ); + +export const executeInventoryBackendConfigurationCurrent = ( + payload: InventoryBackendConfigurationCurrentRequest, + ...[requestCorrelation, options = {}]: InventoryBackendConfigurationCurrentOperationInvocation +) => + operationGateway.invoke((credential) => + executeInventoryBackendConfigurationCurrentWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/inventory-backend-configuration-current.read.ts b/app/verticals/inventory/src/api/inventory-backend-configuration-current.read.ts new file mode 100644 index 000000000..cc844377b --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-backend-configuration-current.read.ts @@ -0,0 +1,68 @@ +// @generated by OntOS Codesmith module-api v1 +import type { ReadHandlerContext } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Option } from 'effect'; +import { + InventoryBackendConfigurationCurrentRequestSchema, + InventoryBackendConfigurationCurrentResponseSchema, +} from '../../shared/apis/inventory-backend-configuration-current.ts'; +import type { InventoryBackendConfigurationCurrentRequest } from '../../shared/apis/inventory-backend-configuration-current.ts'; +import { InventoryBackendConfigurationPersistenceUnavailable } from '../../shared/domain/inventory-backend-configuration-persistence-unavailable.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import type { InventoryBackendConfigurationService } from '../services/inventory-backend-configuration.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the governed Read scope gate; expires: 2027-03-31. +import { makeInventoryBackendConfigurationService } from '../services/inventory-backend-configuration.service.ts'; + +export type InventoryBackendConfigurationCurrentDomainError = InventoryBackendConfigurationPersistenceUnavailable; +const MODULE_KEY = 'commerce.inventory'; + +const inventoryBackendConfigurationCurrentEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'authenticated_principal' }, + entrypointKey: 'commerce.inventory.api.inventory-backend-configuration-current', + moduleKey: MODULE_KEY, + role: 'api', +}); + +export const inventoryBackendConfigurationCurrentRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: InventoryBackendConfigurationPersistenceUnavailable, + entrypoint: inventoryBackendConfigurationCurrentEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.inventory-backend-configuration-current.evidence.v1', + }, + inputSchema: InventoryBackendConfigurationCurrentRequestSchema, + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + permissionTarget: 'module', + policies: [], + readKey: 'commerce.inventory.api.inventory-backend-configuration-current', + resultSchema: InventoryBackendConfigurationCurrentResponseSchema, + schemaVersion: '1', + }, + ( + input: InventoryBackendConfigurationCurrentRequest, + context: ReadHandlerContext, + ) => + context.services.findCurrent(input.customerConfigurationId).pipe( + Effect.flatMap( + Option.match({ + onNone: () => + Effect.fail( + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'No Inventory Backend is selected for this Customer Configuration', + }), + ), + onSome: (configuration) => Effect.succeed({ evidence: { resultCount: 1 }, result: { configuration } }), + }), + ), + ), + (transaction, scope) => + Effect.succeed( + makeInventoryBackendConfigurationService(inventoryBackendConfigurationPersistenceForScope(transaction, scope)), + ), + () => ({ kind: 'module', moduleId: MODULE_KEY }), +); diff --git a/app/verticals/inventory/src/api/inventory-client.ts b/app/verticals/inventory/src/api/inventory-client.ts new file mode 100644 index 000000000..5e99ed5a3 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-client.ts @@ -0,0 +1,96 @@ +// @generated by OntOS Codesmith public API client v1 +/* eslint-disable oxc/no-barrel-file, sonarjs/no-wildcard-import -- The Codesmith Action HTTP boundary requires star exports in this generated client slot; expires: 2027-03-31. */ +import { Effect, makeEffectHttpApiClient } from '@modern-js/bff-effect/effect-client'; +import type { + HttpClientError, + HttpApi, + HttpApiClient, + HttpApiGroup, + Schema, +} from '@modern-js/bff-effect/effect-client'; + +import { inventoryApiContract, inventoryApi, inventoryOperationContexts } from '../../shared/api'; +import type { InventoryReadiness, OperationContext } from '../../shared/api'; + +// oxlint-disable-next-line effect-native/no-scattered-browser-effect-run -- Generated compatibility surface retained for existing callers. +export { Effect, runEffectRequest } from '@modern-js/bff-effect/effect-client'; +// +export * from './change-stock-sharing-eligibility-action-client.ts'; +export * from './compensate-inventory-pre-commit-action-client.ts'; +export * from './correct-catalog-to-stock-binding-action-client.ts'; +export * from './correct-external-stock-correlation-action-client.ts'; +export * from './correct-stock-position-action-client.ts'; +export * from './create-inventory-reservation-action-client.ts'; +export * from './end-catalog-to-stock-binding-action-client.ts'; +export * from './end-external-stock-correlation-action-client.ts'; +export * from './end-stock-sharing-eligibility-action-client.ts'; +export * from './establish-catalog-to-stock-binding-action-client.ts'; +export * from './establish-commitment-protection-action-client.ts'; +export * from './establish-external-stock-correlation-action-client.ts'; +export * from './establish-stock-sharing-eligibility-action-client.ts'; +export * from './import-source-assertion-action-client.ts'; +export * from './recover-inventory-effect-action-client.ts'; +export * from './release-inventory-reservation-action-client.ts'; +export * from './resolve-inventory-source-conflict-action-client.ts'; +export * from './select-inventory-backend-action-client.ts'; +export * from './stock-issue-action-client.ts'; +export * from './stock-receipt-action-client.ts'; +// + +export { + executeCurrentStockEvidenceForAvailability, + executeCurrentStockEvidenceForAvailabilityWithAuthorization, +} from './current-stock-evidence-for-availability-client.ts'; +export type { CurrentStockEvidenceForAvailabilityClientOptions } from './current-stock-evidence-for-availability-client.ts'; +export * from './catalog-to-stock-binding-resolution-client.ts'; +export * from './commitment-protection-verification-client.ts'; +export * from './inventory-backend-configuration-current-client.ts'; +export * from './inventory-effect-outcome-client.ts'; +export * from './inventory-reconciliation-evidence-client.ts'; +export * from './inventory-reservation-detail-client.ts'; +export * from './inventory-source-conflict-detail-client.ts'; +export * from './reservation-confirmation-verification-client.ts'; +export * from './stock-sharing-eligibility-resolution-client.ts'; + +type InventoryApiGroups = typeof inventoryApi extends HttpApi.HttpApi ? Groups : never; + +export type InventoryClient = HttpApiClient.Client>; + +export type InventoryClientError = HttpClientError.HttpClientError | Schema.SchemaError; + +export type InventoryClientEffect = Effect.Effect; + +export interface InventoryClientOptions { + readonly baseUrl?: string | URL; + readonly locale?: string; + readonly operationContext?: OperationContext; + // oxlint-disable-next-line effect-native/no-threaded-correlation-parameter -- This public option is the caller-provided W3C wire header consumed by the generated HTTP transport, not ambient application state. + readonly traceparent?: string; +} + +export const createInventoryClient = (options: InventoryClientOptions = {}): InventoryClientEffect => { + const requestContext = {}; + if (options.locale !== undefined) { + Object.assign(requestContext, { locale: options.locale }); + } + if (options.operationContext !== undefined) { + Object.assign(requestContext, { operationContext: options.operationContext }); + } + if (options.traceparent !== undefined) { + Object.assign(requestContext, { traceparent: options.traceparent }); + } + // oxlint-disable-next-line effect-native/no-per-operation-http-api-client -- This generated public factory intentionally binds caller-specific base URL and request metadata for one operation; sharing it would alter API and header lifetime. + return makeEffectHttpApiClient(inventoryApi, { + baseUrl: options.baseUrl ?? inventoryApiContract.apiPrefix, + requestContext, + }); +}; + +export const getInventoryReadiness = ( + options: InventoryClientOptions = {}, +): InventoryClientEffect => + // oxlint-disable-next-line effect-native/no-per-operation-http-api-client -- This generated public wrapper delegates caller-specific base URL and request metadata without introducing shared cross-request state. + createInventoryClient({ + ...options, + operationContext: options.operationContext ?? inventoryOperationContexts.readiness, + }).pipe(Effect.flatMap((client) => client.foundation.readiness({}))); diff --git a/app/verticals/inventory/src/api/inventory-effect-outcome-client.ts b/app/verticals/inventory/src/api/inventory-effect-outcome-client.ts new file mode 100644 index 000000000..9455aa0ef --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-effect-outcome-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { InventoryEffectOutcomeApi } from '../../shared/apis/inventory-effect-outcome.ts'; +import type { InventoryEffectOutcomeRequest } from '../../shared/apis/inventory-effect-outcome.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface InventoryEffectOutcomeClientOptions { + readonly baseUrl?: string | URL; +} + +type InventoryEffectOutcomeAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: InventoryEffectOutcomeClientOptions, +]; + +type InventoryEffectOutcomeOperationInvocation = readonly [ + requestCorrelation: string, + options?: InventoryEffectOutcomeClientOptions, +]; + +const inventoryEffectOutcomeClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: InventoryEffectOutcomeClientOptions, +) => + makeGovernedEffectBffClient( + { + api: InventoryEffectOutcomeApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeInventoryEffectOutcomeWithAuthorization = ( + payload: InventoryEffectOutcomeRequest, + ...[credential, requestCorrelation, options = {}]: InventoryEffectOutcomeAuthorizedInvocation +) => + inventoryEffectOutcomeClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.inventoryEffectOutcome.execute({ payload })), + ); + +export const executeInventoryEffectOutcome = ( + payload: InventoryEffectOutcomeRequest, + ...[requestCorrelation, options = {}]: InventoryEffectOutcomeOperationInvocation +) => + operationGateway.invoke((credential) => + executeInventoryEffectOutcomeWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/inventory-effect-outcome.read.ts b/app/verticals/inventory/src/api/inventory-effect-outcome.read.ts new file mode 100644 index 000000000..3ac7f3572 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-effect-outcome.read.ts @@ -0,0 +1,185 @@ +// @generated by OntOS Codesmith module-api v1 +import type { + OperationalScope, + ReadHandlerContext, + ReadHandlerResult, + ResolvedReadPermissionTarget, +} from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Match, Option } from 'effect'; +import { + InventoryEffectOutcomeRequestSchema, + InventoryEffectOutcomeResponseSchema, +} from '../../shared/apis/inventory-effect-outcome.ts'; +import type { + InventoryEffectOutcomeRequest, + InventoryEffectOutcomeResponse, +} from '../../shared/apis/inventory-effect-outcome.ts'; +import { + InventoryEffectLedgerErrorSchema, + InventoryEffectLedgerUnavailable, +} from '../../shared/domain/inventory-effect-ledger.ts'; +import type { InventoryEffectLedgerRecord } from '../../shared/domain/inventory-effect-ledger.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local service only after the governed read transaction and scope gate; expires: 2027-03-31. +import { makeInventoryEffectLedgerService } from '../services/inventory-effect-ledger.service.ts'; +import type { + InventoryEffectLedgerPersistence, + InventoryEffectLedgerService, +} from '../services/inventory-effect-ledger.service.ts'; + +export const InventoryEffectOutcomeDomainErrorSchema = InventoryEffectLedgerErrorSchema; +export type InventoryEffectOutcomeDomainError = typeof InventoryEffectOutcomeDomainErrorSchema.Type; + +interface InventoryEffectOutcomeServices { + readonly ledger: InventoryEffectLedgerService; + readonly persistence: InventoryEffectLedgerPersistence; +} + +const MODULE_KEY = 'commerce.inventory'; + +const intentLegalEntityId = (input: InventoryEffectOutcomeRequest) => input.intent.request.legalEntityId; + +const intentResource = (input: InventoryEffectOutcomeRequest) => + Match.value(input.intent).pipe( + Match.tag('RESERVATION_CREATE', ({ request }) => request.reservation.ref), + Match.tag('RESERVATION_RELEASE', ({ request }) => request.reservation.ref), + Match.tag('ESTABLISH_COMMITMENT_PROTECTION', ({ request }) => request.protectionRef), + Match.tag('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', ({ request }) => request.positionRef), + Match.exhaustive, + ); + +export const inventoryEffectOutcomePermissionTarget = ( + input: InventoryEffectOutcomeRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => { + const resource = intentResource(input); + return { + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource, + tenantId: resource.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', + }; +}; + +const outcomeForRecord = ( + record: InventoryEffectLedgerRecord, +): Effect.Effect => { + if (record.currentState === 'REQUESTED') { + return Effect.succeed({ + _tag: 'UNRESOLVED', + currentState: 'REQUESTED', + effectId: record.effectId, + intent: record.intent, + nextStep: 'RECOVER_ORIGINAL_EFFECT', + }); + } + if (record.currentState === 'INDETERMINATE') { + return Effect.succeed({ + _tag: 'INDETERMINATE', + currentState: 'INDETERMINATE', + effectId: record.effectId, + intent: record.intent, + nextStep: 'RECOVER_ORIGINAL_EFFECT', + resolution: record.resolution, + }); + } + if (record.resolution === null) { + return Effect.fail( + new InventoryEffectLedgerUnavailable({ + code: 'inventory_effect_ledger_unavailable', + effectId: record.effectId, + reason: 'Terminal Inventory Effect outcome has no authoritative resolution', + retryable: true, + }), + ); + } + return Effect.succeed({ + _tag: 'RESOLVED', + currentState: record.currentState, + effectId: record.effectId, + intent: record.intent, + nextStep: record.currentState === 'SUCCEEDED' ? 'CONTINUE' : 'STOP', + resolution: record.resolution, + }); +}; + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Inventory Effect is outside the trusted operation scope', + }); + +const inventoryEffectOutcomeHandler = ( + input: InventoryEffectOutcomeRequest, + context: ReadHandlerContext, +): Effect.Effect< + ReadHandlerResult, + ReadHandlerNotFound | InventoryEffectOutcomeDomainError +> => { + const resource = intentResource(input); + if (resource.tenantId !== context.scope.tenantId || intentLegalEntityId(input) !== context.scope.legalEntityId) { + return Effect.fail(notFound()); + } + return context.services.persistence.read(input.effectId).pipe( + Effect.flatMap( + Option.match({ + onNone: () => + Effect.succeed({ + _tag: 'UNRESOLVED' as const, + currentState: 'REQUESTED' as const, + effectId: input.effectId, + intent: input.intent, + nextStep: 'RECOVER_ORIGINAL_EFFECT' as const, + }), + onSome: () => + context.services.ledger + .recover(context.scope.tenantId, input.effectId, input.intent) + .pipe(Effect.flatMap(({ record }) => outcomeForRecord(record))), + }), + ), + Effect.map((result) => ({ evidence: { resultCount: 1 }, result })), + ); +}; + +const inventoryEffectOutcomeEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.inventory-effect-outcome', + moduleKey: MODULE_KEY, + role: 'api', +}); + +export const inventoryEffectOutcomeRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: InventoryEffectOutcomeDomainErrorSchema, + entrypoint: inventoryEffectOutcomeEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.inventory-effect-outcome.evidence.v1', + }, + inputSchema: InventoryEffectOutcomeRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.inventory-effect-outcome', + resultSchema: InventoryEffectOutcomeResponseSchema, + schemaVersion: '1', + }, + inventoryEffectOutcomeHandler, + (transaction, scope) => { + const persistence = inventoryEffectLedgerPersistenceForScope(transaction, scope); + return Effect.succeed({ + ledger: makeInventoryEffectLedgerService(persistence, Effect.succeed('1970-01-01T00:00:00.000Z')), + persistence, + }); + }, + inventoryEffectOutcomePermissionTarget, +); diff --git a/app/verticals/inventory/src/api/inventory-reconciliation-evidence-client.ts b/app/verticals/inventory/src/api/inventory-reconciliation-evidence-client.ts new file mode 100644 index 000000000..c9a1ffc76 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-reconciliation-evidence-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { InventoryReconciliationEvidenceApi } from '../../shared/apis/inventory-reconciliation-evidence.ts'; +import type { InventoryReconciliationEvidenceRequest } from '../../shared/apis/inventory-reconciliation-evidence.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface InventoryReconciliationEvidenceClientOptions { + readonly baseUrl?: string | URL; +} + +type InventoryReconciliationEvidenceAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: InventoryReconciliationEvidenceClientOptions, +]; + +type InventoryReconciliationEvidenceOperationInvocation = readonly [ + requestCorrelation: string, + options?: InventoryReconciliationEvidenceClientOptions, +]; + +const inventoryReconciliationEvidenceClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: InventoryReconciliationEvidenceClientOptions, +) => + makeGovernedEffectBffClient( + { + api: InventoryReconciliationEvidenceApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeInventoryReconciliationEvidenceWithAuthorization = ( + payload: InventoryReconciliationEvidenceRequest, + ...[credential, requestCorrelation, options = {}]: InventoryReconciliationEvidenceAuthorizedInvocation +) => + inventoryReconciliationEvidenceClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.inventoryReconciliationEvidence.execute({ payload })), + ); + +export const executeInventoryReconciliationEvidence = ( + payload: InventoryReconciliationEvidenceRequest, + ...[requestCorrelation, options = {}]: InventoryReconciliationEvidenceOperationInvocation +) => + operationGateway.invoke((credential) => + executeInventoryReconciliationEvidenceWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/inventory-reconciliation-evidence.read.ts b/app/verticals/inventory/src/api/inventory-reconciliation-evidence.read.ts new file mode 100644 index 000000000..a208ad5ec --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-reconciliation-evidence.read.ts @@ -0,0 +1,129 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Match, Option } from 'effect'; + +import { + InventoryReconciliationEvidenceRequestSchema, + InventoryReconciliationEvidenceResponseSchema, +} from '../../shared/apis/inventory-reconciliation-evidence.ts'; +import type { + InventoryReconciliationEvidenceQuery, + InventoryReconciliationEvidenceRequest, +} from '../../shared/apis/inventory-reconciliation-evidence.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local transaction-scoped persistence factory only after the governed Read scope gate; expires: 2027-03-31. +import { makeDrizzleCatalogToStockBindingPersistence } from '../persistence/catalog-to-stock-binding-repository.ts'; +import { commitmentProtectionPersistenceForScope } from '../persistence/commitment-protection-repository.ts'; +import { externalStockCorrelationPersistenceForScope } from '../persistence/external-stock-correlation-repository.ts'; +import { inventoryEffectLedgerPersistenceForScope } from '../persistence/inventory-effect-ledger-repository.ts'; +import { inventoryObligationPersistenceForScope } from '../persistence/inventory-obligation-repository.ts'; +import { inventorySourceConflictPersistenceForScope } from '../persistence/inventory-source-conflict-repository.ts'; +import { reservationConfirmationPersistenceForScope } from '../persistence/reservation-confirmation-repository.ts'; +import { stockSharingEligibilityPersistenceForScope } from '../persistence/stock-sharing-eligibility-repository.ts'; +import { + InventoryReconciliationEvidenceErrorSchema, + // oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this owner-local transaction-scoped Read service factory only after the governed scope gate; expires: 2027-03-31. + makeInventoryReconciliationEvidenceService, +} from '../services/inventory-reconciliation-evidence.service.ts'; + +type InventoryReconciliationEvidenceService = ReturnType; +export type InventoryReconciliationEvidenceDomainError = typeof InventoryReconciliationEvidenceErrorSchema.Type; + +const MODULE_KEY = 'commerce.inventory'; + +const ownerRefFor = (input: InventoryReconciliationEvidenceQuery) => + Match.value(input).pipe( + Match.tag('BINDING_HISTORY', ({ bindingRef }) => bindingRef), + Match.tag('ENDED_CORRELATION', ({ correlationRef }) => correlationRef), + Match.tag('SHARING_HISTORY', ({ relationRef }) => relationRef), + Match.tag('CONFIRMATION_HISTORY', ({ confirmationRef }) => confirmationRef), + Match.tag('PROTECTION_HISTORY', ({ protectionRef }) => protectionRef), + Match.tag('EFFECT_OUTCOME', ({ ownerRef }) => ownerRef), + Match.tag('SOURCE_CONFLICT_DETAIL', ({ conflictRef }) => conflictRef), + Match.tag('PRIVACY_OWNER_COVERAGE', ({ ownerRef }) => ownerRef), + Match.exhaustive, + ); + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Inventory reconciliation evidence was not found', + }); + +export const inventoryReconciliationEvidencePermissionTarget = ( + input: InventoryReconciliationEvidenceRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => { + const ownerRef = ownerRefFor(input.query); + return { + businessPermission: { + permission: 'inventory.audit.read', + target: { + kind: 'inventory_resource', + resource: ownerRef, + tenantId: ownerRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', + }; +}; + +const inventoryReconciliationEvidenceEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.audit.read' }, + entrypointKey: 'commerce.inventory.api.inventory-reconciliation-evidence', + moduleKey: MODULE_KEY, + role: 'api', +}); + +export const inventoryReconciliationEvidenceRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: InventoryReconciliationEvidenceErrorSchema, + entrypoint: inventoryReconciliationEvidenceEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.inventory-reconciliation-evidence.evidence.v1', + }, + inputSchema: InventoryReconciliationEvidenceRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.inventory-reconciliation-evidence', + resultSchema: InventoryReconciliationEvidenceResponseSchema, + schemaVersion: '1', + }, + ( + input: InventoryReconciliationEvidenceRequest, + context: ReadHandlerContext, + ) => { + if (ownerRefFor(input.query).tenantId !== context.scope.tenantId || context.scope.legalEntityId === undefined) { + return Effect.fail(notFound()); + } + return context.services + .read(input.query, { legalEntityId: context.scope.legalEntityId, tenantId: context.scope.tenantId }) + .pipe( + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(notFound()), + onSome: (result) => Effect.succeed({ evidence: { resultCount: 1 }, result }), + }), + ), + ); + }, + (transaction, scope) => + Effect.succeed( + makeInventoryReconciliationEvidenceService({ + bindings: makeDrizzleCatalogToStockBindingPersistence(transaction), + confirmations: reservationConfirmationPersistenceForScope(transaction, scope), + conflicts: inventorySourceConflictPersistenceForScope(transaction, scope), + correlations: externalStockCorrelationPersistenceForScope(transaction, scope), + effects: inventoryEffectLedgerPersistenceForScope(transaction, scope), + obligations: inventoryObligationPersistenceForScope(transaction, scope), + protections: commitmentProtectionPersistenceForScope(transaction, scope), + sharing: stockSharingEligibilityPersistenceForScope(transaction, scope), + }), + ), + inventoryReconciliationEvidencePermissionTarget, +); diff --git a/app/verticals/inventory/src/api/inventory-reservation-detail-client.ts b/app/verticals/inventory/src/api/inventory-reservation-detail-client.ts new file mode 100644 index 000000000..a3af79bb6 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-reservation-detail-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { InventoryReservationDetailApi } from '../../shared/apis/inventory-reservation-detail.ts'; +import type { InventoryReservationDetailRequest } from '../../shared/apis/inventory-reservation-detail.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface InventoryReservationDetailClientOptions { + readonly baseUrl?: string | URL; +} + +type InventoryReservationDetailAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: InventoryReservationDetailClientOptions, +]; + +type InventoryReservationDetailOperationInvocation = readonly [ + requestCorrelation: string, + options?: InventoryReservationDetailClientOptions, +]; + +const inventoryReservationDetailClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: InventoryReservationDetailClientOptions, +) => + makeGovernedEffectBffClient( + { + api: InventoryReservationDetailApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeInventoryReservationDetailWithAuthorization = ( + payload: InventoryReservationDetailRequest, + ...[credential, requestCorrelation, options = {}]: InventoryReservationDetailAuthorizedInvocation +) => + inventoryReservationDetailClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.inventoryReservationDetail.execute({ payload })), + ); + +export const executeInventoryReservationDetail = ( + payload: InventoryReservationDetailRequest, + ...[requestCorrelation, options = {}]: InventoryReservationDetailOperationInvocation +) => + operationGateway.invoke((credential) => + executeInventoryReservationDetailWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/inventory-reservation-detail.read.ts b/app/verticals/inventory/src/api/inventory-reservation-detail.read.ts new file mode 100644 index 000000000..353362567 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-reservation-detail.read.ts @@ -0,0 +1,114 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Option, Schema } from 'effect'; +import { + InventoryReservationDetailRequestSchema, + InventoryReservationDetailResponseSchema, +} from '../../shared/apis/inventory-reservation-detail.ts'; +import type { InventoryReservationDetailRequest } from '../../shared/apis/inventory-reservation-detail.ts'; +import { + InventoryObligationRejected, + ProvisionalInventoryReservationSchema, + RuntimeCommittedInventoryObligationSchema, +} from '../../shared/domain/inventory-obligation.ts'; +import { + InventoryObligationPersistenceUnavailable, + inventoryObligationPersistenceForScope, +} from '../persistence/inventory-obligation-repository.ts'; +import type { InventoryObligationPersistence } from '../persistence/inventory-obligation-repository.ts'; + +export type InventoryReservationDetailServices = Pick; + +export const InventoryReservationDetailDomainErrorSchema = Schema.Union([ + InventoryObligationRejected, + InventoryObligationPersistenceUnavailable, +]); +export type InventoryReservationDetailDomainError = typeof InventoryReservationDetailDomainErrorSchema.Type; + +const MODULE_KEY = 'commerce.inventory'; + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Inventory Reservation was not found', + }); + +const rejected = (reason: InventoryObligationRejected['reason']) => + new InventoryObligationRejected({ code: 'inventory_obligation_rejected', reason }); + +export const inventoryReservationDetailPermissionTarget = ( + input: InventoryReservationDetailRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => ({ + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource: { + moduleId: input.reservationRef.moduleId, + resourceId: input.reservationRef.resourceId, + resourceType: input.reservationRef.resourceType, + }, + tenantId: input.reservationRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', +}); + +const inventoryReservationDetailEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.inventory-reservation-detail', + moduleKey: MODULE_KEY, + role: 'api', +}); + +export const readInventoryReservationDetail = Effect.fn('InventoryReservationDetailRead.read')( + function* readInventoryReservation( + input: InventoryReservationDetailRequest, + context: ReadHandlerContext, + ) { + if (input.reservationRef.tenantId !== context.scope.tenantId) { + return yield* notFound(); + } + const found = yield* context.services.read(input.reservationRef); + if (Option.isNone(found)) { + return yield* notFound(); + } + const reservation = found.value; + if ( + !Schema.is(ProvisionalInventoryReservationSchema)(reservation) && + !Schema.is(RuntimeCommittedInventoryObligationSchema)(reservation) + ) { + return yield* rejected('INVALID_PERSISTED_OBLIGATION'); + } + return { + evidence: { resultCount: 1 }, + result: { reservation }, + }; + }, +); + +export const inventoryReservationDetailRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: InventoryReservationDetailDomainErrorSchema, + entrypoint: inventoryReservationDetailEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.inventory-reservation-detail.evidence.v1', + }, + inputSchema: InventoryReservationDetailRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.inventory-reservation-detail', + resultSchema: InventoryReservationDetailResponseSchema, + schemaVersion: '1', + }, + readInventoryReservationDetail, + (transaction, scope) => Effect.succeed(inventoryObligationPersistenceForScope(transaction, scope)), + inventoryReservationDetailPermissionTarget, +); diff --git a/app/verticals/inventory/src/api/inventory-source-conflict-detail-client.ts b/app/verticals/inventory/src/api/inventory-source-conflict-detail-client.ts new file mode 100644 index 000000000..f4bf8bf47 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-source-conflict-detail-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { InventorySourceConflictDetailApi } from '../../shared/apis/inventory-source-conflict-detail.ts'; +import type { InventorySourceConflictDetailRequest } from '../../shared/apis/inventory-source-conflict-detail.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface InventorySourceConflictDetailClientOptions { + readonly baseUrl?: string | URL; +} + +type InventorySourceConflictDetailAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: InventorySourceConflictDetailClientOptions, +]; + +type InventorySourceConflictDetailOperationInvocation = readonly [ + requestCorrelation: string, + options?: InventorySourceConflictDetailClientOptions, +]; + +const inventorySourceConflictDetailClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: InventorySourceConflictDetailClientOptions, +) => + makeGovernedEffectBffClient( + { + api: InventorySourceConflictDetailApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeInventorySourceConflictDetailWithAuthorization = ( + payload: InventorySourceConflictDetailRequest, + ...[credential, requestCorrelation, options = {}]: InventorySourceConflictDetailAuthorizedInvocation +) => + inventorySourceConflictDetailClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.inventorySourceConflictDetail.execute({ payload })), + ); + +export const executeInventorySourceConflictDetail = ( + payload: InventorySourceConflictDetailRequest, + ...[requestCorrelation, options = {}]: InventorySourceConflictDetailOperationInvocation +) => + operationGateway.invoke((credential) => + executeInventorySourceConflictDetailWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/inventory-source-conflict-detail.read.ts b/app/verticals/inventory/src/api/inventory-source-conflict-detail.read.ts new file mode 100644 index 000000000..a2382fd41 --- /dev/null +++ b/app/verticals/inventory/src/api/inventory-source-conflict-detail.read.ts @@ -0,0 +1,79 @@ +// @generated by OntOS Codesmith module-api v1 +import type { ReadHandlerContext } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Option } from 'effect'; +import { + InventorySourceConflictDetailRequestSchema, + InventorySourceConflictDetailResponseSchema, +} from '../../shared/apis/inventory-source-conflict-detail.ts'; +import type { InventorySourceConflictDetailRequest } from '../../shared/apis/inventory-source-conflict-detail.ts'; +import { InventorySourceConflictUnavailable } from '../../shared/domain/inventory-source-conflict.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core composes the owner-local resolver inside this governed transaction-scoped Read factory; expires: 2027-03-31. +import { makeExternalStockCorrelationResolver } from '../../shared/domain/external-stock-correlation.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from '../persistence/inventory-backend-configuration-repository.ts'; +import { externalStockCorrelationPersistenceForScope } from '../persistence/external-stock-correlation-repository.ts'; +import { inventorySourceAssertionPersistenceForScope } from '../persistence/inventory-source-assertion-repository.ts'; +import { inventorySourceConflictPersistenceForScope } from '../persistence/inventory-source-conflict-repository.ts'; +import { stockPositionPersistenceForScope } from '../persistence/stock-position-repository.ts'; +import type { InventorySourceConflictService } from '../services/inventory-source-conflict.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the governed Read scope gate; expires: 2027-03-31. +import { makeInventorySourceConflictService } from '../services/inventory-source-conflict.service.ts'; + +export type InventorySourceConflictDetailDomainError = InventorySourceConflictUnavailable; +const MODULE_KEY = 'commerce.inventory'; + +const inventorySourceConflictDetailEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'authenticated_principal' }, + entrypointKey: 'commerce.inventory.api.inventory-source-conflict-detail', + moduleKey: MODULE_KEY, + role: 'api', +}); + +export const inventorySourceConflictDetailRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: InventorySourceConflictUnavailable, + entrypoint: inventorySourceConflictDetailEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.inventory-source-conflict-detail.evidence.v1', + }, + inputSchema: InventorySourceConflictDetailRequestSchema, + legalEntityScope: 'forbidden', + owningModuleKey: MODULE_KEY, + permissionTarget: 'resource', + policies: [], + readKey: 'commerce.inventory.api.inventory-source-conflict-detail', + resultSchema: InventorySourceConflictDetailResponseSchema, + schemaVersion: '1', + }, + (input: InventorySourceConflictDetailRequest, context: ReadHandlerContext) => + context.services.find(input.conflictRef).pipe( + Effect.flatMap( + Option.match({ + onNone: () => + Effect.fail( + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Inventory Source Conflict was not found', + }), + ), + onSome: (conflict) => Effect.succeed({ evidence: { resultCount: 1 }, result: { conflict } }), + }), + ), + ), + (transaction, scope) => + Effect.succeed( + makeInventorySourceConflictService({ + assertions: inventorySourceAssertionPersistenceForScope(transaction, scope), + backendConfigurations: inventoryBackendConfigurationPersistenceForScope(transaction, scope), + conflicts: inventorySourceConflictPersistenceForScope(transaction, scope), + correlations: makeExternalStockCorrelationResolver( + externalStockCorrelationPersistenceForScope(transaction, scope), + ), + positions: stockPositionPersistenceForScope(transaction, scope), + }), + ), + (input) => ({ kind: 'resource', permission: 'read', resource: input.conflictRef }), +); diff --git a/app/verticals/inventory/src/api/recover-inventory-effect-action-client.ts b/app/verticals/inventory/src/api/recover-inventory-effect-action-client.ts new file mode 100644 index 000000000..7dbba31f1 --- /dev/null +++ b/app/verticals/inventory/src/api/recover-inventory-effect-action-client.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug recover-inventory-effect +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + RecoverInventoryEffectActionApi, + RecoverInventoryEffectPayloadSchema, +} from '../../shared/apis/recover-inventory-effect-action.ts'; +import type { RecoverInventoryEffectPayload } from '../../shared/actions/recover-inventory-effect.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface RecoverInventoryEffectActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: RecoverInventoryEffectActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: RecoverInventoryEffectActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: RecoverInventoryEffectActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: RecoverInventoryEffectActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeRecoverInventoryEffectWithAuthorization = ( + payload: RecoverInventoryEffectPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(RecoverInventoryEffectPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.recoverInventoryEffectAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeRecoverInventoryEffect = ( + payload: RecoverInventoryEffectPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => executeRecoverInventoryEffectWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/release-inventory-reservation-action-client.ts b/app/verticals/inventory/src/api/release-inventory-reservation-action-client.ts new file mode 100644 index 000000000..dc63925a1 --- /dev/null +++ b/app/verticals/inventory/src/api/release-inventory-reservation-action-client.ts @@ -0,0 +1,69 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug release-inventory-reservation +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + ReleaseInventoryReservationActionApi, + ReleaseInventoryReservationPayloadSchema, +} from '../../shared/apis/release-inventory-reservation-action.ts'; +import type { ReleaseInventoryReservationPayload } from '../../shared/actions/release-inventory-reservation.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface ReleaseInventoryReservationActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: ReleaseInventoryReservationActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: ReleaseInventoryReservationActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: ReleaseInventoryReservationActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: ReleaseInventoryReservationActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeReleaseInventoryReservationWithAuthorization = ( + payload: ReleaseInventoryReservationPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(ReleaseInventoryReservationPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.releaseInventoryReservationAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeReleaseInventoryReservation = ( + payload: ReleaseInventoryReservationPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeReleaseInventoryReservationWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/reservation-confirmation-verification-client.ts b/app/verticals/inventory/src/api/reservation-confirmation-verification-client.ts new file mode 100644 index 000000000..d7ed56138 --- /dev/null +++ b/app/verticals/inventory/src/api/reservation-confirmation-verification-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { ReservationConfirmationVerificationApi } from '../../shared/apis/reservation-confirmation-verification.ts'; +import type { ReservationConfirmationVerificationRequest } from '../../shared/apis/reservation-confirmation-verification.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface ReservationConfirmationVerificationClientOptions { + readonly baseUrl?: string | URL; +} + +type ReservationConfirmationVerificationAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: ReservationConfirmationVerificationClientOptions, +]; + +type ReservationConfirmationVerificationOperationInvocation = readonly [ + requestCorrelation: string, + options?: ReservationConfirmationVerificationClientOptions, +]; + +const reservationConfirmationVerificationClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: ReservationConfirmationVerificationClientOptions, +) => + makeGovernedEffectBffClient( + { + api: ReservationConfirmationVerificationApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeReservationConfirmationVerificationWithAuthorization = ( + payload: ReservationConfirmationVerificationRequest, + ...[credential, requestCorrelation, options = {}]: ReservationConfirmationVerificationAuthorizedInvocation +) => + reservationConfirmationVerificationClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.reservationConfirmationVerification.execute({ payload })), + ); + +export const executeReservationConfirmationVerification = ( + payload: ReservationConfirmationVerificationRequest, + ...[requestCorrelation, options = {}]: ReservationConfirmationVerificationOperationInvocation +) => + operationGateway.invoke((credential) => + executeReservationConfirmationVerificationWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/reservation-confirmation-verification.read.ts b/app/verticals/inventory/src/api/reservation-confirmation-verification.read.ts new file mode 100644 index 000000000..7acb24e80 --- /dev/null +++ b/app/verticals/inventory/src/api/reservation-confirmation-verification.read.ts @@ -0,0 +1,206 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { ReadHandlerNotFound, defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Match, Option, Schema } from 'effect'; +import { + ReservationConfirmationVerificationRequestSchema, + ReservationConfirmationVerificationResponseSchema, +} from '../../shared/apis/reservation-confirmation-verification.ts'; +import type { + ReservationConfirmationVerificationRequest, + ReservationConfirmationVerificationResponse, +} from '../../shared/apis/reservation-confirmation-verification.ts'; +import { + ReservationConfirmationRejected, + ReservationConfirmationSchema, + ReservationConfirmationUnavailable, + evaluateReservationConfirmationCommitment, +} from '../../shared/domain/reservation-confirmation.ts'; +import type { + ReservationConfirmation, + ReservationConfirmationPersistence, +} from '../../shared/domain/reservation-confirmation.ts'; +import { reservationConfirmationPersistenceForScope } from '../persistence/reservation-confirmation-repository.ts'; + +export type ReservationConfirmationVerificationServices = Pick< + ReservationConfirmationPersistence, + 'findByRef' | 'readHistory' +>; + +export const ReservationConfirmationVerificationDomainErrorSchema = Schema.Union([ + ReservationConfirmationRejected, + ReservationConfirmationUnavailable, +]); +export type ReservationConfirmationVerificationDomainError = + typeof ReservationConfirmationVerificationDomainErrorSchema.Type; + +const MODULE_KEY = 'commerce.inventory'; + +const notFound = () => + new ReadHandlerNotFound({ + code: 'read_handler_not_found', + reason: 'Reservation Confirmation was not found', + }); + +const rejected = (reason: ReservationConfirmationRejected['reason']) => + new ReservationConfirmationRejected({ code: 'reservation_confirmation_rejected', reason }); + +const sameRef = ( + left: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, + right: { + readonly moduleId: string; + readonly resourceId: string; + readonly resourceType: string; + readonly tenantId: string; + }, +) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const matchesRequestedReservation = ( + confirmation: ReservationConfirmation, + input: ReservationConfirmationVerificationRequest, +) => + sameRef(confirmation.ref, input.confirmationRef) && + sameRef(confirmation.reservation.ref, input.reservationRef) && + confirmation.reservation.origin.attemptId === input.attemptId; + +const sameConfirmation = Schema.toEquivalence(ReservationConfirmationSchema); + +const completeHistory = ( + current: ReservationConfirmation, + history: readonly ReservationConfirmation[], + input: ReservationConfirmationVerificationRequest, +) => { + const latest = history.at(-1); + return ( + latest !== undefined && + sameConfirmation(latest, current) && + history.every((revision, index) => matchesRequestedReservation(revision, input) && revision.revision === index + 1) + ); +}; + +export const reservationConfirmationVerificationPermissionTarget = ( + input: ReservationConfirmationVerificationRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => ({ + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource: { + moduleId: input.confirmationRef.moduleId, + resourceId: input.confirmationRef.resourceId, + resourceType: input.confirmationRef.resourceType, + }, + tenantId: input.confirmationRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', +}); + +const reservationConfirmationVerificationEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.reservation-confirmation-verification', + moduleKey: MODULE_KEY, + role: 'api', +}); + +const verificationResult = Effect.fn('ReservationConfirmationVerificationRead.result')(function* makeVerificationResult( + request: Readonly<{ + current: ReservationConfirmation; + history: readonly ReservationConfirmation[]; + input: ReservationConfirmationVerificationRequest; + }>, +) { + const { current, history, input } = request; + const evaluation = yield* evaluateReservationConfirmationCommitment( + current, + { evaluatedAt: input.evaluatedAt }, + history, + ); + return yield* Match.value(evaluation).pipe( + Match.when( + { outcome: 'READY_TO_ESTABLISH_PROTECTION' }, + (): Effect.Effect => + Effect.succeed({ outcome: 'READY_TO_ESTABLISH_PROTECTION' }), + ), + Match.when( + { outcome: 'TERMINAL_READINESS_LOSS' }, + ({ replacement }): Effect.Effect => + Effect.succeed({ outcome: 'TERMINAL_READINESS_LOSS', replacement }), + ), + Match.when( + { outcome: 'NOT_READY' }, + ({ health }): Effect.Effect => + Effect.succeed({ health, outcome: 'NOT_READY' }), + ), + Match.when( + { outcome: 'PROTECTION_ESTABLISHED_IN_TIME' }, + (): Effect.Effect => Effect.fail(rejected('INVALID_CONFIRMATION')), + ), + Match.exhaustive, + ); +}); + +export const verifyReservationConfirmation = Effect.fn('ReservationConfirmationVerificationRead.read')( + function* verifyConfirmation( + input: ReservationConfirmationVerificationRequest, + context: ReadHandlerContext, + ) { + if ( + input.confirmationRef.tenantId !== context.scope.tenantId || + input.reservationRef.tenantId !== context.scope.tenantId + ) { + return yield* notFound(); + } + const found = yield* context.services.findByRef(input.confirmationRef); + if (Option.isNone(found)) { + return yield* notFound(); + } + const current = found.value; + if (!matchesRequestedReservation(current, input)) { + return yield* rejected('RESERVATION_SCOPE_MISMATCH'); + } + const history = yield* context.services.readHistory(input.confirmationRef); + if (!completeHistory(current, history, input)) { + return yield* rejected('INVALID_CONFIRMATION'); + } + const evaluation = yield* verificationResult({ current, history, input }); + return { + evidence: { resultCount: 1 }, + result: { current, evaluation, health: current.health, history }, + }; + }, +); + +export const reservationConfirmationVerificationRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: ReservationConfirmationVerificationDomainErrorSchema, + entrypoint: reservationConfirmationVerificationEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.reservation-confirmation-verification.evidence.v1', + }, + inputSchema: ReservationConfirmationVerificationRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.reservation-confirmation-verification', + resultSchema: ReservationConfirmationVerificationResponseSchema, + schemaVersion: '1', + }, + verifyReservationConfirmation, + (transaction, scope) => Effect.succeed(reservationConfirmationPersistenceForScope(transaction, scope)), + reservationConfirmationVerificationPermissionTarget, +); diff --git a/app/verticals/inventory/src/api/resolve-inventory-source-conflict-action-client.ts b/app/verticals/inventory/src/api/resolve-inventory-source-conflict-action-client.ts new file mode 100644 index 000000000..9ffe610ee --- /dev/null +++ b/app/verticals/inventory/src/api/resolve-inventory-source-conflict-action-client.ts @@ -0,0 +1,74 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug resolve-inventory-source-conflict +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + ResolveInventorySourceConflictActionApi, + ResolveInventorySourceConflictPayloadSchema, +} from '../../shared/apis/resolve-inventory-source-conflict-action.ts'; +import type { ResolveInventorySourceConflictPayload } from '../../shared/actions/resolve-inventory-source-conflict.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface ResolveInventorySourceConflictActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: ResolveInventorySourceConflictActionClientOptions, +]; +type OperationInvocation = readonly [ + requestCorrelation: string, + options: ResolveInventorySourceConflictActionClientOptions, +]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: ResolveInventorySourceConflictActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { + api: ResolveInventorySourceConflictActionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeResolveInventorySourceConflictWithAuthorization = ( + payload: ResolveInventorySourceConflictPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(ResolveInventorySourceConflictPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.resolveInventorySourceConflictAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeResolveInventorySourceConflict = ( + payload: ResolveInventorySourceConflictPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => + executeResolveInventorySourceConflictWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/select-inventory-backend-action-client.ts b/app/verticals/inventory/src/api/select-inventory-backend-action-client.ts new file mode 100644 index 000000000..fd448f7b6 --- /dev/null +++ b/app/verticals/inventory/src/api/select-inventory-backend-action-client.ts @@ -0,0 +1,65 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug select-inventory-backend +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { + SelectInventoryBackendActionApi, + SelectInventoryBackendPayloadSchema, +} from '../../shared/apis/select-inventory-backend-action.ts'; +import type { SelectInventoryBackendPayload } from '../../shared/actions/select-inventory-backend.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface SelectInventoryBackendActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: SelectInventoryBackendActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: SelectInventoryBackendActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: SelectInventoryBackendActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: SelectInventoryBackendActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeSelectInventoryBackendWithAuthorization = ( + payload: SelectInventoryBackendPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(SelectInventoryBackendPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.selectInventoryBackendAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeSelectInventoryBackend = ( + payload: SelectInventoryBackendPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => executeSelectInventoryBackendWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/stock-issue-action-client.ts b/app/verticals/inventory/src/api/stock-issue-action-client.ts new file mode 100644 index 000000000..f67f30096 --- /dev/null +++ b/app/verticals/inventory/src/api/stock-issue-action-client.ts @@ -0,0 +1,59 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-issue +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { StockIssueActionApi, StockIssuePayloadSchema } from '../../shared/apis/stock-issue-action.ts'; +import type { StockIssuePayload } from '../../shared/actions/stock-issue.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface StockIssueActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: StockIssueActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: StockIssueActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: StockIssueActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: StockIssueActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeStockIssueWithAuthorization = ( + payload: StockIssuePayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(StockIssuePayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.stockIssueAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeStockIssue = (payload: StockIssuePayload, ...[requestCorrelation, options]: OperationInvocation) => + operationGateway.invoke( + (credential) => executeStockIssueWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/stock-receipt-action-client.ts b/app/verticals/inventory/src/api/stock-receipt-action-client.ts new file mode 100644 index 000000000..00aaaef9e --- /dev/null +++ b/app/verticals/inventory/src/api/stock-receipt-action-client.ts @@ -0,0 +1,62 @@ +// @generated by OntOS Codesmith Action HTTP v1 +// @ontos-action-http-owner commerce.inventory +// @ontos-action-http-slug stock-receipt +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted, Schema } from 'effect'; +import { StockReceiptActionApi, StockReceiptPayloadSchema } from '../../shared/apis/stock-receipt-action.ts'; +import type { StockReceiptPayload } from '../../shared/actions/stock-receipt.ts'; +import { operationGateway } from './action-gateway.ts'; + +const traceIdOption = 'traceId' as const; + +export interface StockReceiptActionClientOptions { + readonly baseUrl?: string | URL; + readonly gateway?: Parameters[1]; + readonly idempotencyKey: string; + readonly [traceIdOption]?: string; +} + +type AuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options: StockReceiptActionClientOptions, +]; +type OperationInvocation = readonly [requestCorrelation: string, options: StockReceiptActionClientOptions]; + +interface MakeClientOptions { + readonly credential: Redacted.Redacted; + readonly options: StockReceiptActionClientOptions; + readonly requestCorrelation: string; +} + +const makeClient = ({ credential, options, requestCorrelation }: MakeClientOptions) => + makeGovernedEffectBffClient( + { api: StockReceiptActionApi, credential, defaultApiPrefix: '/inventory-api', requestCorrelation }, + options, + ); + +export const executeStockReceiptWithAuthorization = ( + payload: StockReceiptPayload, + ...[credential, requestCorrelation, options]: AuthorizedInvocation +) => + Schema.encodeUnknownEffect(StockReceiptPayloadSchema)(payload).pipe( + Effect.flatMap((encoded) => + makeClient({ credential: Redacted.make(credential), options, requestCorrelation }).pipe( + Effect.flatMap((client) => + client.stockReceiptAction.execute({ + headers: { 'idempotency-key': options.idempotencyKey }, + payload: encoded, + }), + ), + ), + ), + ); + +export const executeStockReceipt = ( + payload: StockReceiptPayload, + ...[requestCorrelation, options]: OperationInvocation +) => + operationGateway.invoke( + (credential) => executeStockReceiptWithAuthorization(payload, credential, requestCorrelation, options), + options.gateway, + ); diff --git a/app/verticals/inventory/src/api/stock-sharing-eligibility-resolution-client.ts b/app/verticals/inventory/src/api/stock-sharing-eligibility-resolution-client.ts new file mode 100644 index 000000000..adccb1731 --- /dev/null +++ b/app/verticals/inventory/src/api/stock-sharing-eligibility-resolution-client.ts @@ -0,0 +1,52 @@ +// @generated by OntOS Codesmith module-api v1 +import { makeGovernedEffectBffClient } from '@app/shared-contracts/client-runtime'; +import { Effect, Redacted } from 'effect'; +import { StockSharingEligibilityResolutionApi } from '../../shared/apis/stock-sharing-eligibility-resolution.ts'; +import type { StockSharingEligibilityResolutionRequest } from '../../shared/apis/stock-sharing-eligibility-resolution.ts'; +import { operationGateway } from './action-gateway.ts'; + +export interface StockSharingEligibilityResolutionClientOptions { + readonly baseUrl?: string | URL; +} + +type StockSharingEligibilityResolutionAuthorizedInvocation = readonly [ + credential: string, + requestCorrelation: string, + options?: StockSharingEligibilityResolutionClientOptions, +]; + +type StockSharingEligibilityResolutionOperationInvocation = readonly [ + requestCorrelation: string, + options?: StockSharingEligibilityResolutionClientOptions, +]; + +const stockSharingEligibilityResolutionClient = ( + credential: Redacted.Redacted, + requestCorrelation: string, + options: StockSharingEligibilityResolutionClientOptions, +) => + makeGovernedEffectBffClient( + { + api: StockSharingEligibilityResolutionApi, + credential, + defaultApiPrefix: '/inventory-api', + requestCorrelation, + }, + options, + ); + +export const executeStockSharingEligibilityResolutionWithAuthorization = ( + payload: StockSharingEligibilityResolutionRequest, + ...[credential, requestCorrelation, options = {}]: StockSharingEligibilityResolutionAuthorizedInvocation +) => + stockSharingEligibilityResolutionClient(Redacted.make(credential), requestCorrelation, options).pipe( + Effect.flatMap((client) => client.stockSharingEligibilityResolution.execute({ payload })), + ); + +export const executeStockSharingEligibilityResolution = ( + payload: StockSharingEligibilityResolutionRequest, + ...[requestCorrelation, options = {}]: StockSharingEligibilityResolutionOperationInvocation +) => + operationGateway.invoke((credential) => + executeStockSharingEligibilityResolutionWithAuthorization(payload, credential, requestCorrelation, options), + ); diff --git a/app/verticals/inventory/src/api/stock-sharing-eligibility-resolution.read.ts b/app/verticals/inventory/src/api/stock-sharing-eligibility-resolution.read.ts new file mode 100644 index 000000000..755eb5061 --- /dev/null +++ b/app/verticals/inventory/src/api/stock-sharing-eligibility-resolution.read.ts @@ -0,0 +1,104 @@ +// @generated by OntOS Codesmith module-api v1 +import type { OperationalScope, ReadHandlerContext, ResolvedReadPermissionTarget } from '@app/core-runtime'; +import { defineRead, defineTenantModuleEntrypoint } from '@app/core-runtime'; +import { Effect, Schema } from 'effect'; +import { + StockSharingEligibilityResolutionRequestSchema, + StockSharingEligibilityResolutionResponseSchema, +} from '../../shared/apis/stock-sharing-eligibility-resolution.ts'; +import type { StockSharingEligibilityResolutionRequest } from '../../shared/apis/stock-sharing-eligibility-resolution.ts'; +import { + StockSharingEligibilityRejected, + TrustedCurrentCommercePurchasingContextSchema, +} from '../../shared/domain/stock-sharing-eligibility.ts'; +import { StockSharingEligibilityUnavailable } from '../../shared/domain/stock-sharing-eligibility-unavailable.ts'; +import { stockSharingEligibilityPersistenceForScope } from '../persistence/stock-sharing-eligibility-repository.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this generated transaction-scoped owner factory only after the governed Read scope gate; expires: 2027-03-31. +import { makeStockSharingEligibilityEvaluator } from '../services/stock-sharing-eligibility-service.ts'; + +export const StockSharingEligibilityResolutionDomainErrorSchema = Schema.Union([ + StockSharingEligibilityRejected, + StockSharingEligibilityUnavailable, +]); +export type StockSharingEligibilityResolutionDomainError = + typeof StockSharingEligibilityResolutionDomainErrorSchema.Type; + +type StockSharingEligibilityResolutionService = Pick< + ReturnType, + 'evaluate' +>; + +const MODULE_KEY = 'commerce.inventory'; + +const scopeMismatch = () => + new StockSharingEligibilityRejected({ + code: 'stock_sharing_eligibility_rejected', + reason: 'POSITION_SCOPE_MISMATCH', + }); + +export const stockSharingEligibilityResolutionPermissionTarget = ( + input: StockSharingEligibilityResolutionRequest, + scope: OperationalScope, +): ResolvedReadPermissionTarget => ({ + businessPermission: { + permission: 'inventory.resource.read', + target: { + kind: 'inventory_resource', + resource: { + moduleId: input.scope.positionRef.moduleId, + resourceId: input.scope.positionRef.resourceId, + resourceType: input.scope.positionRef.resourceType, + }, + tenantId: input.scope.positionRef.tenantId === scope.tenantId ? scope.tenantId : '', + }, + }, + kind: 'business_permission', +}); + +const stockSharingEligibilityResolutionEntrypoint = defineTenantModuleEntrypoint({ + access: 'read', + authorization: { kind: 'context_permission', permission: 'inventory.resource.read' }, + entrypointKey: 'commerce.inventory.api.stock-sharing-eligibility-resolution', + moduleKey: 'commerce.inventory', + role: 'api', +}); + +export const stockSharingEligibilityResolutionRead = defineRead( + { + accessKind: 'detail', + domainErrorSchema: StockSharingEligibilityResolutionDomainErrorSchema, + entrypoint: stockSharingEligibilityResolutionEntrypoint, + evidencePolicy: { + captureMode: 'metadata_only', + policyKey: 'commerce.inventory.api.stock-sharing-eligibility-resolution.evidence.v1', + }, + inputSchema: StockSharingEligibilityResolutionRequestSchema, + legalEntityScope: 'required', + owningModuleKey: MODULE_KEY, + permissionTarget: 'business_permission', + policies: [], + readKey: 'commerce.inventory.api.stock-sharing-eligibility-resolution', + resultSchema: StockSharingEligibilityResolutionResponseSchema, + schemaVersion: '1', + }, + ( + input: StockSharingEligibilityResolutionRequest, + context: ReadHandlerContext, + ) => { + if ( + input.scope.positionRef.tenantId !== context.scope.tenantId || + (Schema.is(TrustedCurrentCommercePurchasingContextSchema)(input.commerceContextEvidence) && + input.commerceContextEvidence.sellingLegalEntityRef.resourceId !== context.scope.legalEntityId) + ) { + return Effect.fail(scopeMismatch()); + } + return context.services + .evaluate({ context: input.commerceContextEvidence, scope: input.scope }) + .pipe(Effect.map((decision) => ({ evidence: { resultCount: 1 }, result: { decision } }))); + }, + (transaction, scope) => + Effect.succeed( + makeStockSharingEligibilityEvaluator(stockSharingEligibilityPersistenceForScope(transaction, scope)), + ), + stockSharingEligibilityResolutionPermissionTarget, +); diff --git a/app/verticals/inventory/src/components/inventory-widget.tsx b/app/verticals/inventory/src/components/inventory-widget.tsx new file mode 100644 index 000000000..6979928d5 --- /dev/null +++ b/app/verticals/inventory/src/components/inventory-widget.tsx @@ -0,0 +1,42 @@ +// @generated by OntOS Codesmith public-component v1 +import { FederatedI18nBoundary, useModernI18n } from '@modern-js/plugin-i18n/runtime/consumer'; + +import csResource from '../../locales/cs/inventory.json'; +import enResource from '../../locales/en/inventory.json'; + +const federatedI18nLanguages = ['en', 'cs']; +const federatedI18nResources = { + cs: { inventory: csResource }, + en: { inventory: enResource }, +}; + +const InventoryWidgetContent = () => { + const { t } = useModernI18n(); + + return ( +
+

{t('inventory.title')}

+

{t('inventory.widgetBody')}

+
+ ); +}; + +const InventoryWidget = (_props: Record) => { + void _props; + return ( + + + + ); +}; + +export default InventoryWidget; diff --git a/app/verticals/inventory/src/database/catalog.ts b/app/verticals/inventory/src/database/catalog.ts new file mode 100644 index 000000000..78a223c06 --- /dev/null +++ b/app/verticals/inventory/src/database/catalog.ts @@ -0,0 +1,20 @@ +import { Array as EffectArray, Order } from 'effect'; + +import { INVENTORY_SCHEMA_NAME, INVENTORY_TABLE_INVENTORY } from './schema.ts'; + +const expectedCatalog = INVENTORY_TABLE_INVENTORY.map((tableName) => `${INVENTORY_SCHEMA_NAME}.${tableName}`); + +export const compareInventoryCatalog = (qualifiedTableNames: readonly string[]) => { + const expected = new Set(expectedCatalog); + const actual = new Set(qualifiedTableNames); + return { + missing: EffectArray.sort( + [...expected].filter((tableName) => !actual.has(tableName)), + Order.String, + ), + unexpected: EffectArray.sort( + [...actual].filter((tableName) => !expected.has(tableName)), + Order.String, + ), + }; +}; diff --git a/app/verticals/inventory/src/database/client.ts b/app/verticals/inventory/src/database/client.ts new file mode 100644 index 000000000..046208866 --- /dev/null +++ b/app/verticals/inventory/src/database/client.ts @@ -0,0 +1,56 @@ +/* oxlint-disable effect-native/no-effect-provide-in-library -- Native Drizzle executor construction is this owner database factory boundary; expires: 2027-03-31. */ +import type { DatabasePoolDeadlines } from '@app/core-runtime'; +import { DatabaseConfig, configureDatabasePool } from '@app/core-runtime'; +import { PgClient } from '@effect/sql-pg'; +import { makeWithDefaults } from 'drizzle-orm/effect-postgres'; +import type { Scope } from 'effect'; +import { Context, Effect, Layer, Redacted } from 'effect'; +import { Reactivity } from 'effect/unstable/reactivity'; + +import { InventoryDatabaseConnectionError } from './connection-error.ts'; +import { inventoryRelations } from './schema.ts'; +import type { InventoryDatabaseExecutor } from './types.ts'; + +export class InventoryDatabase extends Context.Service< + InventoryDatabase, + { readonly executor: InventoryDatabaseExecutor } +>()('@app/inventory/database/client/InventoryDatabase') {} + +const connectionFailure = (cause: unknown): InventoryDatabaseConnectionError => + Object.defineProperty( + new InventoryDatabaseConnectionError({ reason: 'Unable to initialize the Inventory PostgreSQL connection pool' }), + 'cause', + { value: cause }, + ); + +type ContextServiceContract = + Service extends Context.Key ? Contract : never; + +const makeInventoryDatabase = Effect.fn('InventoryDatabase.make')(function* makeDatabase( + configuration: ContextServiceContract & { + readonly poolDeadlines?: Partial; + }, +): Effect.fn.Return, InventoryDatabaseConnectionError, Scope.Scope> { + const poolConfiguration = yield* configureDatabasePool( + Redacted.make(configuration.connectionString), + configuration.poolDeadlines, + ).pipe(Effect.mapError((error) => new InventoryDatabaseConnectionError({ reason: error.reason }))); + const reactivity = yield* Reactivity.make; + const client = yield* PgClient.make(poolConfiguration).pipe( + Effect.provideService(Reactivity.Reactivity, reactivity), + Effect.mapError(connectionFailure), + ); + return { + executor: yield* makeWithDefaults({ relations: inventoryRelations }).pipe( + Effect.provideService(PgClient.PgClient, client), + ), + }; +}); + +export const InventoryDatabaseLive = Layer.effect( + InventoryDatabase, + Effect.gen(function* makeDatabaseService() { + const configuration = yield* DatabaseConfig; + return yield* makeInventoryDatabase(configuration); + }), +); diff --git a/app/verticals/inventory/src/database/connection-error.ts b/app/verticals/inventory/src/database/connection-error.ts new file mode 100644 index 000000000..70980487c --- /dev/null +++ b/app/verticals/inventory/src/database/connection-error.ts @@ -0,0 +1,6 @@ +import { Schema } from 'effect'; + +export class InventoryDatabaseConnectionError extends Schema.TaggedError()( + 'InventoryDatabaseConnectionError', + { reason: Schema.String }, +) {} diff --git a/app/verticals/inventory/src/database/inventory-schema.ts b/app/verticals/inventory/src/database/inventory-schema.ts new file mode 100644 index 000000000..3df7aa0a5 --- /dev/null +++ b/app/verticals/inventory/src/database/inventory-schema.ts @@ -0,0 +1,6 @@ +import { pgSchema } from 'drizzle-orm/pg-core'; + +export const INVENTORY_SCHEMA_NAME = 'inventory'; + +/** Sole PostgreSQL schema declaration shared by every Inventory-owned table. */ +export const inventorySchema = pgSchema(INVENTORY_SCHEMA_NAME); diff --git a/app/verticals/inventory/src/database/schema.ts b/app/verticals/inventory/src/database/schema.ts new file mode 100644 index 000000000..eb036d350 --- /dev/null +++ b/app/verticals/inventory/src/database/schema.ts @@ -0,0 +1,253 @@ +import { defineRelations } from 'drizzle-orm'; +import type { EmptyRelations, ExtractTablesFromSchema, ExtractTablesWithRelations } from 'drizzle-orm'; +import type { PgTable } from 'drizzle-orm/pg-core'; + +import { inventoryBackendConfigurations } from '../persistence/inventory-backend-configuration-table.ts'; +import { inventoryBindingCorrectionReconciliations } from '../persistence/binding-correction-impact-table.ts'; +import { + inventoryCatalogToStockBindingHistory, + inventoryCatalogToStockBindings, +} from '../persistence/catalog-to-stock-binding-table.ts'; +import { + inventoryCommitmentProtectionHistory, + inventoryCommitmentProtections, +} from '../persistence/commitment-protection-table.ts'; +import { inventoryExternalStockCorrelations } from '../persistence/external-stock-correlation-table.ts'; +import { inventoryEffectLedger, inventoryEffectLedgerHistory } from '../persistence/inventory-effect-ledger-table.ts'; +import { + inventoryObligationAllocations, + inventoryObligationRequirements, + inventoryObligations, +} from '../persistence/inventory-obligation-table.ts'; +import { inventoryPhysicalStockEffects } from '../persistence/physical-stock-effect-table.ts'; +import { + inventoryReservationConfirmationHistory, + inventoryReservationConfirmations, +} from '../persistence/reservation-confirmation-table.ts'; +import { inventoryReservationCreateEffects } from '../persistence/reservation-create-effect-table.ts'; +import { + inventoryReservationReleaseEffectHistory, + inventoryReservationReleaseEffects, +} from '../persistence/reservation-release-effect-table.ts'; +import { + inventoryReservationShortageImpactDecisions, + inventoryReservationShortageImpacts, +} from '../persistence/reservation-shortage-impact-table.ts'; +import { + inventorySourceAssertionCoverage, + inventorySourceAssertions, +} from '../persistence/inventory-source-assertion-table.ts'; +import { inventorySourceConflictRevisions } from '../persistence/inventory-source-conflict-table.ts'; +import { inventorySourceImportLedger } from '../persistence/inventory-source-import-ledger-table.ts'; +import { + inventoryStockCorrectionOpenReconciliations, + inventoryStockCorrections, +} from '../persistence/stock-correction-table.ts'; +import { + inventoryStockCorrectionSourceEvidence, + inventoryStockCorrectionSourceEvidenceCoverage, + inventoryStockCorrectionSourceEvidenceCurrent, +} from '../persistence/stock-correction-source-evidence-table.ts'; +import { inventoryStockItems } from '../persistence/stock-item-table.ts'; +import { inventoryStockLocationRevisions, inventoryStockLocations } from '../persistence/stock-location-table.ts'; +import { inventoryStockPositions } from '../persistence/stock-position-table.ts'; +import { + inventoryStockSharingEligibilities, + inventoryStockSharingEligibilityHistory, +} from '../persistence/stock-sharing-eligibility-table.ts'; + +export { INVENTORY_SCHEMA_NAME, inventorySchema } from './inventory-schema.ts'; +export { inventoryBackendConfigurations } from '../persistence/inventory-backend-configuration-table.ts'; +export { inventoryBindingCorrectionReconciliations } from '../persistence/binding-correction-impact-table.ts'; +export { + inventoryCatalogToStockBindingHistory, + inventoryCatalogToStockBindings, +} from '../persistence/catalog-to-stock-binding-table.ts'; +export { + inventoryCommitmentProtectionHistory, + inventoryCommitmentProtections, +} from '../persistence/commitment-protection-table.ts'; +export { inventoryExternalStockCorrelations } from '../persistence/external-stock-correlation-table.ts'; +export { inventoryEffectLedger, inventoryEffectLedgerHistory } from '../persistence/inventory-effect-ledger-table.ts'; +export { + inventoryObligationAllocations, + inventoryObligationRequirements, + inventoryObligations, +} from '../persistence/inventory-obligation-table.ts'; +export { inventoryPhysicalStockEffects } from '../persistence/physical-stock-effect-table.ts'; +export { + inventoryReservationConfirmationHistory, + inventoryReservationConfirmations, +} from '../persistence/reservation-confirmation-table.ts'; +export { inventoryReservationCreateEffects } from '../persistence/reservation-create-effect-table.ts'; +export { + inventoryReservationReleaseEffectHistory, + inventoryReservationReleaseEffects, +} from '../persistence/reservation-release-effect-table.ts'; +export { + inventoryReservationShortageImpactDecisions, + inventoryReservationShortageImpacts, +} from '../persistence/reservation-shortage-impact-table.ts'; +export { + inventorySourceAssertionCoverage, + inventorySourceAssertions, +} from '../persistence/inventory-source-assertion-table.ts'; +export { inventorySourceConflictRevisions } from '../persistence/inventory-source-conflict-table.ts'; +export { inventorySourceImportLedger } from '../persistence/inventory-source-import-ledger-table.ts'; +export { + inventoryStockCorrectionOpenReconciliations, + inventoryStockCorrections, +} from '../persistence/stock-correction-table.ts'; +export { + inventoryStockCorrectionSourceEvidence, + inventoryStockCorrectionSourceEvidenceCoverage, + inventoryStockCorrectionSourceEvidenceCurrent, +} from '../persistence/stock-correction-source-evidence-table.ts'; +export { inventoryStockItems } from '../persistence/stock-item-table.ts'; +export { inventoryStockLocationRevisions, inventoryStockLocations } from '../persistence/stock-location-table.ts'; +export { inventoryStockPositions } from '../persistence/stock-position-table.ts'; +export { + inventoryStockSharingEligibilities, + inventoryStockSharingEligibilityHistory, +} from '../persistence/stock-sharing-eligibility-table.ts'; + +export const INVENTORY_TABLE_INVENTORY = [ + 'backend_configurations', + 'binding_correction_reconciliations', + 'catalog_to_stock_binding_history', + 'catalog_to_stock_bindings', + 'commitment_protection_history', + 'commitment_protections', + 'effect_ledger', + 'effect_ledger_history', + 'external_stock_correlations', + 'obligation_allocations', + 'obligation_requirements', + 'obligations', + 'physical_stock_effects', + 'reservation_confirmation_history', + 'reservation_confirmations', + 'reservation_create_effects', + 'reservation_release_effect_history', + 'reservation_release_effects', + 'reservation_shortage_impact_decisions', + 'reservation_shortage_impacts', + 'source_assertion_coverage', + 'source_assertions', + 'source_conflict_revisions', + 'source_import_ledger', + 'stock_correction_open_reconciliations', + 'stock_correction_source_evidence', + 'stock_correction_source_evidence_coverage', + 'stock_correction_source_evidence_current', + 'stock_corrections', + 'stock_items', + 'stock_location_revisions', + 'stock_locations', + 'stock_positions', + 'stock_sharing_eligibilities', + 'stock_sharing_eligibility_history', +] as const; + +export const INVENTORY_TABLES: readonly PgTable[] = [ + inventoryBackendConfigurations, + inventoryBindingCorrectionReconciliations, + inventoryCatalogToStockBindingHistory, + inventoryCatalogToStockBindings, + inventoryCommitmentProtectionHistory, + inventoryCommitmentProtections, + inventoryEffectLedger, + inventoryEffectLedgerHistory, + inventoryExternalStockCorrelations, + inventoryObligationAllocations, + inventoryObligationRequirements, + inventoryObligations, + inventoryPhysicalStockEffects, + inventoryReservationConfirmationHistory, + inventoryReservationConfirmations, + inventoryReservationCreateEffects, + inventoryReservationReleaseEffectHistory, + inventoryReservationReleaseEffects, + inventoryReservationShortageImpactDecisions, + inventoryReservationShortageImpacts, + inventorySourceAssertionCoverage, + inventorySourceAssertions, + inventorySourceConflictRevisions, + inventorySourceImportLedger, + inventoryStockCorrectionOpenReconciliations, + inventoryStockCorrections, + inventoryStockCorrectionSourceEvidence, + inventoryStockCorrectionSourceEvidenceCoverage, + inventoryStockCorrectionSourceEvidenceCurrent, + inventoryStockItems, + inventoryStockLocationRevisions, + inventoryStockLocations, + inventoryStockPositions, + inventoryStockSharingEligibilities, + inventoryStockSharingEligibilityHistory, +] as const; + +const inventoryDatabaseSchemaIdentity = { + inventoryBackendConfigurations, + inventoryCatalogToStockBindingHistory, + inventoryCatalogToStockBindings, + inventoryCommitmentProtectionHistory, + inventoryCommitmentProtections, + inventoryEffectLedger, + inventoryEffectLedgerHistory, + inventoryExternalStockCorrelations, + inventoryObligationAllocations, + inventoryObligationRequirements, +} as const; + +const inventoryDatabaseSchemaReservations = { + inventoryBindingCorrectionReconciliations, + inventoryObligations, + inventoryPhysicalStockEffects, + inventoryReservationConfirmationHistory, + inventoryReservationConfirmations, + inventoryReservationCreateEffects, + inventoryReservationReleaseEffectHistory, + inventoryReservationReleaseEffects, + inventoryReservationShortageImpactDecisions, + inventoryReservationShortageImpacts, +} as const; + +const inventoryDatabaseSchemaEvidence = { + inventorySourceAssertionCoverage, + inventorySourceAssertions, + inventorySourceConflictRevisions, + inventorySourceImportLedger, + inventoryStockCorrectionOpenReconciliations, + inventoryStockCorrections, + inventoryStockCorrectionSourceEvidence, + inventoryStockCorrectionSourceEvidenceCoverage, +} as const; + +const inventoryDatabaseSchemaStock = { + inventoryStockCorrectionSourceEvidenceCurrent, + inventoryStockItems, + inventoryStockLocationRevisions, + inventoryStockLocations, + inventoryStockPositions, + inventoryStockSharingEligibilities, + inventoryStockSharingEligibilityHistory, +} as const; + +const inventoryDatabaseSchema: typeof inventoryDatabaseSchemaIdentity & + typeof inventoryDatabaseSchemaReservations & + typeof inventoryDatabaseSchemaEvidence & + typeof inventoryDatabaseSchemaStock = { + ...inventoryDatabaseSchemaIdentity, + ...inventoryDatabaseSchemaReservations, + ...inventoryDatabaseSchemaEvidence, + ...inventoryDatabaseSchemaStock, +}; + +type InventoryRelations = ExtractTablesWithRelations< + EmptyRelations, + ExtractTablesFromSchema +>; + +/** Relational Queries v2 entry point for the Inventory owner. */ +export const inventoryRelations: InventoryRelations = defineRelations(inventoryDatabaseSchema); diff --git a/app/verticals/inventory/src/database/types.ts b/app/verticals/inventory/src/database/types.ts new file mode 100644 index 000000000..24874b111 --- /dev/null +++ b/app/verticals/inventory/src/database/types.ts @@ -0,0 +1,5 @@ +import type { EffectPgDatabase } from 'drizzle-orm/effect-postgres'; + +import type { inventoryRelations } from './schema.ts'; + +export type InventoryDatabaseExecutor = EffectPgDatabase; diff --git a/app/verticals/inventory/src/domain/inventory-source-assertion-evaluator.ts b/app/verticals/inventory/src/domain/inventory-source-assertion-evaluator.ts new file mode 100644 index 000000000..11a7a269a --- /dev/null +++ b/app/verticals/inventory/src/domain/inventory-source-assertion-evaluator.ts @@ -0,0 +1,277 @@ +import type { Effect as EffectType, Option as OptionType } from 'effect'; +import { Effect, Match, Schema } from 'effect'; + +import { + InventorySourceAssertionRejected, + InventorySourceAssertionSchema, + InventorySourceAssertionUnavailable, + sourceAssertionBusinessTimeAtOrAfterSelection, +} from '../../shared/domain/inventory-source-assertion.ts'; +import type { + InventorySourceAssertionEvaluation, + InventorySourceAssertionPersistence, + InventorySourceAssertionProposal, +} from '../../shared/domain/inventory-source-assertion.ts'; +import type { InventoryBackendConfiguration } from '../../shared/domain/inventory-backend-configuration.ts'; +import { + ExternalStockItemTargetSchema, + ExternalStockLocationTargetSchema, +} from '../../shared/domain/external-stock-correlation.ts'; +import type { + ExternalStockCorrelationResolution, + ExternalStockCorrelationResolutionInput, + ResolvedExternalStockCorrelationSchema, +} from '../../shared/domain/external-stock-correlation.ts'; +import { AppliedPhysicalStockEffectSchema } from '../../shared/domain/physical-stock-effect.ts'; +import type { PhysicalStockEffectRecord } from '../../shared/domain/physical-stock-effect.ts'; +import type { StockPosition } from '../../shared/domain/stock-position.ts'; +import type { StockPositionRef } from '../../shared/resources/stock-position.ts'; + +interface InventorySourceAssertionCorrelationResolver { + readonly resolve: ( + input: ExternalStockCorrelationResolutionInput, + ) => EffectType.Effect; +} + +interface InventorySourceAssertionPositionReader { + readonly read: ( + positionRef: StockPositionRef, + ) => EffectType.Effect, InventorySourceAssertionUnavailable>; +} + +interface InventorySourceAssertionEffectReader { + readonly listAppliedForPosition: ( + positionRef: StockPositionRef, + ) => EffectType.Effect; +} + +interface InventorySourceAssertionEvaluatorDependencies { + readonly correlations: InventorySourceAssertionCorrelationResolver; + readonly effects: InventorySourceAssertionEffectReader; + readonly persistence: InventorySourceAssertionPersistence; + readonly positions: InventorySourceAssertionPositionReader; +} + +const rejected = ( + assertionId: InventorySourceAssertionProposal['assertionId'], + reason: InventorySourceAssertionRejected['reason'], + cause?: unknown, +) => { + const failure = new InventorySourceAssertionRejected({ + assertionId, + code: 'inventory_source_assertion_rejected', + reason, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const unavailable = (assertionId: InventorySourceAssertionProposal['assertionId'], cause: unknown) => { + const failure = new InventorySourceAssertionUnavailable({ + assertionId, + code: 'inventory_source_assertion_unavailable', + reason: 'Inventory Source Assertion dependency is temporarily unavailable', + retryable: true, + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +const sameRef = ( + left: { readonly resourceId: string; readonly tenantId: string }, + right: { readonly resourceId: string; readonly tenantId: string }, +) => left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +const sameUnit = (left: StockPosition['scope']['unitRef'], right: StockPosition['scope']['unitRef']) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const requireResolved = ( + assertionId: InventorySourceAssertionProposal['assertionId'], + resolution: ExternalStockCorrelationResolution, +): EffectType.Effect => + Match.value(resolution).pipe( + Match.tag('UNRESOLVED', () => Effect.fail(rejected(assertionId, 'CORRELATION_NOT_FOUND'))), + Match.tag('AMBIGUOUS', () => Effect.fail(rejected(assertionId, 'CORRELATION_AMBIGUOUS'))), + Match.tag('RESOLVED', (resolved) => Effect.succeed(resolved)), + Match.exhaustive, + ); + +const exactMaterialEffects = ( + assertion: typeof InventorySourceAssertionSchema.Type, + records: readonly PhysicalStockEffectRecord[], +) => + records.filter( + (record) => + Schema.is(AppliedPhysicalStockEffectSchema)(record) && + sameRef(record.request.positionRef, assertion.positionRef) && + sameRef(record.request.stockItemRef, assertion.stockItemRef) && + sameRef(record.request.stockLocationRef, assertion.stockLocationRef) && + sameUnit(record.request.quantity.unitRef, assertion.quantity.unitRef), + ); + +/** + * Evaluates owner-authored coverage for the exact material physical effects in an assertion scope. + * This is shared by source ingestion and later reconciliation so neither path invents arithmetic. + */ +export const evaluateInventorySourceAssertionCoverage = ( + assertion: typeof InventorySourceAssertionSchema.Type, + effects: readonly PhysicalStockEffectRecord[], +): EffectType.Effect => { + const materialEffects = exactMaterialEffects(assertion, effects); + const materialIds = new Set(materialEffects.map((effect) => effect.request.effectId)); + if (assertion.coverage.some((coverage) => !materialIds.has(coverage.effectId))) { + return Effect.fail(rejected(assertion.assertionId, 'COVERAGE_EFFECT_NOT_FOUND')); + } + if (assertion.issuerAuthority === 'HISTORICAL_PRE_CUTOVER_ISSUER') { + return Effect.succeed({ + _tag: 'HISTORICAL', + assertion, + postEffectOnHand: null, + reason: 'ISSUER_OUTSIDE_SELECTED_BACKEND', + reconciliationRequired: false, + }); + } + const coverageByEffect = new Map(assertion.coverage.map((coverage) => [coverage.effectId, coverage])); + const missingEffectIds: (typeof materialEffects)[number]['request']['effectId'][] = []; + const unknownEffectIds: (typeof materialEffects)[number]['request']['effectId'][] = []; + for (const effect of materialEffects) { + const { effectId } = effect.request; + const coverage = coverageByEffect.get(effectId); + if (coverage === undefined) { + missingEffectIds.push(effectId); + } else if (coverage.relation === 'UNKNOWN') { + unknownEffectIds.push(effectId); + } + } + if (missingEffectIds.length > 0) { + return Effect.succeed({ + _tag: 'INDETERMINATE', + assertion, + materialEffectIds: missingEffectIds, + postEffectOnHand: null, + reason: 'MATERIAL_EFFECT_COVERAGE_MISSING', + reconciliationRequired: true, + }); + } + if (unknownEffectIds.length > 0) { + return Effect.succeed({ + _tag: 'INDETERMINATE', + assertion, + materialEffectIds: unknownEffectIds, + postEffectOnHand: null, + reason: 'MATERIAL_EFFECT_COVERAGE_UNKNOWN', + reconciliationRequired: true, + }); + } + if ( + materialEffects.some((effect) => { + const relation = coverageByEffect.get(effect.request.effectId)?.relation; + return relation === 'EXCLUDES' || relation === 'PREDATES'; + }) + ) { + return Effect.succeed({ + _tag: 'HISTORICAL', + assertion, + postEffectOnHand: null, + reason: 'MATERIAL_EFFECT_EXCLUDED_OR_PREDATED', + reconciliationRequired: false, + }); + } + return Effect.succeed({ + _tag: 'DETERMINATE', + assertion, + postEffectOnHand: assertion.quantity, + reconciliationRequired: false, + }); +}; + +// oxlint-disable-next-line effect-native/no-dependency-parameters, effect-native/no-wide-factory-signature -- Core binds these owner-local ports inside one scoped Inventory operation; expires: 2027-03-31. +export const makeInventorySourceAssertionEvaluator = (dependencies: InventorySourceAssertionEvaluatorDependencies) => ({ + evaluate: Effect.fn('InventorySourceAssertionEvaluator.evaluate')(function* evaluate(input: { + readonly proposal: InventorySourceAssertionProposal; + readonly selectedConfiguration: InventoryBackendConfiguration; + }) { + if ( + input.selectedConfiguration.tenantId !== input.proposal.positionRef.tenantId || + input.selectedConfiguration.customerConfigurationId !== input.proposal.customerConfigurationId + ) { + return yield* rejected(input.proposal.assertionId, 'AUTHORITY_SCOPE_MISMATCH'); + } + const [itemResolution, locationResolution] = yield* Effect.all( + [ + dependencies.correlations.resolve({ + asOf: input.proposal.businessObservedAt, + externalKey: input.proposal.itemExternalKey, + selectedConfiguration: input.selectedConfiguration, + }), + dependencies.correlations.resolve({ + asOf: input.proposal.businessObservedAt, + externalKey: input.proposal.locationExternalKey, + selectedConfiguration: input.selectedConfiguration, + }), + ], + { concurrency: 2 }, + ).pipe( + Effect.mapError((cause) => unavailable(input.proposal.assertionId, cause)), + Effect.flatMap(([item, location]) => + Effect.all( + [requireResolved(input.proposal.assertionId, item), requireResolved(input.proposal.assertionId, location)], + { concurrency: 2 }, + ), + ), + ); + + if ( + !Schema.is(ExternalStockItemTargetSchema)(itemResolution.target) || + !Schema.is(ExternalStockLocationTargetSchema)(locationResolution.target) + ) { + return yield* rejected(input.proposal.assertionId, 'POSITION_SCOPE_MISMATCH'); + } + if (itemResolution.selectedBackendOriginMatch !== locationResolution.selectedBackendOriginMatch) { + return yield* rejected(input.proposal.assertionId, 'CORRELATION_AUTHORITY_MISMATCH'); + } + + const maybePosition = yield* dependencies.positions + .read(input.proposal.positionRef) + .pipe(Effect.mapError((cause) => unavailable(input.proposal.assertionId, cause))); + const position = yield* Effect.fromOption(maybePosition).pipe( + Effect.mapError((cause) => rejected(input.proposal.assertionId, 'POSITION_NOT_FOUND', cause)), + ); + if ( + position.scope.customerConfigurationId !== input.proposal.customerConfigurationId || + !sameRef(position.scope.stockItemRef, itemResolution.target.ref) || + !sameRef(position.scope.stockLocationRef, locationResolution.target.ref) || + !sameUnit(position.scope.unitRef, input.proposal.quantity.unitRef) + ) { + return yield* rejected(input.proposal.assertionId, 'POSITION_SCOPE_MISMATCH'); + } + + const assertion = yield* Schema.decodeEffect(InventorySourceAssertionSchema)({ + ...input.proposal, + authorityConfiguration: input.selectedConfiguration, + issuerAuthority: + itemResolution.selectedBackendOriginMatch === 'MATCHES_SELECTED_BACKEND' && + sourceAssertionBusinessTimeAtOrAfterSelection( + input.proposal.businessObservedAt, + input.selectedConfiguration.selectedAt, + ) + ? 'SELECTED_BACKEND' + : 'HISTORICAL_PRE_CUTOVER_ISSUER', + itemCorrelationRef: itemResolution.correlationRef, + locationCorrelationRef: locationResolution.correlationRef, + stockItemRef: itemResolution.target.ref, + stockLocationRef: locationResolution.target.ref, + }).pipe(Effect.mapError((cause) => unavailable(input.proposal.assertionId, cause))); + const materialEffects = yield* dependencies.effects + .listAppliedForPosition(input.proposal.positionRef) + .pipe(Effect.mapError((cause) => unavailable(input.proposal.assertionId, cause))); + const evaluation = yield* evaluateInventorySourceAssertionCoverage(assertion, materialEffects); + const stored = yield* dependencies.persistence.append(evaluation.assertion); + return { ...evaluation, assertion: stored }; + }), +}); diff --git a/app/verticals/inventory/src/federation-entry.tsx b/app/verticals/inventory/src/federation-entry.tsx new file mode 100644 index 000000000..e6c3b478e --- /dev/null +++ b/app/verticals/inventory/src/federation-entry.tsx @@ -0,0 +1,43 @@ +import { FederatedI18nBoundary, useModernI18n } from '@modern-js/plugin-i18n/runtime/consumer'; +import type { JSX } from 'react'; + +import csResource from '../locales/cs/inventory.json'; +import enResource from '../locales/en/inventory.json'; + +const federatedI18nLanguages = ['en', 'cs']; +const federatedI18nResources = { + cs: { inventory: csResource }, + en: { inventory: enResource }, +}; + +const InventoryRouteContent = () => { + const { t } = useModernI18n(); + + return ( +
+

{t('inventory.title')}

+

{t('inventory.routeSurface')}

+
+ ); +}; + +const InventoryRoute = (props: Record): JSX.Element => { + void props; + + return ( + + + + ); +}; + +export default InventoryRoute; diff --git a/app/verticals/inventory/src/modern-app-env.d.ts b/app/verticals/inventory/src/modern-app-env.d.ts new file mode 100644 index 000000000..d1afc6c0e --- /dev/null +++ b/app/verticals/inventory/src/modern-app-env.d.ts @@ -0,0 +1,3 @@ +/// + +declare const ULTRAMODERN_SITE_URL: string; diff --git a/app/verticals/inventory/src/modern.runtime.ts b/app/verticals/inventory/src/modern.runtime.ts new file mode 100644 index 000000000..d5083b992 --- /dev/null +++ b/app/verticals/inventory/src/modern.runtime.ts @@ -0,0 +1,34 @@ +import { assertI18nInstance } from '@modern-js/plugin-i18n/i18n'; +import { defineRuntimeConfig } from '@modern-js/runtime'; +import { createInstance } from 'i18next'; + +import csResource from '../locales/cs/inventory.json'; +import enResource from '../locales/en/inventory.json'; +import { ultramodernRouteNamespace } from './routes/ultramodern-route-metadata'; + +const i18nInstance = createInstance(); +assertI18nInstance(i18nInstance); +const resources = { + cs: { [ultramodernRouteNamespace]: csResource }, + en: { [ultramodernRouteNamespace]: enResource }, +} as const; + +export default defineRuntimeConfig({ + i18n: { + i18nInstance, + initOptions: { + defaultNS: ultramodernRouteNamespace, + fallbackLng: 'en', + interpolation: { + escapeValue: false, + }, + ns: [ultramodernRouteNamespace, 'translation'], + resources, + supportedLngs: ['en', 'cs'], + }, + }, + + router: { + framework: 'tanstack', + }, +}); diff --git a/app/verticals/inventory/src/persistence/binding-correction-impact-repository.ts b/app/verticals/inventory/src/persistence/binding-correction-impact-repository.ts new file mode 100644 index 000000000..60b8606c5 --- /dev/null +++ b/app/verticals/inventory/src/persistence/binding-correction-impact-repository.ts @@ -0,0 +1,195 @@ +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq } from 'drizzle-orm'; +import { DateTime, Effect, Schema } from 'effect'; + +import { CatalogToStockBindingUnavailable } from '../../shared/domain/catalog-to-stock-binding-unavailable.ts'; +import type { CommitmentProtection } from '../../shared/domain/commitment-protection.ts'; +import { CommitmentProtectionSchema } from '../../shared/domain/commitment-protection.ts'; +import type { ReservationConfirmation } from '../../shared/domain/reservation-confirmation.ts'; +import { ReservationConfirmationSchema } from '../../shared/domain/reservation-confirmation.ts'; +import type { + BindingCorrectionAffectedRequirement, + BindingCorrectionImpactPersistence, +} from '../services/binding-correction-impact.service.ts'; +import { inventoryBindingCorrectionReconciliations } from './binding-correction-impact-table.ts'; +import { commitmentProtectionPersistenceForScope } from './commitment-protection-repository.ts'; +import { inventoryCommitmentProtections } from './commitment-protection-table.ts'; +import { inventoryObligationRequirements, inventoryObligations } from './inventory-obligation-table.ts'; +import { reservationConfirmationPersistenceForScope } from './reservation-confirmation-repository.ts'; +import { inventoryReservationConfirmations } from './reservation-confirmation-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +interface AffectedRequirementRow { + readonly attemptId: string | null; + readonly lifecycleMeaning: string; + readonly obligationId: string; + readonly originKind: string; + readonly purchaseDemandOccurrenceId: string; +} + +const unavailable = (cause?: unknown) => { + const failure = new CatalogToStockBindingUnavailable({ + code: 'catalog_to_stock_binding_unavailable', + reason: 'Binding correction impact persistence is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const decodeConfirmation = (snapshot: ReservationConfirmation) => + Schema.decodeEffect(ReservationConfirmationSchema)(snapshot).pipe(Effect.mapError(unavailable)); +const decodeProtection = (snapshot: CommitmentProtection) => + Schema.decodeEffect(CommitmentProtectionSchema)(snapshot).pipe(Effect.mapError(unavailable)); + +export const bindingCorrectionImpactPersistenceForScope = ( + transaction: ScopedTransaction, + operationScope: OperationalScope, +): BindingCorrectionImpactPersistence => { + const confirmations = reservationConfirmationPersistenceForScope(transaction, operationScope); + const protections = commitmentProtectionPersistenceForScope(transaction, operationScope); + + const lockAffected: BindingCorrectionImpactPersistence['lockAffected'] = Effect.fn( + 'BindingCorrectionImpactPersistence.lockAffected', + )(function* lockAffectedRequirements(input) { + if (input.previousBinding.bindingRef.tenantId !== operationScope.tenantId) { + return yield* unavailable(); + } + const requirements = yield* transaction + .select({ + attemptId: inventoryObligations.attemptId, + lifecycleMeaning: inventoryObligations.lifecycleMeaning, + obligationId: inventoryObligationRequirements.obligationId, + originKind: inventoryObligations.originKind, + purchaseDemandOccurrenceId: inventoryObligationRequirements.purchaseDemandOccurrenceId, + }) + .from(inventoryObligationRequirements) + .innerJoin( + inventoryObligations, + and( + eq(inventoryObligations.tenantId, inventoryObligationRequirements.tenantId), + eq(inventoryObligations.obligationId, inventoryObligationRequirements.obligationId), + ), + ) + .where( + and( + eq(inventoryObligationRequirements.tenantId, operationScope.tenantId), + eq(inventoryObligationRequirements.bindingId, input.previousBinding.bindingRef.resourceId), + eq(inventoryObligationRequirements.stockItemId, input.previousBinding.stockItemRef.resourceId), + eq( + inventoryObligationRequirements.exactSelectionMeaningKind, + input.previousBinding.exactSelectionMeaning.kind, + ), + eq(inventoryObligationRequirements.exactSelectionMeaningId, input.previousBinding.exactSelectionMeaning.id), + ), + ) + .orderBy( + asc(inventoryObligationRequirements.obligationId), + asc(inventoryObligationRequirements.purchaseDemandOccurrenceId), + ) + .for('update', { of: inventoryObligations }) + .pipe(Effect.mapError(unavailable)); + + const loadLinkedOwnerState = Effect.fn('BindingCorrectionImpactPersistence.loadLinkedOwnerState')( + function* loadLinkedOwnerState( + requirement: AffectedRequirementRow, + ): Effect.fn.Return { + if ( + requirement.lifecycleMeaning !== 'PROVISIONAL_RESERVATION' && + requirement.lifecycleMeaning !== 'COMMITTED_OBLIGATION' + ) { + return yield* unavailable(); + } + if ( + requirement.originKind !== 'ORDER_COMMITMENT_ATTEMPT' && + requirement.originKind !== 'IMPORTED_PROVEN_ORDER' + ) { + return yield* unavailable(); + } + const common = { + lifecycleMeaning: requirement.lifecycleMeaning, + obligationId: requirement.obligationId, + purchaseDemandOccurrenceId: requirement.purchaseDemandOccurrenceId, + subjectResourceType: + requirement.originKind === 'IMPORTED_PROVEN_ORDER' + ? ('commerce.inventory.imported-committed-obligation' as const) + : ('commerce.inventory.inventory-reservation' as const), + } as const; + if (requirement.attemptId === null) { + return common; + } + const [confirmationRows, protectionRows] = yield* Effect.all( + [ + transaction + .select({ snapshot: inventoryReservationConfirmations.snapshot }) + .from(inventoryReservationConfirmations) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, operationScope.tenantId), + eq(inventoryReservationConfirmations.reservationId, requirement.obligationId), + eq(inventoryReservationConfirmations.attemptId, requirement.attemptId), + ), + ) + .for('update') + .limit(1) + .pipe(Effect.mapError(unavailable)), + transaction + .select({ snapshot: inventoryCommitmentProtections.snapshot }) + .from(inventoryCommitmentProtections) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + eq(inventoryCommitmentProtections.reservationId, requirement.obligationId), + eq(inventoryCommitmentProtections.attemptId, requirement.attemptId), + ), + ) + .for('update') + .limit(1) + .pipe(Effect.mapError(unavailable)), + ], + { concurrency: 1 }, + ); + const [confirmationRow] = confirmationRows; + const [protectionRow] = protectionRows; + const confirmation = + confirmationRow === undefined ? undefined : yield* decodeConfirmation(confirmationRow.snapshot); + const protection = protectionRow === undefined ? undefined : yield* decodeProtection(protectionRow.snapshot); + if (confirmation === undefined) { + return protection === undefined ? common : { ...common, protection }; + } + return protection === undefined ? { ...common, confirmation } : { ...common, confirmation, protection }; + }, + ); + return yield* Effect.forEach(requirements, loadLinkedOwnerState, { concurrency: 1 }); + }); + + const persistence: BindingCorrectionImpactPersistence = { + appendCommittedReconciliation: (debt) => + transaction + .insert(inventoryBindingCorrectionReconciliations) + .values({ + bindingId: debt.bindingId, + bindingRevision: debt.bindingRevision, + correctedAt: DateTime.toDateUtc(DateTime.makeUnsafe(debt.correctedAt)), + correctionEvidenceRef: debt.correctionEvidenceRef, + currentStockItemId: debt.currentStockItemId, + historicalStockItemId: debt.historicalStockItemId, + obligationId: debt.obligationId, + purchaseDemandOccurrenceId: debt.purchaseDemandOccurrenceId, + tenantId: debt.tenantId, + }) + .onConflictDoNothing() + .returning({ reconciliationId: inventoryBindingCorrectionReconciliations.reconciliationId }) + .pipe( + Effect.mapError(unavailable), + Effect.map(([inserted]) => (inserted === undefined ? 'EXACT_REPLAY' : 'APPENDED')), + ), + lockAffected, + saveConfirmation: (current, next) => + confirmations.saveRevision({ current, next }).pipe(Effect.mapError(unavailable)), + saveProtection: (current, next) => protections.saveRevision({ current, next }).pipe(Effect.mapError(unavailable)), + }; + return Object.freeze(persistence); +}; diff --git a/app/verticals/inventory/src/persistence/binding-correction-impact-table.ts b/app/verticals/inventory/src/persistence/binding-correction-impact-table.ts new file mode 100644 index 000000000..6f7a28caa --- /dev/null +++ b/app/verticals/inventory/src/persistence/binding-correction-impact-table.ts @@ -0,0 +1,62 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryObligationRequirements } from './inventory-obligation-table.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; + +export const inventoryBindingCorrectionReconciliations = inventorySchema.table.withRLS( + 'binding_correction_reconciliations', + { + reconciliationId: uuid('reconciliation_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + bindingId: uuid('binding_id').notNull(), + bindingRevision: integer('binding_revision').notNull(), + correctionEvidenceRef: text('correction_evidence_ref').notNull(), + correctedAt: timestamp('corrected_at', { withTimezone: true }).notNull(), + obligationId: uuid('obligation_id').notNull(), + purchaseDemandOccurrenceId: text('purchase_demand_occurrence_id').notNull(), + historicalStockItemId: uuid('historical_stock_item_id').notNull(), + currentStockItemId: uuid('current_stock_item_id').notNull(), + reason: text('reason').default('POST_COMMIT_BINDING_MISMATCH').notNull(), + status: text('status').default('OPEN').notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_binding_correction_reconciliations_scope_id_uk').on(table.tenantId, table.reconciliationId), + uniqueIndex('inventory_binding_correction_reconciliations_observation_uk').on( + table.tenantId, + table.bindingId, + table.bindingRevision, + table.obligationId, + table.purchaseDemandOccurrenceId, + ), + index('inventory_binding_correction_reconciliations_open_idx').on(table.tenantId, table.status, table.correctedAt), + foreignKey({ + columns: [table.tenantId, table.obligationId, table.purchaseDemandOccurrenceId], + foreignColumns: [ + inventoryObligationRequirements.tenantId, + inventoryObligationRequirements.obligationId, + inventoryObligationRequirements.purchaseDemandOccurrenceId, + ], + name: 'inventory_binding_correction_reconciliations_requirement_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.historicalStockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_binding_correction_reconciliations_historical_item_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.currentStockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_binding_correction_reconciliations_current_item_fk', + }).onDelete('restrict'), + check( + 'inventory_binding_correction_reconciliations_meaning_ck', + sql`${table.bindingRevision} >= 2 and char_length(btrim(${table.correctionEvidenceRef})) between 1 and 300 and char_length(btrim(${table.purchaseDemandOccurrenceId})) between 1 and 300 and ${table.reason} = 'POST_COMMIT_BINDING_MISMATCH' and ${table.status} = 'OPEN' and ${table.historicalStockItemId} <> ${table.currentStockItemId}`, + ), + ...tenantRlsPolicies('inventory_binding_correction_reconciliations_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/binding-correction-serialization.ts b/app/verticals/inventory/src/persistence/binding-correction-serialization.ts new file mode 100644 index 000000000..07429eecd --- /dev/null +++ b/app/verticals/inventory/src/persistence/binding-correction-serialization.ts @@ -0,0 +1,108 @@ +import type { ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import { Effect } from 'effect'; + +import type { + CatalogToStockBindingPersistence, + CatalogToStockBindingReader, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import type { ExactCatalogSelectionMeaning } from '../../shared/domain/stock-item.ts'; +import { inventoryCatalogToStockBindings } from './catalog-to-stock-binding-table.ts'; + +type ScopedTransaction = Pick>>>[0], 'select'>; + +export interface BindingCorrectionScope { + readonly exactSelectionMeaning: ExactCatalogSelectionMeaning; + readonly tenantId: string; +} + +export interface BindingCorrectionRequirementScope extends BindingCorrectionScope { + readonly bindingId: string; + readonly stockItemId: string; +} + +const lockKey = ({ exactSelectionMeaning, tenantId }: BindingCorrectionScope) => + `commerce.inventory:binding-correction:${tenantId}:${exactSelectionMeaning.kind}:${exactSelectionMeaning.id}`; + +const uniqueOrderedScopes = (scopes: readonly Scope[]) => + [...new Map(scopes.map((scope) => [lockKey(scope), scope])).entries()].toSorted(([left], [right]) => + left.localeCompare(right), + ); + +/** Serializes Current binding resolution and every child write, including when no child row exists yet. */ +export const lockBindingCorrectionScopes = Effect.fn('BindingCorrectionSerialization.lockScopes')(function* lockScopes( + transaction: ScopedTransaction, + scopes: readonly BindingCorrectionScope[], +) { + yield* Effect.forEach( + uniqueOrderedScopes(scopes), + ([, scope]) => + transaction + .select({ bindingId: inventoryCatalogToStockBindings.bindingId }) + .from(inventoryCatalogToStockBindings) + .where( + and( + eq(inventoryCatalogToStockBindings.tenantId, scope.tenantId), + eq(inventoryCatalogToStockBindings.exactSelectionKind, scope.exactSelectionMeaning.kind), + eq(inventoryCatalogToStockBindings.exactSelectionMeaningId, scope.exactSelectionMeaning.id), + ), + ) + .for('update') + .pipe(Effect.asVoid), + { concurrency: 1 }, + ); +}); + +export const currentBindingRequirementsMatch = Effect.fn('BindingCorrectionSerialization.requireCurrentBindings')( + function* requireCurrentBindings( + transaction: ScopedTransaction, + requirements: readonly BindingCorrectionRequirementScope[], + ) { + const matches = yield* Effect.forEach( + uniqueOrderedScopes(requirements).map(([, requirement]) => requirement), + (requirement) => + transaction + .select({ + bindingId: inventoryCatalogToStockBindings.bindingId, + stockItemId: inventoryCatalogToStockBindings.stockItemId, + }) + .from(inventoryCatalogToStockBindings) + .where( + and( + eq(inventoryCatalogToStockBindings.tenantId, requirement.tenantId), + eq(inventoryCatalogToStockBindings.exactSelectionKind, requirement.exactSelectionMeaning.kind), + eq(inventoryCatalogToStockBindings.exactSelectionMeaningId, requirement.exactSelectionMeaning.id), + ), + ) + .for('update') + .limit(2) + .pipe( + Effect.map( + (rows) => + rows.length === 1 && + rows[0]?.bindingId === requirement.bindingId && + rows[0]?.stockItemId === requirement.stockItemId, + ), + ), + { concurrency: 1 }, + ); + return matches.every(Boolean); + }, +); + +export const serializeCatalogToStockBindingReader = ( + transaction: ScopedTransaction, + reader: Reader, +): Reader => + Object.freeze({ + ...reader, + findCurrentByExactSelectionMeaning: (tenantId, exactSelectionMeaning) => + lockBindingCorrectionScopes(transaction, [{ exactSelectionMeaning, tenantId }]).pipe( + Effect.andThen(reader.findCurrentByExactSelectionMeaning(tenantId, exactSelectionMeaning)), + ), + }); + +export const serializeCatalogToStockBindingPersistence = ( + transaction: ScopedTransaction, + persistence: CatalogToStockBindingPersistence, +): CatalogToStockBindingPersistence => serializeCatalogToStockBindingReader(transaction, persistence); diff --git a/app/verticals/inventory/src/persistence/catalog-to-stock-binding-repository.ts b/app/verticals/inventory/src/persistence/catalog-to-stock-binding-repository.ts new file mode 100644 index 000000000..bc0fd5f58 --- /dev/null +++ b/app/verticals/inventory/src/persistence/catalog-to-stock-binding-repository.ts @@ -0,0 +1,354 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + CatalogToStockBindingHistoryEntrySchema, + CatalogToStockBindingRejected, + CatalogToStockBindingSchema, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import { CatalogToStockBindingUnavailable } from '../../shared/domain/catalog-to-stock-binding-unavailable.ts'; +import type { + CatalogToStockBinding, + CatalogToStockBindingPersistence, + CatalogToStockBindingStockItemReader, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import type { CatalogToStockBindingRef } from '../../shared/resources/catalog-to-stock-binding.ts'; +import { + inventoryCatalogToStockBindingHistory, + inventoryCatalogToStockBindingCompatibilityTriggerContract, + inventoryCatalogToStockBindings, +} from './catalog-to-stock-binding-table.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; +import type { StockItemRepositoryService } from './stock-item-repository.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type BindingRow = typeof inventoryCatalogToStockBindings.$inferSelect; +type StockItemTargetRow = typeof inventoryStockItems.$inferSelect; + +const unavailable = (cause?: unknown): CatalogToStockBindingUnavailable => { + const failure = new CatalogToStockBindingUnavailable({ + code: 'catalog_to_stock_binding_unavailable', + reason: 'Catalog-to-Stock Binding persistence is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const reject = (reason: CatalogToStockBindingRejected['reason']) => + new CatalogToStockBindingRejected({ code: 'catalog_to_stock_binding_rejected', reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); + +// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Core's PostgreSQL decoder owns inspection of the opaque driver cause. +export const mapCatalogToStockBindingWriteError = (error: unknown) => { + const { failureConstraints } = inventoryCatalogToStockBindingCompatibilityTriggerContract; + const targetFailure = findPostgresFailure(error, ({ code, constraint }) => { + if (code === foreignKeyViolationSqlState && constraint === 'inventory_catalog_to_stock_bindings_stock_item_fk') { + return true; + } + return code === checkViolationSqlState && Object.values(failureConstraints).some((owned) => owned === constraint); + }); + if (Option.isSome(targetFailure)) { + const { constraint } = targetFailure.value; + if (constraint === failureConstraints.current) { + return reject('STOCK_ITEM_NOT_CURRENT'); + } + if (constraint === failureConstraints.meaning || constraint === failureConstraints.stockItemMutation) { + return reject('INTRINSIC_MEANING_MISMATCH'); + } + if (constraint === failureConstraints.unit) { + return reject('STOCK_UNIT_MISMATCH'); + } + return reject('STOCK_ITEM_NOT_FOUND'); + } + const selectionConflict = findPostgresFailure( + error, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_catalog_to_stock_bindings_selection_meaning_uk', + ); + if (Option.isSome(selectionConflict)) { + return reject('SELECTION_MEANING_ALREADY_BOUND'); + } + const targetConflict = findPostgresFailure( + error, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_catalog_to_stock_bindings_stock_item_uk', + ); + if (Option.isSome(targetConflict)) { + return reject('STOCK_ITEM_ALREADY_BOUND'); + } + const bindingIdentityConflict = findPostgresFailure( + error, + ({ code, constraint }) => + code === uniqueViolationSqlState && + ['catalog_to_stock_bindings_pkey', 'inventory_catalog_to_stock_bindings_scope_id_uk'].includes(constraint ?? ''), + ); + if (Option.isSome(bindingIdentityConflict)) { + return reject('BINDING_ID_CONFLICT'); + } + const historyConflict = findPostgresFailure( + error, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_catalog_to_stock_binding_history_revision_uk', + ); + return Option.isSome(historyConflict) ? reject('REVISION_CONFLICT') : unavailable(error); +}; + +const instantAsDate = (instant: CatalogToStockBinding['effectiveFrom']) => + DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const bindingValues = (binding: CatalogToStockBinding) => ({ + bindingId: binding.bindingRef.resourceId, + catalogSelection: binding.catalogSelection, + currentRevision: binding.revision, + effectiveFrom: instantAsDate(binding.effectiveFrom), + exactSelectionKind: binding.exactSelectionMeaning.kind, + exactSelectionMeaningId: binding.exactSelectionMeaning.id, + stockItemId: binding.stockItemRef.resourceId, + stockUnitModuleId: binding.unitRef.moduleId, + stockUnitResourceId: binding.unitRef.resourceId, + stockUnitResourceType: binding.unitRef.resourceType, + stockUnitTenantId: binding.unitRef.tenantId, + tenantId: binding.bindingRef.tenantId, +}); + +const bindingReplacementValues = (binding: CatalogToStockBinding) => ({ + currentRevision: binding.revision, + effectiveFrom: instantAsDate(binding.effectiveFrom), + exactSelectionKind: binding.exactSelectionMeaning.kind, + exactSelectionMeaningId: binding.exactSelectionMeaning.id, + stockItemId: binding.stockItemRef.resourceId, + stockUnitModuleId: binding.unitRef.moduleId, + stockUnitResourceId: binding.unitRef.resourceId, + stockUnitResourceType: binding.unitRef.resourceType, + stockUnitTenantId: binding.unitRef.tenantId, +}); + +export const validateCatalogToStockBindingTarget = ( + binding: CatalogToStockBinding, + target: StockItemTargetRow | undefined, +) => { + if (target === undefined) { + return Effect.fail(reject('STOCK_ITEM_NOT_FOUND')); + } + if (target.lifecycleState !== 'CURRENT') { + return Effect.fail(reject('STOCK_ITEM_NOT_CURRENT')); + } + if ( + target.exactSelectionMeaningId !== binding.exactSelectionMeaning.id || + target.exactSelectionKind !== binding.exactSelectionMeaning.kind + ) { + return Effect.fail(reject('INTRINSIC_MEANING_MISMATCH')); + } + return target.stockUnitModuleId === binding.unitRef.moduleId && + target.stockUnitResourceId === binding.unitRef.resourceId && + target.stockUnitResourceType === binding.unitRef.resourceType && + target.stockUnitTenantId === binding.unitRef.tenantId + ? Effect.succeed(binding) + : Effect.fail(reject('STOCK_UNIT_MISMATCH')); +}; + +const decodeBinding = (row: BindingRow) => + Schema.decodeUnknownEffect(CatalogToStockBindingSchema)({ + bindingRef: { + moduleId: 'commerce.inventory', + resourceId: row.bindingId, + resourceType: 'commerce.inventory.catalog-to-stock-binding', + tenantId: row.tenantId, + }, + catalogSelection: row.catalogSelection, + effectiveFrom: row.effectiveFrom.toISOString(), + exactSelectionMeaning: { id: row.exactSelectionMeaningId, kind: row.exactSelectionKind }, + revision: row.currentRevision, + stockItemRef: { + moduleId: 'commerce.inventory', + resourceId: row.stockItemId, + resourceType: 'commerce.inventory.stock-item', + tenantId: row.tenantId, + }, + unitRef: { + moduleId: row.stockUnitModuleId, + resourceId: row.stockUnitResourceId, + resourceType: row.stockUnitResourceType, + tenantId: row.stockUnitTenantId, + }, + }).pipe(Effect.mapError(unavailable)); + +export const catalogToStockBindingStockItemReader = ( + stockItems: Pick, +): CatalogToStockBindingStockItemReader => ({ + findById: (tenantId, stockItemId) => stockItems.findById(tenantId, stockItemId).pipe(Effect.mapError(unavailable)), +}); + +export const makeDrizzleCatalogToStockBindingPersistence = ( + transaction: ScopedTransaction, +): CatalogToStockBindingPersistence => { + const assertPersistableTarget = (binding: CatalogToStockBinding) => + transaction + .select() + .from(inventoryStockItems) + .where( + and( + eq(inventoryStockItems.tenantId, binding.stockItemRef.tenantId), + eq(inventoryStockItems.stockItemId, binding.stockItemRef.resourceId), + ), + ) + .for('update') + .limit(1) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap(([target]) => validateCatalogToStockBindingTarget(binding, target)), + ); + + const replaceCurrent: CatalogToStockBindingPersistence['replaceCurrent'] = Effect.fn( + 'CatalogToStockBindingPersistence.replaceCurrent', + )(function* replaceBinding({ current, historyEntry, next }) { + yield* assertPersistableTarget(next); + yield* transaction + .insert(inventoryCatalogToStockBindingHistory) + .values({ + bindingId: current.bindingRef.resourceId, + endedAt: instantAsDate(historyEntry.endedAt), + ownerEvidenceRef: historyEntry.ownerEvidenceRef, + revision: current.revision, + snapshot: current, + tenantId: current.bindingRef.tenantId, + transition: historyEntry.transition, + }) + .pipe(Effect.mapError(mapCatalogToStockBindingWriteError)); + + const [row] = yield* transaction + .update(inventoryCatalogToStockBindings) + .set(bindingReplacementValues(next)) + .where( + and( + eq(inventoryCatalogToStockBindings.tenantId, current.bindingRef.tenantId), + eq(inventoryCatalogToStockBindings.bindingId, current.bindingRef.resourceId), + eq(inventoryCatalogToStockBindings.currentRevision, current.revision), + eq(inventoryCatalogToStockBindings.stockItemId, current.stockItemRef.resourceId), + ), + ) + .returning() + .pipe(Effect.mapError(mapCatalogToStockBindingWriteError)); + + if (row === undefined) { + return yield* reject('REVISION_CONFLICT'); + } + return yield* decodeBinding(row); + }); + + const endCurrent: CatalogToStockBindingPersistence['endCurrent'] = Effect.fn( + 'CatalogToStockBindingPersistence.endCurrent', + )(function* endBinding({ current, historyEntry }) { + yield* transaction + .insert(inventoryCatalogToStockBindingHistory) + .values({ + bindingId: current.bindingRef.resourceId, + endedAt: instantAsDate(historyEntry.endedAt), + ownerEvidenceRef: historyEntry.ownerEvidenceRef, + revision: current.revision, + snapshot: current, + tenantId: current.bindingRef.tenantId, + transition: historyEntry.transition, + }) + .pipe(Effect.mapError(mapCatalogToStockBindingWriteError)); + + const [removed] = yield* transaction + .delete(inventoryCatalogToStockBindings) + .where( + and( + eq(inventoryCatalogToStockBindings.tenantId, current.bindingRef.tenantId), + eq(inventoryCatalogToStockBindings.bindingId, current.bindingRef.resourceId), + eq(inventoryCatalogToStockBindings.currentRevision, current.revision), + eq(inventoryCatalogToStockBindings.stockItemId, current.stockItemRef.resourceId), + ), + ) + .returning({ bindingId: inventoryCatalogToStockBindings.bindingId }) + .pipe(Effect.mapError(mapCatalogToStockBindingWriteError)); + + if (removed === undefined) { + return yield* reject('REVISION_CONFLICT'); + } + return historyEntry; + }); + + return { + endCurrent, + findCurrentByExactSelectionMeaning: (tenantId, exactSelectionMeaning) => + transaction + .select() + .from(inventoryCatalogToStockBindings) + .where( + and( + eq(inventoryCatalogToStockBindings.tenantId, tenantId), + eq(inventoryCatalogToStockBindings.exactSelectionMeaningId, exactSelectionMeaning.id), + ), + ) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap((rows) => Effect.forEach(rows, (row) => decodeBinding(row), { concurrency: 1 })), + ), + findCurrentByStockItem: (stockItemRef) => + transaction + .select() + .from(inventoryCatalogToStockBindings) + .where( + and( + eq(inventoryCatalogToStockBindings.tenantId, stockItemRef.tenantId), + eq(inventoryCatalogToStockBindings.stockItemId, stockItemRef.resourceId), + ), + ) + .limit(1) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeBinding(row).pipe(Effect.asSome))), + ), + insertCurrent: (binding) => + assertPersistableTarget(binding).pipe( + Effect.flatMap(() => + transaction + .insert(inventoryCatalogToStockBindings) + .values(bindingValues(binding)) + .returning() + .pipe( + Effect.mapError(mapCatalogToStockBindingWriteError), + Effect.flatMap(([row]) => (row === undefined ? Effect.fail(unavailable()) : decodeBinding(row))), + ), + ), + ), + readHistory: (bindingRef: CatalogToStockBindingRef) => + transaction + .select() + .from(inventoryCatalogToStockBindingHistory) + .where( + and( + eq(inventoryCatalogToStockBindingHistory.tenantId, bindingRef.tenantId), + eq(inventoryCatalogToStockBindingHistory.bindingId, bindingRef.resourceId), + ), + ) + .orderBy(asc(inventoryCatalogToStockBindingHistory.revision)) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap((rows) => + Effect.forEach( + rows, + (row) => + Schema.decodeEffect(CatalogToStockBindingHistoryEntrySchema)({ + binding: row.snapshot, + endedAt: row.endedAt.toISOString(), + ownerEvidenceRef: row.ownerEvidenceRef, + transition: row.transition, + }).pipe(Effect.mapError(unavailable)), + { concurrency: 1 }, + ), + ), + ), + replaceCurrent, + }; +}; diff --git a/app/verticals/inventory/src/persistence/catalog-to-stock-binding-table.ts b/app/verticals/inventory/src/persistence/catalog-to-stock-binding-table.ts new file mode 100644 index 000000000..893f408d1 --- /dev/null +++ b/app/verticals/inventory/src/persistence/catalog-to-stock-binding-table.ts @@ -0,0 +1,115 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, integer, jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { CatalogSelection } from '@app/catalog/domain/catalog-selection-evidence'; + +import type { + CatalogToStockBinding, + CatalogToStockBindingHistoryEntry, +} from '../../shared/domain/catalog-to-stock-binding.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; + +export const inventoryCatalogToStockBindings = inventorySchema.table.withRLS( + 'catalog_to_stock_bindings', + { + bindingId: uuid('binding_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + catalogSelection: jsonb('catalog_selection').$type().notNull(), + exactSelectionMeaningId: text('exact_selection_meaning_id').notNull(), + exactSelectionKind: text('exact_selection_kind').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockUnitModuleId: text('stock_unit_module_id').notNull(), + stockUnitResourceId: uuid('stock_unit_resource_id').notNull(), + stockUnitResourceType: text('stock_unit_resource_type').notNull(), + stockUnitTenantId: uuid('stock_unit_tenant_id').notNull(), + currentRevision: integer('current_revision').default(1).notNull(), + effectiveFrom: timestamp('effective_from', { withTimezone: true }).notNull(), + }, + (table) => [ + uniqueIndex('inventory_catalog_to_stock_bindings_scope_id_uk').on(table.tenantId, table.bindingId), + uniqueIndex('inventory_catalog_to_stock_bindings_selection_meaning_uk').on( + table.tenantId, + table.exactSelectionMeaningId, + ), + uniqueIndex('inventory_catalog_to_stock_bindings_stock_item_uk').on(table.tenantId, table.stockItemId), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_catalog_to_stock_bindings_stock_item_fk', + }).onDelete('restrict'), + check( + 'inventory_catalog_to_stock_bindings_meaning_ck', + sql`char_length(btrim(${table.exactSelectionMeaningId})) between 1 and 300 and ${table.exactSelectionKind} in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')`, + ), + check( + 'inventory_catalog_to_stock_bindings_unit_ck', + sql`${table.stockUnitModuleId} = 'commerce.catalog' and ${table.stockUnitResourceType} = 'commerce.catalog.product-unit' and ${table.stockUnitTenantId} = ${table.tenantId}`, + ), + check('inventory_catalog_to_stock_bindings_revision_ck', sql`${table.currentRevision} >= 1`), + ...tenantRlsPolicies('inventory_catalog_to_stock_bindings_tenant', table.tenantId), + ], +); + +export const inventoryCatalogToStockBindingHistory = inventorySchema.table.withRLS( + 'catalog_to_stock_binding_history', + { + bindingHistoryId: uuid('binding_history_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + bindingId: uuid('binding_id').notNull(), + revision: integer('revision').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + endedAt: timestamp('ended_at', { withTimezone: true }).notNull(), + transition: text('transition').$type().notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_catalog_to_stock_binding_history_scope_id_uk').on(table.tenantId, table.bindingHistoryId), + uniqueIndex('inventory_catalog_to_stock_binding_history_revision_uk').on( + table.tenantId, + table.bindingId, + table.revision, + ), + check('inventory_catalog_to_stock_binding_history_revision_ck', sql`${table.revision} >= 1`), + check( + 'inventory_catalog_to_stock_binding_history_transition_ck', + sql`${table.transition} in ('CORRECTED', 'ENDED', 'SUPERSEDED') and char_length(btrim(${table.ownerEvidenceRef})) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_catalog_to_stock_binding_history_tenant', table.tenantId), + ], +); + +export const inventoryCatalogToStockBindingHistoryImmutabilityContract = { + currentRetention: 'CURRENT_ROW_REMOVED_AFTER_ARCHIVE', + deleteTriggerName: 'inventory_catalog_to_stock_binding_history_no_delete_trg', + functionName: 'inventory.reject_catalog_to_stock_binding_history_mutation', + table: 'inventory.catalog_to_stock_binding_history', + updateTriggerName: 'inventory_catalog_to_stock_binding_history_no_update_trg', +} as const; + +export const inventoryCatalogToStockBindingCompatibilityTriggerContract = { + bindingFunctionName: 'inventory.enforce_catalog_to_stock_binding_compatibility', + bindingTable: 'inventory.catalog_to_stock_bindings', + bindingTriggerName: 'inventory_catalog_to_stock_bindings_compatibility_trg', + failureConstraints: { + current: 'inventory_catalog_to_stock_bindings_target_current_ck', + meaning: 'inventory_catalog_to_stock_bindings_target_meaning_ck', + missing: 'inventory_catalog_to_stock_bindings_target_missing_ck', + stockItemMutation: 'inventory_stock_items_current_binding_target_ck', + unit: 'inventory_catalog_to_stock_bindings_target_unit_ck', + }, + stockItemFunctionName: 'inventory.protect_current_catalog_to_stock_binding_target', + stockItemTable: 'inventory.stock_items', + stockItemTriggerName: 'inventory_stock_items_current_binding_target_trg', + timing: 'BEFORE', +} as const; + +export const inventoryCatalogToStockBindingMeaningKeyContract = { + columns: ['tenant_id', 'exact_selection_meaning_id'], + evidenceOnlyPath: 'catalog_selection.configuration.definition.revision', + indexName: 'inventory_catalog_to_stock_bindings_selection_meaning_uk', + provenanceColumn: 'catalog_selection', +} as const; diff --git a/app/verticals/inventory/src/persistence/commitment-protection-repository.ts b/app/verticals/inventory/src/persistence/commitment-protection-repository.ts new file mode 100644 index 000000000..017c5d4bd --- /dev/null +++ b/app/verticals/inventory/src/persistence/commitment-protection-repository.ts @@ -0,0 +1,448 @@ +import { defineScopedRoutine, findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, asc, eq, or } from 'drizzle-orm'; +import { DateTime, Effect, Option, Result, Schema } from 'effect'; + +import { + CommitmentProtectionRejected, + CommitmentProtectionEffectSchema, + CommitmentProtectionSchema, + CommitmentProtectionUnavailable, + sameCommitmentProtectionRequest, +} from '../../shared/domain/commitment-protection.ts'; +import type { + CommitmentProtection, + CommitmentProtectionEffect, + CommitmentProtectionPersistence, + EstablishCommitmentProtectionError, +} from '../../shared/domain/commitment-protection.ts'; +import { + CommitmentProtectionInventoryEffectLedgerIntentSchema, + InventoryEffectLedgerRecordSchema, +} from '../../shared/domain/inventory-effect-ledger.ts'; +import type { InventoryEffectLedgerRecord } from '../../shared/domain/inventory-effect-ledger.ts'; +import { ReservationAuthorityEffectIdSchema } from '../../shared/domain/reservation-issuer-failure-fields.ts'; +import { currentBindingRequirementsMatch, lockBindingCorrectionScopes } from './binding-correction-serialization.ts'; +import { + inventoryCommitmentProtectionHistory, + inventoryCommitmentProtectionScopeContract, + inventoryCommitmentProtections, +} from './commitment-protection-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type ProtectionRow = typeof inventoryCommitmentProtections.$inferSelect; +type HistoryRow = typeof inventoryCommitmentProtectionHistory.$inferSelect; +type ProtectionEffectId = typeof ReservationAuthorityEffectIdSchema.Type; + +const workerFinalizationRowSchema = Schema.Struct({ record: InventoryEffectLedgerRecordSchema }); +export const finalizeCommitmentProtectionForWorkerRoutine = defineScopedRoutine({ + name: 'finalize_commitment_protection_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'integer' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: workerFinalizationRowSchema, + routineKey: 'inventory.finalize-commitment-protection-for-worker', + schema: 'inventory', +}); + +const persistenceReadEffectId = Result.getOrThrow( + Schema.decodeResult(ReservationAuthorityEffectIdSchema)('commitment-protection:persistence-read'), +); + +const unavailable = (effectId: ProtectionEffectId, cause?: unknown) => { + const failure = new CommitmentProtectionUnavailable({ + code: 'commitment_protection_unavailable', + effectId, + reason: 'Commitment Protection persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const rejected = (effectId: ProtectionEffectId, reason: CommitmentProtectionRejected['reason']) => + new CommitmentProtectionRejected({ code: 'commitment_protection_rejected', effectId, reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); + +export const mapCommitmentProtectionWriteError = ( + effectId: ProtectionEffectId, + cause: unknown, +): EstablishCommitmentProtectionError => { + const revision = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_commitment_protection_history_revision_uk', + ); + if (Option.isSome(revision)) { + return rejected(effectId, 'REVISION_CONFLICT'); + } + const sibling = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_commitment_protections_reservation_attempt_uk', + ); + if (Option.isSome(sibling)) { + return rejected(effectId, 'SIBLING_PROTECTION_FORBIDDEN'); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === uniqueViolationSqlState && + [ + 'commitment_protections_pkey', + 'inventory_commitment_protections_scope_id_uk', + 'inventory_commitment_protections_confirmation_uk', + 'inventory_commitment_protections_authority_effect_uk', + ].includes(constraint ?? '')) || + (code === checkViolationSqlState && constraint === 'inventory_commitment_protection_worker_finalization_ck'), + ); + if (Option.isSome(identity)) { + return rejected(effectId, 'PROTECTION_IDENTITY_CONFLICT'); + } + const { constraintNames } = inventoryCommitmentProtectionScopeContract; + const confirmationScopeConstraints = new Set([constraintNames.confirmation, constraintNames.reservation]); + const confirmation = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === foreignKeyViolationSqlState && + [ + 'inventory_commitment_protections_confirmation_fk', + 'inventory_commitment_protections_reservation_fk', + ].includes(constraint ?? '')) || + (code === checkViolationSqlState && confirmationScopeConstraints.has(constraint ?? '')), + ); + if (Option.isSome(confirmation)) { + return rejected(effectId, 'CONFIRMATION_SCOPE_MISMATCH'); + } + const authority = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === foreignKeyViolationSqlState && + constraint === 'inventory_commitment_protections_backend_configuration_fk') || + (code === checkViolationSqlState && constraint === constraintNames.authority), + ); + if (Option.isSome(authority)) { + return rejected(effectId, 'AUTHORITY_SCOPE_MISMATCH'); + } + const proof = findPostgresFailure( + cause, + ({ code, constraint }) => code === checkViolationSqlState && constraint === constraintNames.snapshot, + ); + if (Option.isSome(proof)) { + return rejected(effectId, 'PROOF_SCOPE_MISMATCH'); + } + const invalid = findPostgresFailure( + cause, + ({ code, constraint }) => + code === checkViolationSqlState && + [ + 'inventory_commitment_protections_meaning_ck', + 'inventory_commitment_protections_health_ck', + 'inventory_commitment_protection_history_health_ck', + ].includes(constraint ?? ''), + ); + return Option.isSome(invalid) ? rejected(effectId, 'INVALID_PROTECTION') : unavailable(effectId, cause); +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const valuesFor = (protection: CommitmentProtection) => ({ + attemptId: protection.confirmation.reservation.origin.attemptId, + authorityEffectId: protection.authorityEvidence.effectId, + confirmationId: protection.confirmation.ref.resourceId, + currentHealthState: protection.health.state, + currentRevision: protection.revision, + establishedAt: instantAsDate(protection.establishedAt), + issuerBackendId: protection.authorityEvidence.issuer.backendId, + issuerBackendKind: protection.authorityEvidence.issuer.backend, + ownerConfigurationId: protection.confirmation.reservation.authority.configurationId, + ownerEvidenceRef: protection.authorityEvidence.evidence.ownerEvidenceRef, + protectionId: protection.ref.resourceId, + reservationId: protection.confirmation.reservation.ref.resourceId, + snapshot: protection, + tenantId: protection.ref.tenantId, + updatedAt: instantAsDate(protection.health.observation.effectiveAt), +}); + +const decodeSnapshot = (effectId: ProtectionEffectId, snapshot: CommitmentProtection) => + Schema.decodeEffect(CommitmentProtectionSchema)(snapshot).pipe( + Effect.mapError((cause) => unavailable(effectId, cause)), + ); + +export const decodeCommitmentProtectionHistoryRows = ( + effectId: ProtectionEffectId, + rows: readonly Pick[], +) => Effect.forEach(rows, ({ snapshot }) => decodeSnapshot(effectId, snapshot), { concurrency: 1 }); + +export const commitmentProtectionPersistenceForScope = ( + transaction: ScopedTransaction, + operationScope: Pick, +): CommitmentProtectionPersistence => { + const requireCandidateTenant = (protection: CommitmentProtection) => + protection.ref.tenantId === operationScope.tenantId + ? Effect.void + : Effect.fail(rejected(protection.authorityEvidence.effectId, 'TENANT_SCOPE_MISMATCH')); + + const decodeRow = (row: ProtectionRow) => + Schema.decodeEffect(ReservationAuthorityEffectIdSchema)(row.authorityEffectId).pipe( + Effect.mapError((cause) => unavailable(persistenceReadEffectId, cause)), + Effect.flatMap((effectId) => decodeSnapshot(effectId, row.snapshot)), + ); + + const appendHistory = (protection: CommitmentProtection) => + transaction + .insert(inventoryCommitmentProtectionHistory) + .values({ + healthState: protection.health.state, + protectionId: protection.ref.resourceId, + revision: protection.revision, + snapshot: protection, + tenantId: protection.ref.tenantId, + transitionedAt: instantAsDate(protection.health.observation.effectiveAt), + }) + .pipe( + Effect.mapError((cause) => mapCommitmentProtectionWriteError(protection.authorityEvidence.effectId, cause)), + Effect.asVoid, + ); + + const findByRef: CommitmentProtectionPersistence['findByRef'] = Effect.fn( + 'CommitmentProtectionPersistence.findByRef', + )(function* findProtection(ref) { + if (ref.tenantId !== operationScope.tenantId) { + return yield* unavailable(persistenceReadEffectId); + } + const [row] = yield* transaction + .select() + .from(inventoryCommitmentProtections) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + eq(inventoryCommitmentProtections.protectionId, ref.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(persistenceReadEffectId, cause))); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }); + + const findByReservationAttempt: CommitmentProtectionPersistence['findByReservationAttempt'] = Effect.fn( + 'CommitmentProtectionPersistence.findByReservationAttempt', + )(function* findProtectionByReservationAttempt(reservationId, attemptId) { + const [row] = yield* transaction + .select() + .from(inventoryCommitmentProtections) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + eq(inventoryCommitmentProtections.reservationId, reservationId), + eq(inventoryCommitmentProtections.attemptId, attemptId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(persistenceReadEffectId, cause))); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }); + + const createOrRead: CommitmentProtectionPersistence['createOrRead'] = Effect.fn( + 'CommitmentProtectionPersistence.createOrRead', + )(function* createOrReadProtection(candidate) { + yield* requireCandidateTenant(candidate); + const bindingRequirements = candidate.confirmation.reservation.requirements.map((requirement) => ({ + bindingId: requirement.bindingRef.resourceId, + exactSelectionMeaning: requirement.exactSelectionMeaning, + stockItemId: requirement.stockItem.stockItemRef.resourceId, + tenantId: candidate.ref.tenantId, + })); + yield* lockBindingCorrectionScopes(transaction, bindingRequirements).pipe( + Effect.mapError((cause) => unavailable(candidate.authorityEvidence.effectId, cause)), + ); + const [existingBeforeInsert] = yield* transaction + .select() + .from(inventoryCommitmentProtections) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + or( + eq(inventoryCommitmentProtections.protectionId, candidate.ref.resourceId), + and( + eq(inventoryCommitmentProtections.reservationId, candidate.confirmation.reservation.ref.resourceId), + eq(inventoryCommitmentProtections.attemptId, candidate.confirmation.reservation.origin.attemptId), + ), + eq(inventoryCommitmentProtections.confirmationId, candidate.confirmation.ref.resourceId), + eq(inventoryCommitmentProtections.authorityEffectId, candidate.authorityEvidence.effectId), + ), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(candidate.authorityEvidence.effectId, cause))); + if (existingBeforeInsert !== undefined) { + if ( + existingBeforeInsert.reservationId === candidate.confirmation.reservation.ref.resourceId && + existingBeforeInsert.attemptId === candidate.confirmation.reservation.origin.attemptId && + existingBeforeInsert.protectionId !== candidate.ref.resourceId + ) { + return yield* rejected(candidate.authorityEvidence.effectId, 'SIBLING_PROTECTION_FORBIDDEN'); + } + if ( + existingBeforeInsert.protectionId !== candidate.ref.resourceId || + existingBeforeInsert.confirmationId !== candidate.confirmation.ref.resourceId || + existingBeforeInsert.authorityEffectId !== candidate.authorityEvidence.effectId + ) { + return yield* rejected(candidate.authorityEvidence.effectId, 'PROTECTION_IDENTITY_CONFLICT'); + } + return { outcome: 'EXISTING' as const, protection: yield* decodeRow(existingBeforeInsert) }; + } + const bindingsRemainCurrent = yield* currentBindingRequirementsMatch(transaction, bindingRequirements).pipe( + Effect.mapError((cause) => unavailable(candidate.authorityEvidence.effectId, cause)), + ); + if (!bindingsRemainCurrent) { + return yield* rejected(candidate.authorityEvidence.effectId, 'CONFIRMATION_SCOPE_MISMATCH'); + } + const [inserted] = yield* transaction + .insert(inventoryCommitmentProtections) + .values(valuesFor(candidate)) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError((cause) => mapCommitmentProtectionWriteError(candidate.authorityEvidence.effectId, cause))); + if (inserted !== undefined) { + const persisted = yield* decodeRow(inserted); + yield* appendHistory(persisted); + return { outcome: 'INSERTED' as const, protection: persisted }; + } + const [reservationAttemptProtection] = yield* transaction + .select() + .from(inventoryCommitmentProtections) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + eq(inventoryCommitmentProtections.reservationId, candidate.confirmation.reservation.ref.resourceId), + eq(inventoryCommitmentProtections.attemptId, candidate.confirmation.reservation.origin.attemptId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(candidate.authorityEvidence.effectId, cause))); + if (reservationAttemptProtection !== undefined) { + if (reservationAttemptProtection.protectionId !== candidate.ref.resourceId) { + return yield* rejected(candidate.authorityEvidence.effectId, 'SIBLING_PROTECTION_FORBIDDEN'); + } + return { outcome: 'EXISTING' as const, protection: yield* decodeRow(reservationAttemptProtection) }; + } + const [identityCollision] = yield* transaction + .select() + .from(inventoryCommitmentProtections) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + or( + eq(inventoryCommitmentProtections.protectionId, candidate.ref.resourceId), + eq(inventoryCommitmentProtections.confirmationId, candidate.confirmation.ref.resourceId), + eq(inventoryCommitmentProtections.authorityEffectId, candidate.authorityEvidence.effectId), + ), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(candidate.authorityEvidence.effectId, cause))); + if (identityCollision === undefined) { + return yield* unavailable(candidate.authorityEvidence.effectId); + } + return yield* rejected(candidate.authorityEvidence.effectId, 'PROTECTION_IDENTITY_CONFLICT'); + }); + + const readHistory: CommitmentProtectionPersistence['readHistory'] = (ref) => + ref.tenantId === operationScope.tenantId + ? transaction + .select() + .from(inventoryCommitmentProtectionHistory) + .where( + and( + eq(inventoryCommitmentProtectionHistory.tenantId, operationScope.tenantId), + eq(inventoryCommitmentProtectionHistory.protectionId, ref.resourceId), + ), + ) + .orderBy(asc(inventoryCommitmentProtectionHistory.revision)) + .pipe( + Effect.mapError((cause) => unavailable(persistenceReadEffectId, cause)), + Effect.flatMap((rows) => decodeCommitmentProtectionHistoryRows(persistenceReadEffectId, rows)), + ) + : Effect.fail(unavailable(persistenceReadEffectId)); + + const saveRevision: CommitmentProtectionPersistence['saveRevision'] = Effect.fn( + 'CommitmentProtectionPersistence.saveRevision', + )(function* saveProtectionRevision({ current, next }) { + yield* requireCandidateTenant(current); + if (next.ref.tenantId !== operationScope.tenantId || !Schema.is(CommitmentProtectionSchema)(next)) { + return yield* rejected(current.authorityEvidence.effectId, 'INVALID_PROTECTION'); + } + const [row] = yield* transaction + .update(inventoryCommitmentProtections) + .set(valuesFor(next)) + .where( + and( + eq(inventoryCommitmentProtections.tenantId, operationScope.tenantId), + eq(inventoryCommitmentProtections.protectionId, current.ref.resourceId), + eq(inventoryCommitmentProtections.currentRevision, current.revision), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => mapCommitmentProtectionWriteError(current.authorityEvidence.effectId, cause))); + if (row === undefined) { + return yield* rejected(current.authorityEvidence.effectId, 'REVISION_CONFLICT'); + } + const persisted = yield* decodeRow(row); + yield* appendHistory(persisted); + return persisted; + }); + + return Object.freeze({ createOrRead, findByRef, findByReservationAttempt, readHistory, saveRevision }); +}; + +/** Atomically installs an exact Protection (when applicable) and terminalizes its durable ledger intent. */ +export const finalizeCommitmentProtectionForWorker = ( + scope: OutboxWorkerLegalEntityScope, + expected: InventoryEffectLedgerRecord, + effect: CommitmentProtectionEffect, +): Effect.Effect => { + if (!Schema.is(CommitmentProtectionEffectSchema)(effect)) { + return Effect.fail(rejected(persistenceReadEffectId, 'INVALID_PROTECTION')); + } + if ( + expected.tenantId !== scope.tenantId || + effect.request.confirmation.ref.tenantId !== scope.tenantId || + effect.request.protectionRef.tenantId !== scope.tenantId || + effect.request.legalEntityId !== scope.legalEntityId + ) { + return Effect.fail(rejected(effect.request.effectId, 'TENANT_SCOPE_MISMATCH')); + } + if ( + !Schema.is(CommitmentProtectionInventoryEffectLedgerIntentSchema)(expected.intent) || + String(expected.effectId) !== String(effect.request.effectId) || + !sameCommitmentProtectionRequest(expected.intent.request, effect.request) + ) { + return Effect.fail(rejected(effect.request.effectId, 'PROTECTION_IDENTITY_CONFLICT')); + } + return scope.routineInvoker + .invoke(finalizeCommitmentProtectionForWorkerRoutine, [ + expected.effectId, + expected.revision, + expected.currentState, + effect, + ]) + .pipe( + Effect.mapError((cause) => mapCommitmentProtectionWriteError(effect.request.effectId, cause)), + Effect.flatMap(([row]) => + row === undefined ? Effect.fail(unavailable(effect.request.effectId)) : Effect.succeed(row.record), + ), + ); +}; diff --git a/app/verticals/inventory/src/persistence/commitment-protection-table.ts b/app/verticals/inventory/src/persistence/commitment-protection-table.ts new file mode 100644 index 000000000..8f94f6086 --- /dev/null +++ b/app/verticals/inventory/src/persistence/commitment-protection-table.ts @@ -0,0 +1,154 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { CommitmentProtection } from '../../shared/domain/commitment-protection.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryObligations } from './inventory-obligation-table.ts'; +import { inventoryReservationConfirmations } from './reservation-confirmation-table.ts'; + +export const inventoryCommitmentProtections = inventorySchema.table.withRLS( + 'commitment_protections', + { + protectionId: uuid('protection_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + confirmationId: uuid('confirmation_id').notNull(), + reservationId: uuid('reservation_id').notNull(), + attemptId: text('attempt_id').notNull(), + ownerConfigurationId: uuid('owner_configuration_id').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + authorityEffectId: text('authority_effect_id').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + establishedAt: timestamp('established_at', { withTimezone: true }).notNull(), + currentHealthState: text('current_health_state').default('PROTECTED').notNull(), + currentRevision: integer('current_revision').default(1).notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_commitment_protections_scope_id_uk').on(table.tenantId, table.protectionId), + uniqueIndex('inventory_commitment_protections_reservation_attempt_uk').on( + table.tenantId, + table.reservationId, + table.attemptId, + ), + uniqueIndex('inventory_commitment_protections_confirmation_uk').on(table.tenantId, table.confirmationId), + uniqueIndex('inventory_commitment_protections_authority_effect_uk').on(table.tenantId, table.authorityEffectId), + index('inventory_commitment_protections_health_idx').on( + table.tenantId, + table.currentHealthState, + table.establishedAt, + ), + foreignKey({ + columns: [table.tenantId, table.confirmationId], + foreignColumns: [inventoryReservationConfirmations.tenantId, inventoryReservationConfirmations.confirmationId], + name: 'inventory_commitment_protections_confirmation_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.reservationId], + foreignColumns: [inventoryObligations.tenantId, inventoryObligations.obligationId], + name: 'inventory_commitment_protections_reservation_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.ownerConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_commitment_protections_backend_configuration_fk', + }).onDelete('restrict'), + check( + 'inventory_commitment_protections_meaning_ck', + sql`char_length(btrim(${table.attemptId})) between 1 and 300 and char_length(btrim(${table.issuerBackendId})) between 1 and 300 and char_length(btrim(${table.authorityEffectId})) between 1 and 300 and char_length(btrim(${table.ownerEvidenceRef})) between 1 and 300 and ${table.issuerBackendKind} in ('external_business_system', 'ontos_wms')`, + ), + check( + 'inventory_commitment_protections_health_ck', + sql`${table.currentHealthState} in ('PROTECTED', 'AT_RISK') and ${table.currentRevision} >= 1`, + ), + ...tenantRlsPolicies('inventory_commitment_protections_tenant', table.tenantId), + ], +); + +export const inventoryCommitmentProtectionHistory = inventorySchema.table.withRLS( + 'commitment_protection_history', + { + historyId: uuid('history_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + protectionId: uuid('protection_id').notNull(), + revision: integer('revision').notNull(), + healthState: text('health_state').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + transitionedAt: timestamp('transitioned_at', { withTimezone: true }).notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_commitment_protection_history_scope_id_uk').on(table.tenantId, table.historyId), + uniqueIndex('inventory_commitment_protection_history_revision_uk').on( + table.tenantId, + table.protectionId, + table.revision, + ), + foreignKey({ + columns: [table.tenantId, table.protectionId], + foreignColumns: [inventoryCommitmentProtections.tenantId, inventoryCommitmentProtections.protectionId], + name: 'inventory_commitment_protection_history_protection_fk', + }).onDelete('restrict'), + check( + 'inventory_commitment_protection_history_health_ck', + sql`${table.healthState} in ('PROTECTED', 'AT_RISK') and ${table.revision} >= 1`, + ), + ...tenantRlsPolicies('inventory_commitment_protection_history_tenant', table.tenantId), + ], +); + +export const inventoryCommitmentProtectionScopeContract = { + constraintNames: { + authority: 'inventory_commitment_protections_exact_authority_ck', + confirmation: 'inventory_commitment_protections_exact_confirmation_ck', + reservation: 'inventory_commitment_protections_exact_reservation_ck', + snapshot: 'inventory_commitment_protections_snapshot_ck', + }, + event: 'INSERT OR UPDATE', + functionName: 'inventory.enforce_commitment_protection_scope', + table: 'inventory.commitment_protections', + timing: 'BEFORE', + triggerName: 'inventory_commitment_protections_scope_trg', +} as const; + +export const inventoryCommitmentProtectionLifecycleContract = { + allowedTransitions: ['PROTECTED -> AT_RISK', 'AT_RISK -> AT_RISK'], + immutableColumns: [ + 'protection_id', + 'tenant_id', + 'confirmation_id', + 'reservation_id', + 'attempt_id', + 'owner_configuration_id', + 'issuer_backend_kind', + 'issuer_backend_id', + 'authority_effect_id', + 'owner_evidence_ref', + 'established_at', + 'created_at', + ], + monotonicRevision: true, + releaseAllowed: false, + event: 'UPDATE OR DELETE', + functionName: 'inventory.enforce_commitment_protection_lifecycle', + table: 'inventory.commitment_protections', + timing: 'BEFORE', + triggerName: 'inventory_commitment_protections_lifecycle_trg', +} as const; + +export const inventoryCommitmentProtectionHistoryImmutabilityContract = { + deleteTriggerName: 'inventory_commitment_protection_history_no_delete_trg', + functionName: 'inventory.reject_commitment_protection_history_mutation', + table: 'inventory.commitment_protection_history', + updateTriggerName: 'inventory_commitment_protection_history_no_update_trg', +} as const; + +export const INVENTORY_COMMITMENT_PROTECTION_TABLES = [ + inventoryCommitmentProtectionHistory, + inventoryCommitmentProtections, +] as const; diff --git a/app/verticals/inventory/src/persistence/current-stock-evidence-for-availability-repository.ts b/app/verticals/inventory/src/persistence/current-stock-evidence-for-availability-repository.ts new file mode 100644 index 000000000..64819f24b --- /dev/null +++ b/app/verticals/inventory/src/persistence/current-stock-evidence-for-availability-repository.ts @@ -0,0 +1,348 @@ +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq, isNull, ne, or } from 'drizzle-orm'; +import { Effect, Option, Schema } from 'effect'; + +import { CurrentStockEvidenceForAvailabilityUnavailable } from '../../shared/domain/current-stock-evidence-for-availability.ts'; +import type { ReservationCreateEffectForAvailability } from '../../shared/domain/current-stock-evidence-for-availability.ts'; +import { + IndeterminateReservationCreateEffectSchema, + ReconciliationRequiredReservationCreateEffectSchema, + RequestedReservationCreateEffectSchema, +} from '../../shared/domain/inventory-reservation-create.ts'; +import { compareInventorySourceOrdering } from '../../shared/domain/inventory-source-ordering.ts'; +import { InventorySourceAssertionIdSchema } from '../../shared/domain/inventory-source-assertion.ts'; +import { PhysicalStockEffectIdSchema } from '../../shared/domain/physical-stock-effect.ts'; +import { CurrentSuccessfulAllocationQuantitySchema } from '../../shared/domain/stock-position.ts'; +import { ImportedCommittedObligationRefSchema } from '../../shared/resources/imported-committed-obligation.ts'; +import { InventoryReservationRefSchema } from '../../shared/resources/inventory-reservation.ts'; +import type { StockPositionRef } from '../../shared/resources/stock-position.ts'; +import type { CurrentStockEvidenceForAvailabilityDependencies } from '../services/current-stock-evidence-for-availability.service.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this adapter only inside the governed transaction-scoped Read factory; expires: 2027-03-31. +import { makeDrizzleCatalogToStockBindingPersistence } from './catalog-to-stock-binding-repository.ts'; +import { inventoryBackendConfigurationPersistenceForScope } from './inventory-backend-configuration-repository.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryObligationPersistenceForScope } from './inventory-obligation-repository.ts'; +import { inventoryObligationAllocations, inventoryObligations } from './inventory-obligation-table.ts'; +import { inventorySourceAssertionPersistenceForScope } from './inventory-source-assertion-repository.ts'; +import { inventorySourceImportLedger } from './inventory-source-import-ledger-table.ts'; +import { physicalStockEffectPersistenceForScope } from './physical-stock-effect-repository.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; +import { listUnresolvedReservationCreateEffects } from './reservation-create-effect-repository.ts'; +import { inventoryReservationReleaseEffects } from './reservation-release-effect-table.ts'; +// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Core invokes this adapter only inside the governed transaction-scoped Read factory; expires: 2027-03-31. +import { makeDrizzleStockItemRepository } from './stock-item-repository.ts'; +import { stockLocationPersistenceForScope } from './stock-location-repository.ts'; +import { stockPositionPersistenceForScope } from './stock-position-repository.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const unavailable = (cause: Cause) => { + const failure = new CurrentStockEvidenceForAvailabilityUnavailable({ + code: 'current_stock_evidence_for_availability_unavailable', + reason: 'Current Stock evidence for Availability is temporarily unavailable', + retryable: true, + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +const mapUnavailable = ( + effect: Effect.Effect, +): Effect.Effect => + effect.pipe(Effect.mapError((cause) => unavailable(cause))); + +const requireTenant = ( + scope: OperationalScope, + positionRef: StockPositionRef, +): Effect.Effect => + positionRef.tenantId === scope.tenantId + ? Effect.void + : Effect.fail(unavailable('Stock Position Tenant does not match the trusted operation scope')); + +const storedNumericPattern = /^(?[0-9]+)(?:\.(?[0-9]+))?$/u; +const canonicalAmount = (amount: string): string => { + const groups = storedNumericPattern.exec(amount)?.groups; + if (groups?.['integer'] === undefined) { + return amount; + } + const integer = BigInt(groups['integer']).toString(); + const fraction = (groups['fraction'] ?? '').replace(/0+$/u, ''); + return fraction.length === 0 ? integer : `${integer}.${fraction}`; +}; + +export const currentStockEvidenceForAvailabilityDependenciesForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): CurrentStockEvidenceForAvailabilityDependencies => { + const authorities = inventoryBackendConfigurationPersistenceForScope(transaction, scope); + const bindings = makeDrizzleCatalogToStockBindingPersistence(transaction); + const stockItems = makeDrizzleStockItemRepository(transaction); + const stockLocations = stockLocationPersistenceForScope(transaction, scope); + const positions = stockPositionPersistenceForScope(transaction, scope); + const obligations = inventoryObligationPersistenceForScope(transaction, scope); + const sourceAssertions = inventorySourceAssertionPersistenceForScope(transaction, scope); + const physicalEffects = physicalStockEffectPersistenceForScope(transaction, scope); + + const readCommittedObligation = Effect.fn('CurrentStockEvidenceForAvailabilityPersistence.readCommittedObligation')( + function* readCommitted(row: { readonly obligationId: string; readonly originKind: string }) { + if (row.originKind === 'IMPORTED_PROVEN_ORDER') { + const ref = yield* Schema.decodeEffect(ImportedCommittedObligationRefSchema)({ + moduleId: 'commerce.inventory', + resourceId: row.obligationId, + resourceType: 'commerce.inventory.imported-committed-obligation', + tenantId: scope.tenantId, + }).pipe(Effect.mapError(unavailable)); + const obligation = yield* mapUnavailable(obligations.read(ref)); + return yield* Effect.fromOption(obligation).pipe( + Effect.mapError((cause) => + unavailable({ cause, reason: `Committed obligation ${row.obligationId} was not found` }), + ), + ); + } + const ref = yield* Schema.decodeEffect(InventoryReservationRefSchema)({ + moduleId: 'commerce.inventory', + resourceId: row.obligationId, + resourceType: 'commerce.inventory.inventory-reservation', + tenantId: scope.tenantId, + }).pipe(Effect.mapError(unavailable)); + const obligation = yield* mapUnavailable(obligations.read(ref)); + return yield* Effect.fromOption(obligation).pipe( + Effect.mapError((cause) => + unavailable({ cause, reason: `Committed obligation ${row.obligationId} was not found` }), + ), + ); + }, + ); + + const listCommittedObligations: CurrentStockEvidenceForAvailabilityDependencies['listCommittedObligations'] = + Effect.fn('CurrentStockEvidenceForAvailabilityPersistence.listCommittedObligations')( + function* listCommitted(positionRef) { + yield* requireTenant(scope, positionRef); + const rows = yield* transaction + .select({ + obligationId: inventoryObligations.obligationId, + originKind: inventoryObligations.originKind, + }) + .from(inventoryObligations) + .innerJoin( + inventoryObligationAllocations, + and( + eq(inventoryObligationAllocations.tenantId, inventoryObligations.tenantId), + eq(inventoryObligationAllocations.obligationId, inventoryObligations.obligationId), + ), + ) + .where( + and( + eq(inventoryObligations.tenantId, scope.tenantId), + eq(inventoryObligations.lifecycleMeaning, 'COMMITTED_OBLIGATION'), + eq(inventoryObligationAllocations.stockPositionId, positionRef.resourceId), + ), + ) + .orderBy(asc(inventoryObligations.obligationId)) + .pipe(Effect.mapError(unavailable)); + const distinctRows = [ + ...new Map(rows.map((row) => [`${row.originKind}:${row.obligationId}`, row] as const)).values(), + ]; + return yield* Effect.forEach(distinctRows, readCommittedObligation, { concurrency: 1 }); + }, + ); + + const listCurrentSuccessfulAllocations: CurrentStockEvidenceForAvailabilityDependencies['listCurrentSuccessfulAllocations'] = + Effect.fn('CurrentStockEvidenceForAvailabilityPersistence.listCurrentSuccessfulAllocations')( + function* listCurrentAllocations(positionRef) { + yield* requireTenant(scope, positionRef); + const rows = yield* transaction + .select({ + allocationId: inventoryObligationAllocations.allocationId, + amount: inventoryObligationAllocations.allocatedAmount, + unitResourceId: inventoryObligationAllocations.unitResourceId, + }) + .from(inventoryObligationAllocations) + .innerJoin( + inventoryObligations, + and( + eq(inventoryObligations.tenantId, inventoryObligationAllocations.tenantId), + eq(inventoryObligations.obligationId, inventoryObligationAllocations.obligationId), + ), + ) + .leftJoin( + inventoryReservationReleaseEffects, + and( + eq(inventoryReservationReleaseEffects.tenantId, inventoryObligations.tenantId), + eq(inventoryReservationReleaseEffects.reservationId, inventoryObligations.obligationId), + ), + ) + .where( + and( + eq(inventoryObligationAllocations.tenantId, scope.tenantId), + eq(inventoryObligationAllocations.stockPositionId, positionRef.resourceId), + eq(inventoryObligations.lifecycleMeaning, 'PROVISIONAL_RESERVATION'), + or( + isNull(inventoryReservationReleaseEffects.currentState), + ne(inventoryReservationReleaseEffects.currentState, 'RELEASED'), + ), + ), + ) + .orderBy(asc(inventoryObligationAllocations.allocationId)) + .pipe(Effect.mapError(unavailable)); + return yield* Schema.decodeEffect(Schema.Array(CurrentSuccessfulAllocationQuantitySchema))( + rows.map((row) => ({ + allocationId: row.allocationId, + positionRef, + quantity: { + amount: canonicalAmount(row.amount), + unitRef: { + moduleId: 'commerce.catalog', + resourceId: row.unitResourceId, + resourceType: 'commerce.catalog.product-unit', + tenantId: scope.tenantId, + }, + }, + status: 'CURRENT_SUCCESSFUL', + })), + ).pipe(Effect.mapError(unavailable)); + }, + ); + + const listMaterialEffects: CurrentStockEvidenceForAvailabilityDependencies['listMaterialEffects'] = Effect.fn( + 'CurrentStockEvidenceForAvailabilityPersistence.listMaterialEffects', + )(function* listMaterialPhysicalEffects(positionRef) { + yield* requireTenant(scope, positionRef); + const rows = yield* transaction + .select({ effectId: inventoryPhysicalStockEffects.effectId }) + .from(inventoryPhysicalStockEffects) + .where( + and( + eq(inventoryPhysicalStockEffects.tenantId, scope.tenantId), + eq(inventoryPhysicalStockEffects.positionId, positionRef.resourceId), + eq(inventoryPhysicalStockEffects.state, 'APPLIED'), + ), + ) + .orderBy(asc(inventoryPhysicalStockEffects.requestedAt), asc(inventoryPhysicalStockEffects.effectId)) + .pipe(Effect.mapError(unavailable)); + return yield* Effect.forEach( + rows, + ({ effectId }) => + Schema.decodeEffect(PhysicalStockEffectIdSchema)(effectId).pipe( + Effect.mapError(unavailable), + Effect.flatMap((id) => mapUnavailable(physicalEffects.read(id))), + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(unavailable(`Physical Stock effect ${effectId} was not found`)), + onSome: Effect.succeed, + }), + ), + ), + { concurrency: 1 }, + ); + }); + + const readLatestSourceAssertion: CurrentStockEvidenceForAvailabilityDependencies['readLatestSourceAssertion'] = + Effect.fn('CurrentStockEvidenceForAvailabilityPersistence.readLatestSourceAssertion')( + function* readLatestAcceptedAssertion(positionRef) { + yield* requireTenant(scope, positionRef); + const accepted = yield* transaction + .select({ + assertionId: inventorySourceImportLedger.assertionId, + orderingEvidence: inventorySourceImportLedger.proposalJson, + }) + .from(inventorySourceImportLedger) + .innerJoin( + inventoryStockPositions, + and( + eq(inventoryStockPositions.tenantId, inventorySourceImportLedger.tenantId), + eq(inventoryStockPositions.stockPositionId, inventorySourceImportLedger.positionId), + ), + ) + .innerJoin( + inventoryBackendConfigurations, + and( + eq(inventoryBackendConfigurations.tenantId, inventoryStockPositions.tenantId), + eq(inventoryBackendConfigurations.configurationId, inventoryStockPositions.ownerConfigurationId), + ), + ) + .where( + and( + eq(inventorySourceImportLedger.tenantId, scope.tenantId), + eq(inventorySourceImportLedger.positionId, positionRef.resourceId), + eq(inventorySourceImportLedger.status, 'ACCEPTED'), + eq(inventorySourceImportLedger.customerConfigurationId, inventoryStockPositions.customerConfigurationId), + eq(inventorySourceImportLedger.issuerBackendKind, inventoryBackendConfigurations.backendKind), + eq(inventorySourceImportLedger.issuerBackendId, inventoryBackendConfigurations.backendId), + eq(inventorySourceImportLedger.factMeaning, 'ABSOLUTE_PHYSICAL_ON_HAND'), + ), + ) + .pipe(Effect.mapError(unavailable)); + const [head, ...candidates] = accepted; + if (head === undefined) { + return Option.none(); + } + let latest = head; + for (const candidate of candidates) { + if ( + compareInventorySourceOrdering( + candidate.orderingEvidence.orderingEvidence, + latest.orderingEvidence.orderingEvidence, + ) === 'NEWER' + ) { + latest = candidate; + } + } + const assertionId = yield* Schema.decodeEffect(InventorySourceAssertionIdSchema)(latest.assertionId).pipe( + Effect.mapError(unavailable), + ); + const assertion = yield* mapUnavailable(sourceAssertions.findById(assertionId)); + return yield* Option.match(assertion, { + onNone: () => Effect.fail(unavailable(`Accepted source assertion ${latest.assertionId} was not found`)), + onSome: Effect.succeedSome, + }); + }, + ); + + const findAuthority: CurrentStockEvidenceForAvailabilityDependencies['findAuthority'] = (customerConfigurationId) => + mapUnavailable(authorities.findCurrent(customerConfigurationId)); + + const findBinding: CurrentStockEvidenceForAvailabilityDependencies['findBinding'] = (position) => + requireTenant(scope, position.ref).pipe( + Effect.flatMap(() => mapUnavailable(bindings.findCurrentByStockItem(position.scope.stockItemRef))), + ); + + const findStockItem: CurrentStockEvidenceForAvailabilityDependencies['findStockItem'] = (position) => + requireTenant(scope, position.ref).pipe( + Effect.flatMap(() => mapUnavailable(stockItems.findById(scope.tenantId, position.scope.stockItemRef.resourceId))), + ); + + const findStockLocation: CurrentStockEvidenceForAvailabilityDependencies['findStockLocation'] = (position) => + requireTenant(scope, position.ref).pipe( + Effect.flatMap(() => mapUnavailable(stockLocations.read(position.scope.stockLocationRef))), + ); + + const readPosition: CurrentStockEvidenceForAvailabilityDependencies['readPosition'] = (positionRef) => + requireTenant(scope, positionRef).pipe(Effect.flatMap(() => mapUnavailable(positions.read(positionRef)))); + + const unresolvedCreateEffects: CurrentStockEvidenceForAvailabilityDependencies['unresolvedCreateEffects'] = + mapUnavailable(listUnresolvedReservationCreateEffects(transaction, scope)).pipe( + Effect.map((effects) => + effects.filter( + (effect): effect is ReservationCreateEffectForAvailability => + Schema.is(RequestedReservationCreateEffectSchema)(effect) || + Schema.is(ReconciliationRequiredReservationCreateEffectSchema)(effect) || + Schema.is(IndeterminateReservationCreateEffectSchema)(effect), + ), + ), + ); + + return Object.freeze({ + findAuthority, + findBinding, + findStockItem, + findStockLocation, + listCommittedObligations, + listCurrentSuccessfulAllocations, + listMaterialEffects, + readLatestSourceAssertion, + readPosition, + unresolvedCreateEffects, + }); +}; diff --git a/app/verticals/inventory/src/persistence/external-stock-correlation-repository.ts b/app/verticals/inventory/src/persistence/external-stock-correlation-repository.ts new file mode 100644 index 000000000..9762e0160 --- /dev/null +++ b/app/verticals/inventory/src/persistence/external-stock-correlation-repository.ts @@ -0,0 +1,297 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq, gt, isNull, lte, or } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + ExternalStockCorrelationSchema, + ExternalStockItemTargetSchema, + ExternalStockLocationTargetSchema, +} from '../../shared/domain/external-stock-correlation.ts'; +import type { + ExternalStockCorrelation, + ExternalStockCorrelationPersistence, + ExternalStockCorrelationPersistenceError, + ExternalStockKey, +} from '../../shared/domain/external-stock-correlation.ts'; +import { ExternalStockCorrelationPersistenceUnavailable } from '../../shared/domain/external-stock-correlation-persistence-unavailable.ts'; +import { ExternalStockCorrelationRejected } from '../../shared/domain/external-stock-correlation-rejected.ts'; +import type { ExternalStockCorrelationRef } from '../../shared/resources/external-stock-correlation.ts'; +import { inventoryExternalStockCorrelations } from './external-stock-correlation-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type CorrelationRow = typeof inventoryExternalStockCorrelations.$inferSelect; +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; + +const unavailable = (cause?: unknown) => { + const failure = new ExternalStockCorrelationPersistenceUnavailable({ + code: 'external_stock_correlation_persistence_unavailable', + reason: 'External Stock Correlation persistence is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const reject = (reason: ExternalStockCorrelationRejected['reason'], correlationRef?: ExternalStockCorrelationRef) => + correlationRef === undefined + ? new ExternalStockCorrelationRejected({ code: 'external_stock_correlation_rejected', reason }) + : new ExternalStockCorrelationRejected({ + code: 'external_stock_correlation_rejected', + correlationRef, + reason, + }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); +const exclusionViolationSqlState = ['23', 'P01'].join(''); +const overlapConstraint = 'inventory_external_stock_correlations_current_key_uk'; + +export const mapExternalStockCorrelationWriteError = (cause: unknown): ExternalStockCorrelationPersistenceError => { + const targetMissing = findPostgresFailure( + cause, + ({ code, constraint }) => + code === foreignKeyViolationSqlState && + ['inventory_external_stock_correlations_item_fk', 'inventory_external_stock_correlations_location_fk'].includes( + constraint ?? '', + ), + ); + if (Option.isSome(targetMissing)) { + return reject('TARGET_NOT_FOUND'); + } + const overlap = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === uniqueViolationSqlState && constraint === overlapConstraint) || + (code === exclusionViolationSqlState && + constraint === 'inventory_external_stock_correlations_effective_period_excl'), + ); + if (Option.isSome(overlap)) { + return reject('OVERLAPPING_EFFECTIVE_PERIOD'); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + ['external_stock_correlations_pkey', 'inventory_external_stock_correlations_scope_id_uk'].includes( + constraint ?? '', + ), + ); + return Option.isSome(identity) ? reject('CORRELATION_IDENTITY_CONFLICT') : unavailable(cause); +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const correlationRefFor = (row: CorrelationRow) => ({ + moduleId: INVENTORY_MODULE_ID, + resourceId: row.correlationId, + resourceType: 'commerce.inventory.external-stock-correlation' as const, + tenantId: row.tenantId, +}); + +const targetFor = (row: CorrelationRow) => + row.identifierKind === 'ITEM' + ? { + _tag: 'STOCK_ITEM' as const, + ref: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockItemId ?? '', + resourceType: 'commerce.inventory.stock-item' as const, + tenantId: row.tenantId, + }, + } + : { + _tag: 'STOCK_LOCATION' as const, + ref: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockLocationId ?? '', + resourceType: 'commerce.inventory.stock-location' as const, + tenantId: row.tenantId, + }, + }; + +const decodeRow = (row: CorrelationRow) => + Schema.decodeUnknownEffect(ExternalStockCorrelationSchema)({ + confirmedAt: row.confirmedAt.toISOString(), + correlationRef: correlationRefFor(row), + effectivePeriod: { + from: row.effectiveFrom.toISOString(), + to: row.effectiveTo?.toISOString() ?? null, + }, + externalKey: { + customerConfigurationId: row.customerConfigurationId, + externalScope: row.externalScope, + externalValue: row.externalValue, + identifierKind: row.identifierKind, + issuer: { backendId: row.issuerBackendId, backendKind: row.issuerBackendKind }, + namespace: row.namespace, + tenantId: row.tenantId, + }, + lifecycle: row.lifecycleState, + ownerEvidenceRef: row.ownerEvidenceRef, + revision: row.revision, + target: targetFor(row), + }).pipe(Effect.mapError(unavailable)); + +const insertValues = (correlation: ExternalStockCorrelation) => ({ + confirmedAt: instantAsDate(correlation.confirmedAt), + correlationId: correlation.correlationRef.resourceId, + customerConfigurationId: correlation.externalKey.customerConfigurationId, + effectiveFrom: instantAsDate(correlation.effectivePeriod.from), + effectiveTo: correlation.effectivePeriod.to === null ? null : instantAsDate(correlation.effectivePeriod.to), + externalScope: correlation.externalKey.externalScope, + externalValue: correlation.externalKey.externalValue, + identifierKind: correlation.externalKey.identifierKind, + issuerBackendId: correlation.externalKey.issuer.backendId, + issuerBackendKind: correlation.externalKey.issuer.backendKind, + lifecycleState: correlation.lifecycle, + namespace: correlation.externalKey.namespace, + ownerEvidenceRef: correlation.ownerEvidenceRef, + revision: correlation.revision, + stockItemId: Schema.is(ExternalStockItemTargetSchema)(correlation.target) ? correlation.target.ref.resourceId : null, + stockLocationId: Schema.is(ExternalStockLocationTargetSchema)(correlation.target) + ? correlation.target.ref.resourceId + : null, + tenantId: correlation.correlationRef.tenantId, +}); + +const exactKeyPredicate = (externalKey: ExternalStockKey) => + and( + eq(inventoryExternalStockCorrelations.tenantId, externalKey.tenantId), + eq(inventoryExternalStockCorrelations.customerConfigurationId, externalKey.customerConfigurationId), + eq(inventoryExternalStockCorrelations.issuerBackendKind, externalKey.issuer.backendKind), + eq(inventoryExternalStockCorrelations.issuerBackendId, externalKey.issuer.backendId), + eq(inventoryExternalStockCorrelations.namespace, externalKey.namespace), + eq(inventoryExternalStockCorrelations.externalScope, externalKey.externalScope), + eq(inventoryExternalStockCorrelations.identifierKind, externalKey.identifierKind), + eq(inventoryExternalStockCorrelations.externalValue, externalKey.externalValue), + ); + +export const externalStockCorrelationPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): ExternalStockCorrelationPersistence => { + const requireTenant = (tenantId: string, correlationRef?: ExternalStockCorrelationRef) => + tenantId === scope.tenantId ? Effect.void : Effect.fail(reject('TENANT_SCOPE_MISMATCH', correlationRef)); + + const findByRef: ExternalStockCorrelationPersistence['findByRef'] = Effect.fn( + 'ExternalStockCorrelationPersistence.findByRef', + )(function* findCorrelationByRef(correlationRef) { + yield* requireTenant(correlationRef.tenantId, correlationRef); + const [row] = yield* transaction + .select() + .from(inventoryExternalStockCorrelations) + .where( + and( + eq(inventoryExternalStockCorrelations.tenantId, scope.tenantId), + eq(inventoryExternalStockCorrelations.correlationId, correlationRef.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }); + + const findEffective: ExternalStockCorrelationPersistence['findEffective'] = Effect.fn( + 'ExternalStockCorrelationPersistence.findEffective', + )(function* findEffectiveCorrelation(externalKey, asOf) { + yield* requireTenant(externalKey.tenantId); + const instant = instantAsDate(asOf); + const rows = yield* transaction + .select() + .from(inventoryExternalStockCorrelations) + .where( + and( + exactKeyPredicate(externalKey), + lte(inventoryExternalStockCorrelations.effectiveFrom, instant), + or( + isNull(inventoryExternalStockCorrelations.effectiveTo), + gt(inventoryExternalStockCorrelations.effectiveTo, instant), + ), + ), + ) + .pipe(Effect.mapError(unavailable)); + return yield* Effect.forEach(rows, decodeRow, { concurrency: 1 }); + }); + + const insertCurrent: ExternalStockCorrelationPersistence['insertCurrent'] = Effect.fn( + 'ExternalStockCorrelationPersistence.insertCurrent', + )(function* insertCurrentCorrelation(correlation) { + yield* requireTenant(correlation.correlationRef.tenantId, correlation.correlationRef); + const [row] = yield* transaction + .insert(inventoryExternalStockCorrelations) + .values(insertValues(correlation)) + .returning() + .pipe(Effect.mapError(mapExternalStockCorrelationWriteError)); + return row === undefined + ? yield* unavailable('External Stock Correlation insert returned no row') + : yield* decodeRow(row); + }); + + const endRow = Effect.fn('ExternalStockCorrelationPersistence.endRow')(function* endCorrelationRow( + current: ExternalStockCorrelation, + endedAt: string, + ) { + yield* requireTenant(current.correlationRef.tenantId, current.correlationRef); + const [row] = yield* transaction + .update(inventoryExternalStockCorrelations) + .set({ + effectiveTo: instantAsDate(endedAt), + lifecycleState: 'ENDED', + revision: current.revision + 1, + }) + .where( + and( + eq(inventoryExternalStockCorrelations.tenantId, scope.tenantId), + eq(inventoryExternalStockCorrelations.correlationId, current.correlationRef.resourceId), + eq(inventoryExternalStockCorrelations.revision, current.revision), + eq(inventoryExternalStockCorrelations.lifecycleState, 'CURRENT'), + isNull(inventoryExternalStockCorrelations.effectiveTo), + ), + ) + .returning() + .pipe(Effect.mapError(mapExternalStockCorrelationWriteError)); + return row === undefined + ? yield* reject('CORRELATION_REVISION_CONFLICT', current.correlationRef) + : yield* decodeRow(row); + }); + + const endCurrent: ExternalStockCorrelationPersistence['endCurrent'] = ({ current, endedAt }) => + endRow(current, endedAt); + + const replaceCurrent: ExternalStockCorrelationPersistence['replaceCurrent'] = Effect.fn( + 'ExternalStockCorrelationPersistence.replaceCurrent', + )(function* replaceCurrentCorrelation({ current, endedAt, replacement }) { + yield* endRow(current, endedAt); + return yield* insertCurrent(replacement); + }); + + const saveConfirmation: ExternalStockCorrelationPersistence['saveConfirmation'] = Effect.fn( + 'ExternalStockCorrelationPersistence.saveConfirmation', + )(function* saveCorrelationConfirmation({ expectedRevision, next }) { + yield* requireTenant(next.correlationRef.tenantId, next.correlationRef); + const [row] = yield* transaction + .update(inventoryExternalStockCorrelations) + .set({ + confirmedAt: instantAsDate(next.confirmedAt), + ownerEvidenceRef: next.ownerEvidenceRef, + revision: next.revision, + }) + .where( + and( + eq(inventoryExternalStockCorrelations.tenantId, scope.tenantId), + eq(inventoryExternalStockCorrelations.correlationId, next.correlationRef.resourceId), + eq(inventoryExternalStockCorrelations.revision, expectedRevision), + eq(inventoryExternalStockCorrelations.lifecycleState, 'CURRENT'), + ), + ) + .returning() + .pipe(Effect.mapError(mapExternalStockCorrelationWriteError)); + return row === undefined + ? yield* reject('CORRELATION_REVISION_CONFLICT', next.correlationRef) + : yield* decodeRow(row); + }); + + return Object.freeze({ endCurrent, findByRef, findEffective, insertCurrent, replaceCurrent, saveConfirmation }); +}; diff --git a/app/verticals/inventory/src/persistence/external-stock-correlation-table.ts b/app/verticals/inventory/src/persistence/external-stock-correlation-table.ts new file mode 100644 index 000000000..fd4d0e4ea --- /dev/null +++ b/app/verticals/inventory/src/persistence/external-stock-correlation-table.ts @@ -0,0 +1,112 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; +import { inventoryStockLocations } from './stock-location-table.ts'; + +export const inventoryExternalStockCorrelationImmutabilityContract = { + columns: [ + 'correlation_id', + 'tenant_id', + 'customer_configuration_id', + 'issuer_backend_kind', + 'issuer_backend_id', + 'namespace', + 'external_scope', + 'identifier_kind', + 'external_value', + 'stock_item_id', + 'stock_location_id', + 'effective_from', + ], + comparison: 'IS DISTINCT FROM', + deleteTriggerName: 'inventory_external_stock_correlations_no_delete_trg', + errorCondition: 'check_violation', + functionName: 'inventory.reject_external_stock_correlation_identity_mutation', + table: 'inventory.external_stock_correlations', + timing: 'BEFORE', + updateTriggerName: 'inventory_external_stock_correlations_immutable_identity_trg', +} as const; + +/** Migration hardening rejects every overlapping half-open period for one exact external key. */ +export const inventoryExternalStockCorrelationNonoverlapContract = { + errorCondition: 'exclusion_violation', + event: 'INSERT OR UPDATE', + functionName: 'inventory.enforce_external_stock_correlation_nonoverlap', + period: '[effective_from, effective_to)', + table: 'inventory.external_stock_correlations', + triggerName: 'inventory_external_stock_correlations_nonoverlap_trg', +} as const; + +export const inventoryExternalStockCorrelations = inventorySchema.table.withRLS( + 'external_stock_correlations', + { + correlationId: uuid('correlation_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + namespace: text('namespace').notNull(), + externalScope: text('external_scope').notNull(), + identifierKind: text('identifier_kind').notNull(), + externalValue: text('external_value').notNull(), + stockItemId: uuid('stock_item_id'), + stockLocationId: uuid('stock_location_id'), + lifecycleState: text('lifecycle_state').default('CURRENT').notNull(), + effectiveFrom: timestamp('effective_from', { withTimezone: true }).notNull(), + effectiveTo: timestamp('effective_to', { withTimezone: true }), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + confirmedAt: timestamp('confirmed_at', { withTimezone: true }).notNull(), + revision: integer('revision').default(1).notNull(), + }, + (table) => [ + uniqueIndex('inventory_external_stock_correlations_scope_id_uk').on(table.tenantId, table.correlationId), + uniqueIndex('inventory_external_stock_correlations_current_key_uk') + .on( + table.tenantId, + table.customerConfigurationId, + table.issuerBackendKind, + table.issuerBackendId, + table.namespace, + table.externalScope, + table.identifierKind, + table.externalValue, + ) + .where(sql`${table.lifecycleState} = 'CURRENT' and ${table.effectiveTo} is null`), + index('inventory_external_stock_correlations_item_idx').on(table.tenantId, table.stockItemId), + index('inventory_external_stock_correlations_location_idx').on(table.tenantId, table.stockLocationId), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_external_stock_correlations_item_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockLocationId], + foreignColumns: [inventoryStockLocations.tenantId, inventoryStockLocations.stockLocationId], + name: 'inventory_external_stock_correlations_location_fk', + }).onDelete('restrict'), + check( + 'inventory_external_stock_correlations_key_ck', + sql`length(btrim(${table.customerConfigurationId})) between 1 and 300 and ${table.issuerBackendKind} in ('external_business_system', 'ontos_wms') and length(btrim(${table.issuerBackendId})) between 1 and 300 and length(btrim(${table.namespace})) between 1 and 300 and length(btrim(${table.externalScope})) between 1 and 300 and ${table.identifierKind} in ('ITEM', 'LOCATION') and length(btrim(${table.externalValue})) between 1 and 300`, + ), + check( + 'inventory_external_stock_correlations_target_ck', + sql`(${table.identifierKind} = 'ITEM' and ${table.stockItemId} is not null and ${table.stockLocationId} is null) or (${table.identifierKind} = 'LOCATION' and ${table.stockItemId} is null and ${table.stockLocationId} is not null)`, + ), + check( + 'inventory_external_stock_correlations_lifecycle_ck', + sql`(${table.lifecycleState} = 'CURRENT' and ${table.effectiveTo} is null) or (${table.lifecycleState} = 'ENDED' and ${table.effectiveTo} is not null and ${table.effectiveFrom} < ${table.effectiveTo})`, + ), + check( + 'inventory_external_stock_correlations_evidence_ck', + sql`length(btrim(${table.ownerEvidenceRef})) between 1 and 300`, + ), + check('inventory_external_stock_correlations_revision_ck', sql`${table.revision} >= 1`), + ...tenantRlsPolicies('inventory_external_stock_correlations_tenant', table.tenantId), + ], +); + +export const INVENTORY_EXTERNAL_STOCK_CORRELATION_TABLES = [inventoryExternalStockCorrelations] as const; diff --git a/app/verticals/inventory/src/persistence/inventory-backend-configuration-repository.ts b/app/verticals/inventory/src/persistence/inventory-backend-configuration-repository.ts new file mode 100644 index 000000000..d87bf49f8 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-backend-configuration-repository.ts @@ -0,0 +1,110 @@ +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import { DateTime, Effect, Schema } from 'effect'; +import type { Option } from 'effect'; + +import { InventoryBackendConfigurationPersistenceUnavailable } from '../../shared/domain/inventory-backend-configuration-persistence-unavailable.ts'; +import { InventoryBackendConfigurationSchema } from '../../shared/domain/inventory-backend-configuration.ts'; +import type { InventoryBackendConfiguration } from '../../shared/domain/inventory-backend-configuration.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +export interface InventoryBackendConfigurationPersistence { + readonly findCurrent: ( + customerConfigurationId: string, + ) => Effect.Effect, InventoryBackendConfigurationPersistenceUnavailable>; + readonly insertInitial: ( + configuration: InventoryBackendConfiguration, + ) => Effect.Effect< + { readonly configuration: InventoryBackendConfiguration; readonly outcome: 'EXISTING' | 'INSERTED' }, + InventoryBackendConfigurationPersistenceUnavailable + >; +} + +const unavailable = (cause?: unknown) => { + const failure = new InventoryBackendConfigurationPersistenceUnavailable({ + code: 'inventory_backend_configuration_persistence_unavailable', + reason: 'Inventory Backend configuration persistence is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const decodeConfiguration = Schema.decodeUnknownEffect(InventoryBackendConfigurationSchema); + +const toDomain = (row: typeof inventoryBackendConfigurations.$inferSelect) => + decodeConfiguration({ + configurationId: row.configurationId, + customerConfigurationId: row.customerConfigurationId, + revision: row.revision, + selectedAt: row.selectedAt.toISOString(), + selection: { + backend: row.backendKind, + backendId: row.backendId, + exactReservationCapability: row.exactReservationCapability, + stockCorrectionCapability: row.stockCorrectionCapability, + }, + tenantId: row.tenantId, + }).pipe(Effect.mapError(unavailable)); + +export const inventoryBackendConfigurationPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): InventoryBackendConfigurationPersistence => { + const readRows = (customerConfigurationId: string) => + transaction + .select() + .from(inventoryBackendConfigurations) + .where( + and( + eq(inventoryBackendConfigurations.tenantId, scope.tenantId), + eq(inventoryBackendConfigurations.customerConfigurationId, customerConfigurationId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + + const findCurrent: InventoryBackendConfigurationPersistence['findCurrent'] = (customerConfigurationId) => + readRows(customerConfigurationId).pipe( + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : toDomain(row).pipe(Effect.asSome))), + ); + + const insertInitial: InventoryBackendConfigurationPersistence['insertInitial'] = Effect.fn( + 'InventoryBackendConfigurationPersistence.insertInitial', + )(function* insertInitialConfiguration(configuration) { + if (configuration.tenantId !== scope.tenantId) { + return yield* unavailable('Inventory Backend configuration tenant does not match trusted scope'); + } + const [inserted] = yield* transaction + .insert(inventoryBackendConfigurations) + .values({ + backendId: configuration.selection.backendId, + backendKind: configuration.selection.backend, + configurationId: configuration.configurationId, + customerConfigurationId: configuration.customerConfigurationId, + exactReservationCapability: configuration.selection.exactReservationCapability, + revision: configuration.revision, + selectedAt: DateTime.toDateUtc(DateTime.makeUnsafe(configuration.selectedAt)), + stockCorrectionCapability: configuration.selection.stockCorrectionCapability, + tenantId: scope.tenantId, + }) + .onConflictDoNothing({ + target: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.customerConfigurationId], + }) + .returning() + .pipe(Effect.mapError(unavailable)); + if (inserted !== undefined) { + return { configuration: yield* toDomain(inserted), outcome: 'INSERTED' as const }; + } + const [existing] = yield* readRows(configuration.customerConfigurationId); + if (existing === undefined) { + return yield* unavailable('Conflicting Inventory Backend configuration could not be read'); + } + return { configuration: yield* toDomain(existing), outcome: 'EXISTING' as const }; + }); + + return Object.freeze({ findCurrent, insertInitial }); +}; diff --git a/app/verticals/inventory/src/persistence/inventory-backend-configuration-table.ts b/app/verticals/inventory/src/persistence/inventory-backend-configuration-table.ts new file mode 100644 index 000000000..6570c5886 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-backend-configuration-table.ts @@ -0,0 +1,62 @@ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, integer, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import { inventorySchema } from '../database/inventory-schema.ts'; + +export const inventoryBackendConfigurationImmutabilityTriggerContract = { + columns: [ + 'configuration_id', + 'tenant_id', + 'customer_configuration_id', + 'backend_kind', + 'backend_id', + 'exact_reservation_capability', + 'stock_correction_capability', + 'revision', + 'selected_at', + ], + errorCondition: 'check_violation', + event: 'UPDATE_OR_DELETE', + functionName: 'inventory.reject_backend_configuration_mutation', + table: 'inventory.backend_configurations', + timing: 'BEFORE', + triggerName: 'inventory_backend_configurations_explicit_cutover_trg', +} as const; + +export const inventoryBackendConfigurations = inventorySchema.table.withRLS( + 'backend_configurations', + { + backendId: text('backend_id').notNull(), + backendKind: text('backend_kind').notNull(), + configurationId: uuid('configuration_id').primaryKey(), + customerConfigurationId: text('customer_configuration_id').notNull(), + exactReservationCapability: text('exact_reservation_capability').notNull(), + revision: integer('revision').default(1).notNull(), + selectedAt: timestamp('selected_at', { withTimezone: true }).notNull(), + stockCorrectionCapability: text('stock_correction_capability').notNull(), + tenantId: uuid('tenant_id').notNull(), + }, + (table) => [ + uniqueIndex('inventory_backend_configurations_scope_id_uk').on(table.tenantId, table.configurationId), + uniqueIndex('inventory_backend_configurations_customer_uk').on(table.tenantId, table.customerConfigurationId), + check( + 'inventory_backend_configurations_identity_ck', + sql`length(btrim(${table.backendId})) between 1 and 300 and length(btrim(${table.customerConfigurationId})) between 1 and 300`, + ), + check( + 'inventory_backend_configurations_backend_ck', + sql`${table.backendKind} in ('external_business_system', 'ontos_wms')`, + ), + check( + 'inventory_backend_configurations_capability_ck', + sql`${table.exactReservationCapability} in ('SUPPORTED', 'UNSUPPORTED') and (${table.backendKind} <> 'ontos_wms' or ${table.exactReservationCapability} = 'SUPPORTED')`, + ), + check( + 'inventory_backend_configurations_stock_correction_capability_ck', + sql`${table.stockCorrectionCapability} in ('SUPPORTED', 'UNSUPPORTED') and (${table.backendKind} <> 'ontos_wms' or ${table.stockCorrectionCapability} = 'SUPPORTED')`, + ), + check('inventory_backend_configurations_revision_ck', sql`${table.revision} = 1`), + ...tenantRlsPolicies('inventory_backend_configurations_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/inventory-effect-ledger-repository.ts b/app/verticals/inventory/src/persistence/inventory-effect-ledger-repository.ts new file mode 100644 index 000000000..66a457294 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-effect-ledger-repository.ts @@ -0,0 +1,278 @@ +import { defineScopedRoutine } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, eq } from 'drizzle-orm'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + InventoryEffectLedgerEffectIdSchema, + InventoryEffectLedgerRecordSchema, + InventoryEffectLedgerUnavailable, +} from '../../shared/domain/inventory-effect-ledger.ts'; +import type { + InventoryEffectLedgerIntent, + InventoryEffectLedgerRecord, +} from '../../shared/domain/inventory-effect-ledger.ts'; +import type { InventoryEffectLedgerPersistence } from '../services/inventory-effect-ledger.service.ts'; +import { + canonicalInventoryEffectIntent, + canonicalInventoryEffectIntentValue, +} from '../services/inventory-effect-ledger.service.ts'; +import { inventoryEffectLedger, inventoryEffectLedgerHistory } from './inventory-effect-ledger-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type EffectRow = typeof inventoryEffectLedger.$inferSelect; + +const workerRowSchema = Schema.Struct({ record: InventoryEffectLedgerRecordSchema }); +const claimRowSchema = Schema.Struct({ inserted: Schema.Boolean, record: InventoryEffectLedgerRecordSchema }); +const MODULE_KEY = 'commerce.inventory'; +export const claimInventoryEffectLedgerRoutine = defineScopedRoutine({ + name: 'claim_inventory_effect_ledger', + ownerModuleKey: MODULE_KEY, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: claimRowSchema, + routineKey: 'inventory.claim-inventory-effect-ledger', + schema: 'inventory', +}); +export const readInventoryEffectLedgerForWorkerRoutine = defineScopedRoutine({ + name: 'read_inventory_effect_ledger_for_worker', + ownerModuleKey: MODULE_KEY, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.read-inventory-effect-ledger-for-worker', + schema: 'inventory', +}); +export const transitionInventoryEffectLedgerForWorkerRoutine = defineScopedRoutine({ + name: 'transition_inventory_effect_ledger_for_worker', + ownerModuleKey: MODULE_KEY, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'integer' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.transition-inventory-effect-ledger-for-worker', + schema: 'inventory', +}); + +const unavailable = (effectId: typeof InventoryEffectLedgerEffectIdSchema.Type, reason: string, cause?: unknown) => { + const failure = new InventoryEffectLedgerUnavailable({ + code: 'inventory_effect_ledger_unavailable', + effectId, + reason, + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +interface StableScope { + readonly attemptId: string | null; + readonly authorityBackendId: string; + readonly authorityBackendKind: string; + readonly authorityConfigurationId: string; + readonly customerConfigurationId: string; + readonly legalEntityId: string; + readonly reservationId: string | null; +} + +const stableScopeFor = (intent: InventoryEffectLedgerIntent): StableScope => + Match.value(intent).pipe( + Match.tag('RESERVATION_CREATE', ({ request }) => ({ + attemptId: request.reservation.origin.attemptId, + authorityBackendId: request.authority.selection.backendId, + authorityBackendKind: request.authority.selection.backend, + authorityConfigurationId: request.authority.configurationId, + customerConfigurationId: request.authority.customerConfigurationId, + legalEntityId: request.legalEntityId, + reservationId: request.reservation.ref.resourceId, + })), + Match.tag('RESERVATION_RELEASE', ({ request }) => ({ + attemptId: request.reservation.origin.attemptId, + authorityBackendId: request.reservation.authority.selection.backendId, + authorityBackendKind: request.reservation.authority.selection.backend, + authorityConfigurationId: request.reservation.authority.configurationId, + customerConfigurationId: request.reservation.authority.customerConfigurationId, + legalEntityId: request.legalEntityId, + reservationId: request.reservation.ref.resourceId, + })), + Match.tag('ESTABLISH_COMMITMENT_PROTECTION', ({ request }) => ({ + attemptId: request.confirmation.reservation.origin.attemptId, + authorityBackendId: request.confirmation.reservation.authority.selection.backendId, + authorityBackendKind: request.confirmation.reservation.authority.selection.backend, + authorityConfigurationId: request.confirmation.reservation.authority.configurationId, + customerConfigurationId: request.confirmation.reservation.authority.customerConfigurationId, + legalEntityId: request.legalEntityId, + reservationId: request.confirmation.reservation.ref.resourceId, + })), + Match.tag('PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE', ({ request }) => ({ + attemptId: null, + authorityBackendId: request.backendId, + authorityBackendKind: request.backend, + authorityConfigurationId: request.backendConfigurationRef.resourceId, + customerConfigurationId: request.customerConfigurationId, + legalEntityId: request.legalEntityId, + reservationId: null, + })), + Match.exhaustive, + ); + +const valuesFor = (record: InventoryEffectLedgerRecord) => { + const stable = stableScopeFor(record.intent); + return { + ...stable, + currentRevision: record.revision, + currentState: record.currentState, + effectId: record.effectId, + effectKind: record.intent._tag, + intentCanonical: canonicalInventoryEffectIntent(record.intent), + intentJson: canonicalInventoryEffectIntentValue(record.intent), + requestedAt: DateTime.toDateUtc(DateTime.makeUnsafe(record.requestedAt)), + resolutionJson: record.resolution, + snapshot: record, + tenantId: record.tenantId, + updatedAt: DateTime.toDateUtc(DateTime.makeUnsafe(record.updatedAt)), + }; +}; + +const decodeRow = (row: EffectRow) => + Schema.decodeEffect(InventoryEffectLedgerRecordSchema)(row.snapshot).pipe( + Effect.mapError((cause) => + unavailable( + InventoryEffectLedgerEffectIdSchema.make(row.effectId), + 'Persisted Inventory effect ledger entry is invalid', + cause, + ), + ), + ); + +export const inventoryEffectLedgerPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): InventoryEffectLedgerPersistence => { + const read: InventoryEffectLedgerPersistence['read'] = (effectId) => + transaction + .select() + .from(inventoryEffectLedger) + .where(and(eq(inventoryEffectLedger.tenantId, scope.tenantId), eq(inventoryEffectLedger.effectId, effectId))) + .for('update') + .limit(1) + .pipe( + Effect.mapError((cause) => unavailable(effectId, 'Inventory effect ledger is temporarily unavailable', cause)), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeRow(row).pipe(Effect.asSome))), + ); + + const appendHistory = (record: InventoryEffectLedgerRecord) => + transaction + .insert(inventoryEffectLedgerHistory) + .values({ + effectId: record.effectId, + revision: record.revision, + snapshot: record, + state: record.currentState, + tenantId: record.tenantId, + transitionedAt: DateTime.toDateUtc(DateTime.makeUnsafe(record.updatedAt)), + }) + .pipe( + Effect.mapError((cause) => unavailable(record.effectId, 'Inventory effect history is unavailable', cause)), + Effect.asVoid, + ); + + const createOrRead: InventoryEffectLedgerPersistence['createOrRead'] = Effect.fn( + 'InventoryEffectLedgerPersistence.createOrRead', + )(function* createOrReadEffect(candidate) { + if ( + candidate.tenantId !== scope.tenantId || + stableScopeFor(candidate.intent).legalEntityId !== scope.legalEntityId + ) { + return yield* unavailable(candidate.effectId, 'Inventory effect scope does not match the trusted operation'); + } + const canonicalIntent = canonicalInventoryEffectIntentValue(candidate.intent); + const canonicalCandidate: InventoryEffectLedgerRecord = { ...candidate, intent: canonicalIntent }; + const [claimed] = yield* transaction + .invoke(claimInventoryEffectLedgerRoutine, [canonicalInventoryEffectIntent(canonicalIntent), canonicalCandidate]) + .pipe( + Effect.mapError((cause) => unavailable(candidate.effectId, 'Inventory effect claim is unavailable', cause)), + ); + if (claimed === undefined) { + return yield* unavailable(candidate.effectId, 'Inventory effect claim returned no authoritative record'); + } + return { outcome: claimed.inserted ? ('INSERTED' as const) : ('EXISTING' as const), record: claimed.record }; + }); + + const save: InventoryEffectLedgerPersistence['save'] = Effect.fn('InventoryEffectLedgerPersistence.save')( + function* saveEffect(expected, next) { + if ( + expected.tenantId !== scope.tenantId || + next.tenantId !== scope.tenantId || + expected.effectId !== next.effectId || + next.revision !== expected.revision + 1 + ) { + return Option.none(); + } + const [updated] = yield* transaction + .update(inventoryEffectLedger) + .set(valuesFor(next)) + .where( + and( + eq(inventoryEffectLedger.tenantId, scope.tenantId), + eq(inventoryEffectLedger.effectId, expected.effectId), + eq(inventoryEffectLedger.currentRevision, expected.revision), + eq(inventoryEffectLedger.currentState, expected.currentState), + ), + ) + .returning() + .pipe( + Effect.mapError((cause) => + unavailable(expected.effectId, 'Inventory effect transition is unavailable', cause), + ), + ); + if (updated === undefined) { + return Option.none(); + } + const persisted = yield* decodeRow(updated); + yield* appendHistory(persisted); + return Option.some(persisted); + }, + ); + + return Object.freeze({ createOrRead, read, save }); +}; + +export const inventoryEffectLedgerPersistenceForWorkerScope = ( + scope: OutboxWorkerLegalEntityScope, +): InventoryEffectLedgerPersistence => ({ + createOrRead: (candidate) => + Effect.fail(unavailable(candidate.effectId, 'Workers cannot claim a new Inventory effect')), + read: (effectId) => + scope.routineInvoker.invoke(readInventoryEffectLedgerForWorkerRoutine, [effectId]).pipe( + Effect.mapError((cause) => unavailable(effectId, 'Inventory effect ledger is temporarily unavailable', cause)), + Effect.map(([row]) => (row === undefined ? Option.none() : Option.some(row.record))), + ), + save: (expected, next) => + scope.routineInvoker + .invoke(transitionInventoryEffectLedgerForWorkerRoutine, [ + expected.effectId, + expected.revision, + expected.currentState, + next, + ]) + .pipe( + Effect.mapError((cause) => unavailable(expected.effectId, 'Inventory effect transition is unavailable', cause)), + Effect.map(([row]) => (row === undefined ? Option.none() : Option.some(row.record))), + ), +}); diff --git a/app/verticals/inventory/src/persistence/inventory-effect-ledger-table.ts b/app/verticals/inventory/src/persistence/inventory-effect-ledger-table.ts new file mode 100644 index 000000000..ba90b914a --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-effect-ledger-table.ts @@ -0,0 +1,167 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { + check, + foreignKey, + index, + integer, + jsonb, + primaryKey, + text, + timestamp, + uniqueIndex, + uuid, +} from 'drizzle-orm/pg-core'; + +import type { + InventoryEffectLedgerIntent, + InventoryEffectLedgerRecord, + InventoryEffectLedgerResolution, +} from '../../shared/domain/inventory-effect-ledger.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; + +export const inventoryEffectLedger = inventorySchema.table.withRLS( + 'effect_ledger', + { + tenantId: uuid('tenant_id').notNull(), + effectId: text('effect_id').notNull(), + effectKind: text('effect_kind').notNull(), + currentState: text('current_state').default('REQUESTED').notNull(), + currentRevision: integer('current_revision').default(1).notNull(), + legalEntityId: uuid('legal_entity_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + reservationId: uuid('reservation_id'), + attemptId: text('attempt_id'), + authorityConfigurationId: uuid('authority_configuration_id').notNull(), + authorityBackendKind: text('authority_backend_kind').notNull(), + authorityBackendId: text('authority_backend_id').notNull(), + intentJson: jsonb('intent_json').$type().notNull(), + intentCanonical: text('intent_canonical').notNull(), + resolutionJson: jsonb('resolution_json').$type(), + snapshot: jsonb('snapshot').$type().notNull(), + requestedAt: timestamp('requested_at', { withTimezone: true }).notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).notNull(), + }, + (table) => [ + primaryKey({ columns: [table.tenantId, table.effectId], name: 'inventory_effect_ledger_pkey' }), + index('inventory_effect_ledger_state_idx').on( + table.tenantId, + table.currentState, + table.effectKind, + table.updatedAt, + ), + index('inventory_effect_ledger_reservation_idx').on(table.tenantId, table.reservationId, table.effectKind), + uniqueIndex('inventory_effect_ledger_commitment_protection_attempt_uk') + .on(table.tenantId, table.reservationId, table.attemptId, table.effectKind) + .where(sql`${table.effectKind} = 'ESTABLISH_COMMITMENT_PROTECTION'`), + foreignKey({ + columns: [table.tenantId, table.authorityConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_effect_ledger_authority_fk', + }).onDelete('restrict'), + check( + 'inventory_effect_ledger_kind_ck', + sql`${table.effectKind} in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION', 'PHYSICAL_RECEIPT', 'PHYSICAL_ISSUE')`, + ), + check( + 'inventory_effect_ledger_state_ck', + sql`${table.currentState} in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED')`, + ), + check( + 'inventory_effect_ledger_identity_ck', + sql`char_length(btrim(${table.effectId})) between 1 and 300 and char_length(btrim(${table.customerConfigurationId})) between 1 and 300 and char_length(btrim(${table.authorityBackendId})) between 1 and 300 and char_length(${table.intentCanonical}) > 0`, + ), + check( + 'inventory_effect_ledger_reservation_scope_ck', + sql`(${table.effectKind} in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and ${table.reservationId} is not null and ${table.attemptId} is not null and char_length(btrim(${table.attemptId})) between 1 and 300) or (${table.effectKind} not in ('RESERVATION_CREATE', 'RESERVATION_RELEASE', 'ESTABLISH_COMMITMENT_PROTECTION') and ${table.reservationId} is null and ${table.attemptId} is null)`, + ), + check( + 'inventory_effect_ledger_resolution_ck', + sql`(${table.currentState} = 'REQUESTED' and ${table.resolutionJson} is null) or (${table.currentState} = 'INDETERMINATE') or (${table.currentState} in ('SUCCEEDED', 'REJECTED') and ${table.resolutionJson} is not null)`, + ), + check('inventory_effect_ledger_revision_ck', sql`${table.currentRevision} >= 1`), + ...tenantRlsPolicies('inventory_effect_ledger_tenant', table.tenantId), + ], +); + +export const inventoryEffectLedgerHistory = inventorySchema.table.withRLS( + 'effect_ledger_history', + { + historyId: uuid('history_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + effectId: text('effect_id').notNull(), + revision: integer('revision').notNull(), + state: text('state').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + transitionedAt: timestamp('transitioned_at', { withTimezone: true }).notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_effect_ledger_history_scope_id_uk').on(table.tenantId, table.historyId), + uniqueIndex('inventory_effect_ledger_history_revision_uk').on(table.tenantId, table.effectId, table.revision), + foreignKey({ + columns: [table.tenantId, table.effectId], + foreignColumns: [inventoryEffectLedger.tenantId, inventoryEffectLedger.effectId], + name: 'inventory_effect_ledger_history_effect_fk', + }).onDelete('restrict'), + check( + 'inventory_effect_ledger_history_state_ck', + sql`${table.state} in ('REQUESTED', 'INDETERMINATE', 'SUCCEEDED', 'REJECTED') and ${table.revision} >= 1`, + ), + ...tenantRlsPolicies('inventory_effect_ledger_history_tenant', table.tenantId), + ], +); + +export const inventoryEffectLedgerTransitionContract = { + allowedTransitions: { + INDETERMINATE: ['INDETERMINATE', 'SUCCEEDED', 'REJECTED'], + REJECTED: [], + REQUESTED: ['INDETERMINATE', 'SUCCEEDED', 'REJECTED'], + SUCCEEDED: [], + }, + functionName: 'inventory.enforce_effect_ledger_transition', + immutableColumns: [ + 'tenant_id', + 'effect_id', + 'effect_kind', + 'legal_entity_id', + 'customer_configuration_id', + 'reservation_id', + 'attempt_id', + 'authority_configuration_id', + 'authority_backend_kind', + 'authority_backend_id', + 'intent_json', + 'intent_canonical', + 'requested_at', + ], + monotonicRevision: true, + table: 'inventory.effect_ledger', + triggerName: 'inventory_effect_ledger_transition_trg', +} as const; + +export const inventoryEffectLedgerExactScopeContract = { + constraintName: 'inventory_effect_ledger_exact_scope_ck', + currentIntentKinds: [ + 'RESERVATION_CREATE', + 'RESERVATION_RELEASE', + 'ESTABLISH_COMMITMENT_PROTECTION', + 'PHYSICAL_RECEIPT', + 'PHYSICAL_ISSUE', + ], + functionName: 'inventory.enforce_effect_ledger_exact_scope', + reservedKinds: [], + table: 'inventory.effect_ledger', + triggerName: 'inventory_effect_ledger_exact_scope_trg', +} as const; + +export const inventoryEffectLedgerHistoryImmutabilityContract = { + deleteTriggerName: 'inventory_effect_ledger_history_no_delete_trg', + functionName: 'inventory.reject_effect_ledger_history_mutation', + table: 'inventory.effect_ledger_history', + updateTriggerName: 'inventory_effect_ledger_history_no_update_trg', +} as const; + +export const INVENTORY_EFFECT_LEDGER_TABLES = [inventoryEffectLedgerHistory, inventoryEffectLedger] as const; diff --git a/app/verticals/inventory/src/persistence/inventory-obligation-repository.ts b/app/verticals/inventory/src/persistence/inventory-obligation-repository.ts new file mode 100644 index 000000000..4d4b225e0 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-obligation-repository.ts @@ -0,0 +1,636 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + ImportedCommittedObligationSchema, + InventoryObligationRejected, + InventoryObligationSchema, + ProvisionalInventoryReservationSchema, + RuntimeCommittedInventoryObligationSchema, +} from '../../shared/domain/inventory-obligation.ts'; +import type { + ImportedCommittedObligation, + InventoryObligation, + ProvisionalInventoryReservation, + RuntimeCommittedInventoryObligation, +} from '../../shared/domain/inventory-obligation.ts'; +import { InventoryObligationPersistenceUnavailable } from '../../shared/domain/inventory-obligation-persistence-unavailable.ts'; +import type { ImportedCommittedObligationRef } from '../../shared/resources/imported-committed-obligation.ts'; +import type { InventoryReservationRef } from '../../shared/resources/inventory-reservation.ts'; +import { currentBindingRequirementsMatch, lockBindingCorrectionScopes } from './binding-correction-serialization.ts'; +import { + inventoryObligationAllocations, + inventoryObligationCoverageTriggerContract, + inventoryObligationRequirements, + inventoryObligations, + inventoryObligationScopeTriggerContract, +} from './inventory-obligation-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type ObligationRow = typeof inventoryObligations.$inferSelect; +type RequirementRow = typeof inventoryObligationRequirements.$inferSelect; +type AllocationRow = typeof inventoryObligationAllocations.$inferSelect; +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; +const INVENTORY_RESERVATION_RESOURCE_TYPE = 'commerce.inventory.inventory-reservation' as const; +const STOCK_ITEM_RESOURCE_TYPE = 'commerce.inventory.stock-item' as const; +const STOCK_POSITION_RESOURCE_TYPE = 'commerce.inventory.stock-position' as const; +const CATALOG_BINDING_RESOURCE_TYPE = 'commerce.inventory.catalog-to-stock-binding' as const; + +export { InventoryObligationPersistenceUnavailable } from '../../shared/domain/inventory-obligation-persistence-unavailable.ts'; + +export type InventoryObligationPersistenceError = + | InventoryObligationRejected + | InventoryObligationPersistenceUnavailable; + +export interface InventoryReservationEstablishment { + readonly obligation: ProvisionalInventoryReservation; + readonly outcome: 'ESTABLISHED' | 'EXACT_REPLAY'; +} + +export interface ImportedObligationEstablishment { + readonly obligation: ImportedCommittedObligation; + readonly outcome: 'IMPORTED' | 'EXACT_REPLAY'; +} + +export interface RuntimeCommittedObligationTransition { + readonly obligation: RuntimeCommittedInventoryObligation; + readonly outcome: 'COMMITTED' | 'EXACT_REPLAY'; +} + +export interface InventoryObligationPersistence { + readonly commitReservation: ( + obligation: RuntimeCommittedInventoryObligation, + ) => Effect.Effect; + readonly establishReservation: ( + obligation: ProvisionalInventoryReservation, + ) => Effect.Effect; + readonly importCommitted: ( + obligation: ImportedCommittedObligation, + ) => Effect.Effect; + readonly read: ( + ref: ImportedCommittedObligationRef | InventoryReservationRef, + ) => Effect.Effect, InventoryObligationPersistenceError>; +} + +const unavailable = (cause?: unknown) => { + const failure = new InventoryObligationPersistenceUnavailable({ + code: 'inventory_obligation_persistence_unavailable', + reason: 'Inventory obligation persistence is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const reject = (reason: InventoryObligationRejected['reason'], _obligationId?: string) => + new InventoryObligationRejected({ code: 'inventory_obligation_rejected', reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); + +export const mapInventoryObligationWriteError = ( + cause: unknown, + obligationId?: string, +): InventoryObligationPersistenceError => { + const attempt = findPostgresFailure( + cause, + ({ code, constraint }) => code === uniqueViolationSqlState && constraint === 'inventory_obligations_attempt_uk', + ); + if (Option.isSome(attempt)) { + return reject('ATTEMPT_ALREADY_BOUND', obligationId); + } + const importedLineage = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_obligations_imported_lineage_uk', + ); + if (Option.isSome(importedLineage)) { + return reject('SOURCE_LINEAGE_ALREADY_IMPORTED', obligationId); + } + const commitBinding = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === uniqueViolationSqlState && constraint === 'inventory_obligations_runtime_accepted_order_uk') || + (code === checkViolationSqlState && constraint === 'inventory_obligations_immutable_origin_ck'), + ); + if (Option.isSome(commitBinding)) { + return reject('ORDER_COMMIT_BINDING_CONFLICT', obligationId); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + ['obligations_pkey', 'inventory_obligations_scope_id_uk'].includes(constraint ?? ''), + ); + if (Option.isSome(identity)) { + return reject('OBLIGATION_IDENTITY_CONFLICT', obligationId); + } + const scopeConstraints = new Set([ + 'inventory_obligations_backend_configuration_fk', + 'inventory_obligation_requirements_obligation_fk', + 'inventory_obligation_requirements_item_fk', + 'inventory_obligation_allocations_requirement_fk', + 'inventory_obligation_allocations_position_fk', + 'inventory_obligation_allocations_item_fk', + inventoryObligationCoverageTriggerContract.constraintName, + ...Object.values(inventoryObligationScopeTriggerContract.constraintNames), + ]); + const scope = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === foreignKeyViolationSqlState || code === checkViolationSqlState) && + scopeConstraints.has(constraint ?? ''), + ); + return Option.isSome(scope) ? reject('INVALID_PERSISTED_OBLIGATION', obligationId) : unavailable(cause); +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const parentValues = (obligation: InventoryObligation) => { + const common = { + authorityBackendId: obligation.authority.selection.backendId, + authorityBackendKind: obligation.authority.selection.backend, + authorityExactReservationCapability: obligation.authority.selection.exactReservationCapability, + authorityRevision: obligation.authority.revision, + authoritySelectedAt: instantAsDate(obligation.authority.selectedAt), + authorityStockCorrectionCapability: obligation.authority.selection.stockCorrectionCapability, + customerConfigurationId: obligation.authority.customerConfigurationId, + lifecycleMeaning: obligation.lifecycleMeaning, + obligationId: obligation.ref.resourceId, + ownerConfigurationId: obligation.authority.configurationId, + tenantId: obligation.ref.tenantId, + }; + if (Schema.is(ImportedCommittedObligationSchema)(obligation)) { + return { + ...common, + acceptedOrderId: obligation.orderProof.acceptedOrderId, + attemptId: null, + establishedAt: instantAsDate(obligation.importedAt), + orderEvidenceObservedAt: instantAsDate(obligation.orderProof.observedAt), + orderEvidenceRef: obligation.orderProof.evidenceRef, + originKind: obligation.origin.kind, + sourceObligationId: obligation.origin.sourceObligationId, + sourceOrderId: obligation.origin.sourceOrderId, + sourceSystem: obligation.origin.sourceSystem, + }; + } + const commitProof = Schema.is(RuntimeCommittedInventoryObligationSchema)(obligation) ? obligation.orderProof : null; + return { + ...common, + acceptedOrderId: commitProof?.acceptedOrderId ?? null, + attemptId: obligation.origin.attemptId, + establishedAt: instantAsDate(obligation.establishedAt), + orderEvidenceObservedAt: commitProof === null ? null : instantAsDate(commitProof.observedAt), + orderEvidenceRef: commitProof?.evidenceRef ?? null, + originKind: obligation.origin.kind, + sourceObligationId: null, + sourceOrderId: null, + sourceSystem: null, + }; +}; + +const requirementValues = (obligation: InventoryObligation) => + obligation.requirements.map((requirement) => ({ + bindingId: requirement.bindingRef.resourceId, + catalogSelection: requirement.catalogSelection, + exactSelectionMeaningId: requirement.exactSelectionMeaning.id, + exactSelectionMeaningKind: requirement.exactSelectionMeaning.kind, + obligationId: obligation.ref.resourceId, + purchaseDemandOccurrenceId: requirement.purchaseDemandOccurrenceId, + requestedAmount: requirement.quantity, + stockItemId: requirement.stockItem.stockItemRef.resourceId, + stockItemRevision: requirement.stockItem.revision, + stockItemSnapshot: requirement.stockItem, + tenantId: obligation.ref.tenantId, + unitModuleId: requirement.unitRef.moduleId, + unitResourceId: requirement.unitRef.resourceId, + unitResourceType: requirement.unitRef.resourceType, + unitTenantId: requirement.unitRef.tenantId, + })); + +const allocationValues = (obligation: InventoryObligation) => + obligation.requirements.flatMap((requirement) => + requirement.allocations.map((allocation) => ({ + allocatedAmount: allocation.quantity.amount, + allocationId: allocation.allocationId, + obligationId: obligation.ref.resourceId, + purchaseDemandOccurrenceId: requirement.purchaseDemandOccurrenceId, + stockItemId: allocation.stockItemRef.resourceId, + stockPositionId: allocation.positionRef.resourceId, + tenantId: obligation.ref.tenantId, + unitModuleId: allocation.quantity.unitRef.moduleId, + unitResourceId: allocation.quantity.unitRef.resourceId, + unitResourceType: allocation.quantity.unitRef.resourceType, + unitTenantId: allocation.quantity.unitRef.tenantId, + })), + ); + +const storedNumericPattern = /^(?[0-9]+)(?:\.(?[0-9]+))?$/u; +const canonicalAmount = (amount: string): string => { + const groups = storedNumericPattern.exec(amount)?.groups; + if (groups?.['integer'] === undefined) { + return amount; + } + const integer = BigInt(groups['integer']).toString(); + const fraction = (groups['fraction'] ?? '').replace(/0+$/u, ''); + return fraction.length === 0 ? integer : `${integer}.${fraction}`; +}; + +const unitRefFor = (row: RequirementRow | AllocationRow) => ({ + moduleId: row.unitModuleId, + resourceId: row.unitResourceId, + resourceType: row.unitResourceType, + tenantId: row.unitTenantId, +}); + +const requirementsFor = ( + row: ObligationRow, + requirements: readonly RequirementRow[], + allocations: readonly AllocationRow[], +): readonly unknown[] => + requirements.map((requirement) => { + const matchingAllocations: unknown[] = []; + for (const allocation of allocations) { + if (allocation.purchaseDemandOccurrenceId === requirement.purchaseDemandOccurrenceId) { + matchingAllocations.push({ + allocationId: allocation.allocationId, + positionRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: allocation.stockPositionId, + resourceType: STOCK_POSITION_RESOURCE_TYPE, + tenantId: row.tenantId, + }, + quantity: { amount: canonicalAmount(allocation.allocatedAmount), unitRef: unitRefFor(allocation) }, + stockItemRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: allocation.stockItemId, + resourceType: STOCK_ITEM_RESOURCE_TYPE, + tenantId: row.tenantId, + }, + }); + } + } + return { + allocations: matchingAllocations, + bindingRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: requirement.bindingId, + resourceType: CATALOG_BINDING_RESOURCE_TYPE, + tenantId: row.tenantId, + }, + catalogSelection: requirement.catalogSelection, + exactSelectionMeaning: { + id: requirement.exactSelectionMeaningId, + kind: requirement.exactSelectionMeaningKind, + }, + purchaseDemandOccurrenceId: requirement.purchaseDemandOccurrenceId, + quantity: canonicalAmount(requirement.requestedAmount), + stockItem: requirement.stockItemSnapshot, + unitRef: unitRefFor(requirement), + }; + }); + +const decodeAggregate = ( + row: ObligationRow, + requirements: readonly RequirementRow[], + allocations: readonly AllocationRow[], +) => { + const authority = { + configurationId: row.ownerConfigurationId, + customerConfigurationId: row.customerConfigurationId, + revision: row.authorityRevision, + selectedAt: row.authoritySelectedAt.toISOString(), + selection: { + backend: row.authorityBackendKind, + backendId: row.authorityBackendId, + exactReservationCapability: row.authorityExactReservationCapability, + stockCorrectionCapability: row.authorityStockCorrectionCapability, + }, + tenantId: row.tenantId, + }; + const demand = requirementsFor(row, requirements, allocations); + if (row.originKind === 'ORDER_COMMITMENT_ATTEMPT') { + const ref = { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.obligationId, + resourceType: INVENTORY_RESERVATION_RESOURCE_TYPE, + tenantId: row.tenantId, + }; + const encoded = + row.lifecycleMeaning === 'COMMITTED_OBLIGATION' + ? { + authority, + confirmationTerminationReleasesStock: false, + establishedAt: row.establishedAt.toISOString(), + historicalBindingPolicy: 'PRESERVE_AND_RECONCILE', + lifecycleMeaning: row.lifecycleMeaning, + obligationReductionCreatesOnHand: false, + orderProof: { + acceptedOrderId: row.acceptedOrderId, + attemptId: row.attemptId, + authority: 'ORDER_COMMIT_PROOF_AUTHORITY', + commitStatus: 'COMMITTED', + evidenceRef: row.orderEvidenceRef, + observedAt: row.orderEvidenceObservedAt?.toISOString(), + reservationRef: ref, + tenantId: row.tenantId, + }, + origin: { attemptId: row.attemptId, kind: row.originKind }, + physicalIssueBoundary: 'SEPARATE_INVENTORY_TRANSITION', + ref, + remainingQuantityConstraint: 'OWNER_GOVERNED_TRANSITION_REQUIRED', + requirements: demand, + } + : { + authority, + establishedAt: row.establishedAt.toISOString(), + lifecycleMeaning: row.lifecycleMeaning, + origin: { attemptId: row.attemptId, kind: row.originKind }, + ref, + requirements: demand, + }; + return Schema.decodeUnknownEffect(InventoryObligationSchema)(encoded).pipe(Effect.mapError(unavailable)); + } + const encoded = { + authority, + importedAt: row.establishedAt.toISOString(), + lifecycleMeaning: row.lifecycleMeaning, + orderProof: { + acceptedOrderId: row.acceptedOrderId, + authority: 'ORDER_MIGRATION_PROOF_AUTHORITY', + commitStatus: 'COMMITTED', + evidenceRef: row.orderEvidenceRef, + observedAt: row.orderEvidenceObservedAt?.toISOString(), + sourceOrderId: row.sourceOrderId, + sourceSystem: row.sourceSystem, + }, + origin: { + kind: row.originKind, + sourceObligationId: row.sourceObligationId, + sourceOrderId: row.sourceOrderId, + sourceSystem: row.sourceSystem, + }, + ref: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.obligationId, + resourceType: 'commerce.inventory.imported-committed-obligation', + tenantId: row.tenantId, + }, + requirements: demand, + runtimeAttemptId: null, + }; + return Schema.decodeUnknownEffect(InventoryObligationSchema)(encoded).pipe(Effect.mapError(unavailable)); +}; + +const canonicalObligation = (obligation: InventoryObligation) => + Schema.encodeEffect(Schema.fromJsonString(InventoryObligationSchema))({ + ...obligation, + requirements: obligation.requirements + .toSorted((left, right) => left.purchaseDemandOccurrenceId.localeCompare(right.purchaseDemandOccurrenceId)) + .map((requirement) => ({ + ...requirement, + allocations: requirement.allocations.toSorted((left, right) => + left.allocationId.localeCompare(right.allocationId), + ), + })), + }).pipe(Effect.mapError(unavailable)); + +export const inventoryObligationPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): InventoryObligationPersistence => { + const requireTenant = (tenantId: string, obligationId?: string) => + tenantId === scope.tenantId ? Effect.void : Effect.fail(reject('TENANT_SCOPE_MISMATCH', obligationId)); + + const readRows = Effect.fn('InventoryObligationPersistence.readRows')(function* readObligationRows( + row: ObligationRow, + ) { + const requirementsRead = transaction + .select() + .from(inventoryObligationRequirements) + .where( + and( + eq(inventoryObligationRequirements.tenantId, scope.tenantId), + eq(inventoryObligationRequirements.obligationId, row.obligationId), + ), + ) + .orderBy(asc(inventoryObligationRequirements.purchaseDemandOccurrenceId)) + .pipe(Effect.mapError(unavailable)); + const allocationsRead = transaction + .select() + .from(inventoryObligationAllocations) + .where( + and( + eq(inventoryObligationAllocations.tenantId, scope.tenantId), + eq(inventoryObligationAllocations.obligationId, row.obligationId), + ), + ) + .orderBy(asc(inventoryObligationAllocations.allocationId)) + .pipe(Effect.mapError(unavailable)); + const [requirements, allocations] = yield* Effect.all([requirementsRead, allocationsRead] as const, { + concurrency: 1, + }); + return yield* decodeAggregate(row, requirements, allocations); + }); + + const findParent = (predicate: ReturnType) => + transaction.select().from(inventoryObligations).where(predicate).limit(1).pipe(Effect.mapError(unavailable)); + + const read: InventoryObligationPersistence['read'] = Effect.fn('InventoryObligationPersistence.read')( + function* readObligation(ref) { + yield* requireTenant(ref.tenantId, ref.resourceId); + const [row] = yield* findParent( + and(eq(inventoryObligations.tenantId, scope.tenantId), eq(inventoryObligations.obligationId, ref.resourceId)), + ); + if (row === undefined) { + return Option.none(); + } + const obligation = yield* readRows(row); + if (obligation.ref.resourceType !== ref.resourceType) { + return yield* reject('OBLIGATION_IDENTITY_CONFLICT', ref.resourceId); + } + return Option.some(obligation); + }, + ); + + const persistNew = Effect.fn('InventoryObligationPersistence.persistNew')(function* persistNewObligation( + obligation: InventoryObligation, + ) { + const [inserted] = yield* transaction + .insert(inventoryObligations) + .values(parentValues(obligation)) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError((cause) => mapInventoryObligationWriteError(cause, obligation.ref.resourceId))); + if (inserted === undefined) { + return false; + } + const bindingRequirements = obligation.requirements.map((requirement) => ({ + bindingId: requirement.bindingRef.resourceId, + exactSelectionMeaning: requirement.exactSelectionMeaning, + stockItemId: requirement.stockItem.stockItemRef.resourceId, + tenantId: obligation.ref.tenantId, + })); + const bindingsRemainCurrent = yield* currentBindingRequirementsMatch(transaction, bindingRequirements).pipe( + Effect.mapError(unavailable), + ); + if (!bindingsRemainCurrent) { + return yield* reject('INVALID_PERSISTED_OBLIGATION', obligation.ref.resourceId); + } + yield* transaction + .insert(inventoryObligationRequirements) + .values(requirementValues(obligation)) + .pipe(Effect.mapError((cause) => mapInventoryObligationWriteError(cause, obligation.ref.resourceId))); + yield* transaction + .insert(inventoryObligationAllocations) + .values(allocationValues(obligation)) + .pipe(Effect.mapError((cause) => mapInventoryObligationWriteError(cause, obligation.ref.resourceId))); + return true; + }); + + const establishReservation: InventoryObligationPersistence['establishReservation'] = Effect.fn( + 'InventoryObligationPersistence.establishReservation', + )(function* establishReservationObligation(obligation) { + const obligationId = obligation.ref.resourceId; + yield* requireTenant(obligation.ref.tenantId, obligationId); + if (!Schema.is(ProvisionalInventoryReservationSchema)(obligation)) { + return yield* reject('INVALID_PERSISTED_OBLIGATION', obligationId); + } + yield* lockBindingCorrectionScopes( + transaction, + obligation.requirements.map((requirement) => ({ + exactSelectionMeaning: requirement.exactSelectionMeaning, + tenantId: obligation.ref.tenantId, + })), + ).pipe(Effect.mapError(unavailable)); + const inserted = yield* persistNew(obligation); + if (inserted) { + return { obligation, outcome: 'ESTABLISHED' as const }; + } + const [existingRow] = yield* findParent( + and( + eq(inventoryObligations.tenantId, scope.tenantId), + eq(inventoryObligations.originKind, 'ORDER_COMMITMENT_ATTEMPT'), + eq(inventoryObligations.attemptId, obligation.origin.attemptId), + ), + ); + if (existingRow === undefined) { + return yield* reject('OBLIGATION_IDENTITY_CONFLICT', obligation.ref.resourceId); + } + const existing = yield* readRows(existingRow); + if (existing.ref.resourceId !== obligation.ref.resourceId) { + return yield* reject('ATTEMPT_ALREADY_BOUND', obligation.ref.resourceId); + } + const [existingCanonical, requestedCanonical] = yield* Effect.all( + [canonicalObligation(existing), canonicalObligation(obligation)] as const, + { concurrency: 1 }, + ); + if (existingCanonical !== requestedCanonical) { + return yield* reject('OBLIGATION_IDENTITY_CONFLICT', obligation.ref.resourceId); + } + return { obligation, outcome: 'EXACT_REPLAY' as const }; + }); + + const commitReservation: InventoryObligationPersistence['commitReservation'] = Effect.fn( + 'InventoryObligationPersistence.commitReservation', + )(function* commitReservationObligation(obligation) { + const obligationId = obligation.ref.resourceId; + yield* requireTenant(obligation.ref.tenantId, obligationId); + if (!Schema.is(RuntimeCommittedInventoryObligationSchema)(obligation)) { + return yield* reject('INVALID_PERSISTED_OBLIGATION', obligationId); + } + const [updatedRow] = yield* transaction + .update(inventoryObligations) + .set({ + acceptedOrderId: obligation.orderProof.acceptedOrderId, + lifecycleMeaning: 'COMMITTED_OBLIGATION', + orderEvidenceObservedAt: instantAsDate(obligation.orderProof.observedAt), + orderEvidenceRef: obligation.orderProof.evidenceRef, + }) + .where( + and( + eq(inventoryObligations.tenantId, scope.tenantId), + eq(inventoryObligations.obligationId, obligationId), + eq(inventoryObligations.originKind, 'ORDER_COMMITMENT_ATTEMPT'), + eq(inventoryObligations.attemptId, obligation.origin.attemptId), + eq(inventoryObligations.lifecycleMeaning, 'PROVISIONAL_RESERVATION'), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => mapInventoryObligationWriteError(cause, obligationId))); + if (updatedRow !== undefined) { + const persisted = yield* readRows(updatedRow); + if (!Schema.is(RuntimeCommittedInventoryObligationSchema)(persisted)) { + return yield* reject('INVALID_PERSISTED_OBLIGATION', obligationId); + } + return { obligation: persisted, outcome: 'COMMITTED' as const }; + } + + const [existingRow] = yield* findParent( + and(eq(inventoryObligations.tenantId, scope.tenantId), eq(inventoryObligations.obligationId, obligationId)), + ); + if (existingRow === undefined) { + return yield* reject('OBLIGATION_IDENTITY_CONFLICT', obligationId); + } + const existing = yield* readRows(existingRow); + if (!Schema.is(RuntimeCommittedInventoryObligationSchema)(existing)) { + return yield* reject('RESERVATION_NOT_PROVISIONAL', obligationId); + } + const [existingCanonical, requestedCanonical] = yield* Effect.all( + [canonicalObligation(existing), canonicalObligation(obligation)] as const, + { concurrency: 1 }, + ); + if (existingCanonical !== requestedCanonical) { + return yield* reject('ORDER_COMMIT_BINDING_CONFLICT', obligationId); + } + return { obligation: existing, outcome: 'EXACT_REPLAY' as const }; + }); + + const importCommitted: InventoryObligationPersistence['importCommitted'] = Effect.fn( + 'InventoryObligationPersistence.importCommitted', + )(function* importCommittedObligation(obligation) { + const obligationId = obligation.ref.resourceId; + yield* requireTenant(obligation.ref.tenantId, obligationId); + if (!Schema.is(ImportedCommittedObligationSchema)(obligation)) { + return yield* reject('INVALID_PERSISTED_OBLIGATION', obligationId); + } + yield* lockBindingCorrectionScopes( + transaction, + obligation.requirements.map((requirement) => ({ + exactSelectionMeaning: requirement.exactSelectionMeaning, + tenantId: obligation.ref.tenantId, + })), + ).pipe(Effect.mapError(unavailable)); + const inserted = yield* persistNew(obligation); + if (inserted) { + return { obligation, outcome: 'IMPORTED' as const }; + } + const [existingRow] = yield* findParent( + and( + eq(inventoryObligations.tenantId, scope.tenantId), + eq(inventoryObligations.originKind, 'IMPORTED_PROVEN_ORDER'), + eq(inventoryObligations.sourceSystem, obligation.origin.sourceSystem), + eq(inventoryObligations.sourceOrderId, obligation.origin.sourceOrderId), + eq(inventoryObligations.sourceObligationId, obligation.origin.sourceObligationId), + ), + ); + if (existingRow === undefined) { + return yield* reject('OBLIGATION_IDENTITY_CONFLICT', obligation.ref.resourceId); + } + const existing = yield* readRows(existingRow); + const [existingCanonical, requestedCanonical] = yield* Effect.all( + [canonicalObligation(existing), canonicalObligation(obligation)] as const, + { concurrency: 1 }, + ); + if (existing.ref.resourceId !== obligation.ref.resourceId || existingCanonical !== requestedCanonical) { + return yield* reject('SOURCE_LINEAGE_ALREADY_IMPORTED', obligation.ref.resourceId); + } + return { obligation, outcome: 'EXACT_REPLAY' as const }; + }); + + return { commitReservation, establishReservation, importCommitted, read }; +}; diff --git a/app/verticals/inventory/src/persistence/inventory-obligation-table.ts b/app/verticals/inventory/src/persistence/inventory-obligation-table.ts new file mode 100644 index 000000000..04687794a --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-obligation-table.ts @@ -0,0 +1,275 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { + check, + foreignKey, + index, + integer, + jsonb, + numeric, + text, + timestamp, + uniqueIndex, + uuid, +} from 'drizzle-orm/pg-core'; + +import type { CatalogSelection } from '@app/catalog/domain/catalog-selection-evidence'; +import type { StockItem } from '../../shared/domain/stock-item.ts'; + +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +export const inventoryObligations = inventorySchema.table.withRLS( + 'obligations', + { + obligationId: uuid('obligation_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + originKind: text('origin_kind').notNull(), + lifecycleMeaning: text('lifecycle_meaning').notNull(), + attemptId: text('attempt_id'), + acceptedOrderId: text('accepted_order_id'), + orderEvidenceRef: text('order_evidence_ref'), + orderEvidenceObservedAt: timestamp('order_evidence_observed_at', { withTimezone: true }), + sourceSystem: text('source_system'), + sourceOrderId: text('source_order_id'), + sourceObligationId: text('source_obligation_id'), + customerConfigurationId: text('customer_configuration_id').notNull(), + ownerConfigurationId: uuid('owner_configuration_id').notNull(), + authorityBackendKind: text('authority_backend_kind').notNull(), + authorityBackendId: text('authority_backend_id').notNull(), + authorityExactReservationCapability: text('authority_exact_reservation_capability').notNull(), + authoritySelectedAt: timestamp('authority_selected_at', { withTimezone: true }).notNull(), + authorityRevision: integer('authority_revision').default(1).notNull(), + authorityStockCorrectionCapability: text('authority_stock_correction_capability').notNull(), + establishedAt: timestamp('established_at', { withTimezone: true }).notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_obligations_scope_id_uk').on(table.tenantId, table.obligationId), + uniqueIndex('inventory_obligations_attempt_uk') + .on(table.tenantId, table.attemptId) + .where(sql`${table.originKind} = 'ORDER_COMMITMENT_ATTEMPT'`), + uniqueIndex('inventory_obligations_imported_lineage_uk') + .on(table.tenantId, table.sourceSystem, table.sourceOrderId, table.sourceObligationId) + .where(sql`${table.originKind} = 'IMPORTED_PROVEN_ORDER'`), + uniqueIndex('inventory_obligations_runtime_accepted_order_uk') + .on(table.tenantId, table.acceptedOrderId) + .where( + sql`${table.originKind} = 'ORDER_COMMITMENT_ATTEMPT' and ${table.lifecycleMeaning} = 'COMMITTED_OBLIGATION'`, + ), + foreignKey({ + columns: [table.tenantId, table.ownerConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_obligations_backend_configuration_fk', + }).onDelete('restrict'), + check( + 'inventory_obligations_origin_ck', + sql`(${table.originKind} = 'ORDER_COMMITMENT_ATTEMPT' and ${table.attemptId} is not null and ${table.sourceSystem} is null and ${table.sourceOrderId} is null and ${table.sourceObligationId} is null) or (${table.originKind} = 'IMPORTED_PROVEN_ORDER' and ${table.attemptId} is null and ${table.sourceSystem} is not null and ${table.sourceOrderId} is not null and ${table.sourceObligationId} is not null)`, + ), + check( + 'inventory_obligations_lifecycle_ck', + sql`(${table.originKind} = 'ORDER_COMMITMENT_ATTEMPT' and ((${table.lifecycleMeaning} = 'PROVISIONAL_RESERVATION' and ${table.acceptedOrderId} is null and ${table.orderEvidenceRef} is null and ${table.orderEvidenceObservedAt} is null) or (${table.lifecycleMeaning} = 'COMMITTED_OBLIGATION' and ${table.acceptedOrderId} is not null and ${table.orderEvidenceRef} is not null and ${table.orderEvidenceObservedAt} is not null))) or (${table.originKind} = 'IMPORTED_PROVEN_ORDER' and ${table.lifecycleMeaning} = 'COMMITTED_OBLIGATION' and ${table.acceptedOrderId} is not null and ${table.orderEvidenceRef} is not null and ${table.orderEvidenceObservedAt} is not null)`, + ), + check( + 'inventory_obligations_identity_text_ck', + sql`char_length(btrim(${table.customerConfigurationId})) between 1 and 300 and char_length(btrim(${table.authorityBackendId})) between 1 and 300 and (${table.attemptId} is null or char_length(btrim(${table.attemptId})) between 1 and 300) and (${table.acceptedOrderId} is null or char_length(btrim(${table.acceptedOrderId})) between 1 and 300) and (${table.orderEvidenceRef} is null or char_length(btrim(${table.orderEvidenceRef})) between 1 and 300) and (${table.sourceSystem} is null or char_length(btrim(${table.sourceSystem})) between 1 and 300) and (${table.sourceOrderId} is null or char_length(btrim(${table.sourceOrderId})) between 1 and 300) and (${table.sourceObligationId} is null or char_length(btrim(${table.sourceObligationId})) between 1 and 300)`, + ), + check( + 'inventory_obligations_authority_ck', + sql`${table.authorityBackendKind} in ('external_business_system', 'ontos_wms') and ${table.authorityExactReservationCapability} in ('SUPPORTED', 'UNSUPPORTED') and ${table.authorityStockCorrectionCapability} in ('SUPPORTED', 'UNSUPPORTED') and (${table.authorityBackendKind} <> 'ontos_wms' or (${table.authorityExactReservationCapability} = 'SUPPORTED' and ${table.authorityStockCorrectionCapability} = 'SUPPORTED')) and ${table.authorityRevision} = 1`, + ), + ...tenantRlsPolicies('inventory_obligations_tenant', table.tenantId), + ], +); + +export const inventoryObligationRequirements = inventorySchema.table.withRLS( + 'obligation_requirements', + { + tenantId: uuid('tenant_id').notNull(), + obligationId: uuid('obligation_id').notNull(), + purchaseDemandOccurrenceId: text('purchase_demand_occurrence_id').notNull(), + bindingId: uuid('binding_id').notNull(), + catalogSelection: jsonb('catalog_selection').$type().notNull(), + exactSelectionMeaningId: text('exact_selection_meaning_id').notNull(), + exactSelectionMeaningKind: text('exact_selection_meaning_kind').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockItemRevision: integer('stock_item_revision').notNull(), + stockItemSnapshot: jsonb('stock_item_snapshot').$type().notNull(), + requestedAmount: numeric('requested_amount', { precision: 38, scale: 9 }).notNull(), + unitModuleId: text('unit_module_id').notNull(), + unitResourceId: uuid('unit_resource_id').notNull(), + unitResourceType: text('unit_resource_type').notNull(), + unitTenantId: uuid('unit_tenant_id').notNull(), + }, + (table) => [ + uniqueIndex('inventory_obligation_requirements_occurrence_uk').on( + table.tenantId, + table.obligationId, + table.purchaseDemandOccurrenceId, + ), + index('inventory_obligation_requirements_binding_impact_idx').on( + table.tenantId, + table.bindingId, + table.stockItemId, + table.exactSelectionMeaningKind, + table.exactSelectionMeaningId, + ), + foreignKey({ + columns: [table.tenantId, table.obligationId], + foreignColumns: [inventoryObligations.tenantId, inventoryObligations.obligationId], + name: 'inventory_obligation_requirements_obligation_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_obligation_requirements_item_fk', + }).onDelete('restrict'), + check( + 'inventory_obligation_requirements_meaning_ck', + sql`char_length(btrim(${table.purchaseDemandOccurrenceId})) between 1 and 300 and char_length(btrim(${table.exactSelectionMeaningId})) between 1 and 300 and ${table.exactSelectionMeaningKind} in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION') and ${table.stockItemRevision} >= 1 and ${table.requestedAmount} >= 0 and ${table.unitModuleId} = 'commerce.catalog' and ${table.unitResourceType} = 'commerce.catalog.product-unit' and ${table.unitTenantId} = ${table.tenantId}`, + ), + ...tenantRlsPolicies('inventory_obligation_requirements_tenant', table.tenantId), + ], +); + +export const inventoryObligationAllocations = inventorySchema.table.withRLS( + 'obligation_allocations', + { + tenantId: uuid('tenant_id').notNull(), + obligationId: uuid('obligation_id').notNull(), + allocationId: text('allocation_id').notNull(), + purchaseDemandOccurrenceId: text('purchase_demand_occurrence_id').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockPositionId: uuid('stock_position_id').notNull(), + allocatedAmount: numeric('allocated_amount', { precision: 38, scale: 9 }).notNull(), + unitModuleId: text('unit_module_id').notNull(), + unitResourceId: uuid('unit_resource_id').notNull(), + unitResourceType: text('unit_resource_type').notNull(), + unitTenantId: uuid('unit_tenant_id').notNull(), + }, + (table) => [ + uniqueIndex('inventory_obligation_allocations_identity_uk').on( + table.tenantId, + table.obligationId, + table.allocationId, + ), + index('inventory_obligation_allocations_position_idx').on(table.tenantId, table.stockPositionId), + foreignKey({ + columns: [table.tenantId, table.obligationId, table.purchaseDemandOccurrenceId], + foreignColumns: [ + inventoryObligationRequirements.tenantId, + inventoryObligationRequirements.obligationId, + inventoryObligationRequirements.purchaseDemandOccurrenceId, + ], + name: 'inventory_obligation_allocations_requirement_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockPositionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_obligation_allocations_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_obligation_allocations_item_fk', + }).onDelete('restrict'), + check( + 'inventory_obligation_allocations_meaning_ck', + sql`char_length(btrim(${table.allocationId})) between 1 and 300 and ${table.allocatedAmount} >= 0 and ${table.unitModuleId} = 'commerce.catalog' and ${table.unitResourceType} = 'commerce.catalog.product-unit' and ${table.unitTenantId} = ${table.tenantId}`, + ), + ...tenantRlsPolicies('inventory_obligation_allocations_tenant', table.tenantId), + ], +); + +/** Migration validation for selected authority snapshots and exact Position Item/Unit/backend scope. */ +export const inventoryObligationScopeTriggerContract = { + constraintNames: { + allocation: 'inventory_obligation_allocations_exact_scope_ck', + authority: 'inventory_obligations_exact_authority_ck', + requirement: 'inventory_obligation_requirements_exact_item_unit_ck', + }, + functions: { + allocation: 'inventory.enforce_obligation_allocation_scope', + authority: 'inventory.enforce_obligation_authority', + requirement: 'inventory.enforce_obligation_requirement_scope', + }, + timing: 'BEFORE INSERT OR UPDATE', +} as const; + +/** Deferred whole-aggregate validation: every Requirement has one or more exact-cover Allocations. */ +export const inventoryObligationCoverageTriggerContract = { + constraintName: 'inventory_obligations_exact_requirement_coverage_ck', + functionName: 'inventory.enforce_obligation_requirement_coverage', + timing: 'AFTER INSERT DEFERRABLE INITIALLY DEFERRED', + triggerNames: [ + 'inventory_obligation_requirements_exact_coverage_trg', + 'inventory_obligation_allocations_exact_coverage_trg', + ], +} as const; + +/** Identity, origin, demand, and allocation snapshots never change after establishment/import. */ +export const inventoryObligationImmutabilityContract = { + functions: { + allocation: 'inventory.reject_obligation_allocation_mutation', + obligation: 'inventory.reject_obligation_origin_mutation', + requirement: 'inventory.reject_obligation_requirement_mutation', + }, + obligationImmutableColumns: [ + 'obligation_id', + 'tenant_id', + 'origin_kind', + 'attempt_id', + 'source_system', + 'source_order_id', + 'source_obligation_id', + 'customer_configuration_id', + 'owner_configuration_id', + 'authority_backend_kind', + 'authority_backend_id', + 'authority_exact_reservation_capability', + 'authority_selected_at', + 'authority_revision', + 'authority_stock_correction_capability', + 'established_at', + 'created_at', + ], + importedOriginKind: 'IMPORTED_PROVEN_ORDER', + importedProofImmutableColumns: [ + 'lifecycle_meaning', + 'accepted_order_id', + 'order_evidence_ref', + 'order_evidence_observed_at', + ], + rejectChildEvent: 'UPDATE OR DELETE', + rejectObligationDelete: true, + runtimeOriginKind: 'ORDER_COMMITMENT_ATTEMPT', + runtimeTransition: { + from: 'PROVISIONAL_RESERVATION', + requiredProofColumns: ['accepted_order_id', 'order_evidence_ref', 'order_evidence_observed_at'], + to: 'COMMITTED_OBLIGATION', + }, +} as const; + +/** The only mutable seam on a runtime Obligation is its authoritative Order-commit promotion. */ +export const inventoryObligationCommitTransitionContract = { + constraintName: 'inventory_obligations_immutable_origin_ck', + exactMutableColumns: ['lifecycle_meaning', 'accepted_order_id', 'order_evidence_ref', 'order_evidence_observed_at'], + functionName: 'inventory.reject_obligation_origin_mutation', + indexName: 'inventory_obligations_runtime_accepted_order_uk', + requiredProofColumns: ['accepted_order_id', 'order_evidence_ref', 'order_evidence_observed_at'], + timing: 'BEFORE UPDATE OR DELETE', + transition: { + from: 'PROVISIONAL_RESERVATION', + to: 'COMMITTED_OBLIGATION', + }, + triggerName: 'inventory_obligations_immutable_origin_trg', +} as const; + +export const INVENTORY_OBLIGATION_TABLES = [ + inventoryObligationAllocations, + inventoryObligationRequirements, + inventoryObligations, +] as const; diff --git a/app/verticals/inventory/src/persistence/inventory-source-assertion-repository.ts b/app/verticals/inventory/src/persistence/inventory-source-assertion-repository.ts new file mode 100644 index 000000000..30988fc76 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-source-assertion-repository.ts @@ -0,0 +1,211 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + InventorySourceAssertionRejected, + InventorySourceAssertionSchema, + InventorySourceAssertionUnavailable, + SourceCoverageEvidenceSchema, +} from '../../shared/domain/inventory-source-assertion.ts'; +import type { + InventorySourceAssertion, + InventorySourceAssertionId, + InventorySourceAssertionPersistence, +} from '../../shared/domain/inventory-source-assertion.ts'; +import { inventorySourceAssertionCoverage, inventorySourceAssertions } from './inventory-source-assertion-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const unavailable = (assertionId?: InventorySourceAssertionId, cause?: unknown) => { + const failure = + assertionId === undefined + ? new InventorySourceAssertionUnavailable({ + code: 'inventory_source_assertion_unavailable', + reason: 'Inventory Source Assertion dependency is temporarily unavailable', + retryable: true, + }) + : new InventorySourceAssertionUnavailable({ + assertionId, + code: 'inventory_source_assertion_unavailable', + reason: 'Inventory Source Assertion dependency is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const rejected = ( + assertionId: InventorySourceAssertionId, + reason: InventorySourceAssertionRejected['reason'], + cause?: unknown, +) => { + const failure = new InventorySourceAssertionRejected({ + assertionId, + code: 'inventory_source_assertion_rejected', + reason, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const mapWriteError = (assertionId: InventorySourceAssertionId, cause: unknown) => { + const uniqueViolationSqlState = ['23', '505'].join(''); + const identityConflict = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + [ + 'source_assertions_pkey', + 'inventory_source_assertions_tenant_id_uk', + 'inventory_source_assertion_coverage_pk', + ].includes(constraint ?? ''), + ); + return Option.isSome(identityConflict) + ? rejected(assertionId, 'ASSERTION_ID_CONFLICT', cause) + : unavailable(assertionId, cause); +}; + +const orderingValue = (assertion: InventorySourceAssertion) => + Match.value(assertion.orderingEvidence).pipe( + Match.tag('SOURCE_REVISION', ({ revision }) => revision), + Match.tag('OWNER_ORDER_KEY', ({ key }) => key), + Match.exhaustive, + ); + +const assertionValues = (assertion: InventorySourceAssertion) => ({ + assertionId: assertion.assertionId, + assertionJson: assertion, + authorityConfigurationId: assertion.authorityConfiguration.configurationId, + businessObservedAt: DateTime.toDateUtc(DateTime.makeUnsafe(assertion.businessObservedAt)), + customerConfigurationId: assertion.customerConfigurationId, + factMeaning: assertion.factMeaning, + issuerAuthority: assertion.issuerAuthority, + issuerBackendId: assertion.issuer.backendId, + issuerBackendKind: assertion.issuer.backendKind, + itemCorrelationId: assertion.itemCorrelationRef.resourceId, + locationCorrelationId: assertion.locationCorrelationRef.resourceId, + orderingEvidenceKind: assertion.orderingEvidence._tag, + orderingEvidenceValue: orderingValue(assertion), + ownerEvidenceRef: assertion.ownerEvidenceRef, + positionId: assertion.positionRef.resourceId, + quantityAmount: assertion.quantity.amount, + receivedAt: DateTime.toDateUtc(DateTime.makeUnsafe(assertion.receivedAt)), + sourceReference: assertion.sourceReference, + stockItemId: assertion.stockItemRef.resourceId, + stockLocationId: assertion.stockLocationRef.resourceId, + tenantId: assertion.positionRef.tenantId, + unitModuleId: assertion.quantity.unitRef.moduleId, + unitResourceId: assertion.quantity.unitRef.resourceId, + unitResourceType: assertion.quantity.unitRef.resourceType, + unitTenantId: assertion.quantity.unitRef.tenantId, +}); + +const coverageMatches = ( + expected: InventorySourceAssertion['coverage'], + actual: readonly (typeof inventorySourceAssertionCoverage.$inferSelect)[], +) => + expected.length === actual.length && + expected.every((evidence) => + actual.some( + (row) => + row.assertionId === evidence.assertionId && + row.effectId === evidence.effectId && + row.ownerEvidenceRef === evidence.ownerEvidenceRef && + row.relation === evidence.relation, + ), + ); + +export const inventorySourceAssertionPersistenceForScope = ( + transaction: ScopedTransaction, + scope: Pick, +): InventorySourceAssertionPersistence => { + const findById: InventorySourceAssertionPersistence['findById'] = Effect.fn( + 'InventorySourceAssertionPersistence.findById', + )(function* findSourceAssertionById(assertionId) { + return yield* Effect.gen(function* readSourceAssertion() { + const [row] = yield* transaction + .select() + .from(inventorySourceAssertions) + .where( + and( + eq(inventorySourceAssertions.tenantId, scope.tenantId), + eq(inventorySourceAssertions.assertionId, assertionId), + ), + ) + .limit(1); + if (row === undefined) { + return Option.none(); + } + const coverage = yield* transaction + .select() + .from(inventorySourceAssertionCoverage) + .where( + and( + eq(inventorySourceAssertionCoverage.tenantId, scope.tenantId), + eq(inventorySourceAssertionCoverage.assertionId, assertionId), + ), + ); + if (!coverageMatches(row.assertionJson.coverage, coverage)) { + return yield* unavailable(assertionId); + } + const decodedCoverage = yield* Schema.decodeUnknownEffect(Schema.Array(SourceCoverageEvidenceSchema))( + coverage.map((entry) => ({ + assertionId: entry.assertionId, + effectId: entry.effectId, + ownerEvidenceRef: entry.ownerEvidenceRef, + relation: entry.relation, + })), + ); + const decoded = yield* Schema.decodeEffect(InventorySourceAssertionSchema)({ + ...row.assertionJson, + coverage: decodedCoverage, + }); + return Option.some(decoded); + }).pipe( + Effect.mapError((cause) => + Schema.is(InventorySourceAssertionUnavailable)(cause) ? cause : unavailable(assertionId, cause), + ), + ); + }); + + const append: InventorySourceAssertionPersistence['append'] = Effect.fn('InventorySourceAssertionPersistence.append')( + function* appendSourceAssertion(assertion) { + if (assertion.positionRef.tenantId !== scope.tenantId || !Schema.is(InventorySourceAssertionSchema)(assertion)) { + return yield* rejected(assertion.assertionId, 'INVALID_ASSERTION'); + } + const [inserted] = yield* transaction + .insert(inventorySourceAssertions) + .values(assertionValues(assertion)) + .returning() + .pipe(Effect.mapError((cause) => mapWriteError(assertion.assertionId, cause))); + if (inserted === undefined) { + return yield* unavailable(assertion.assertionId); + } + if (assertion.coverage.length > 0) { + yield* transaction + .insert(inventorySourceAssertionCoverage) + .values( + assertion.coverage.map((coverage) => ({ + assertionId: coverage.assertionId, + effectId: coverage.effectId, + ownerEvidenceRef: coverage.ownerEvidenceRef, + relation: coverage.relation, + tenantId: scope.tenantId, + })), + ) + .pipe(Effect.mapError((cause) => mapWriteError(assertion.assertionId, cause))); + } + return yield* Schema.decodeEffect(InventorySourceAssertionSchema)(inserted.assertionJson).pipe( + Effect.mapError((cause) => unavailable(assertion.assertionId, cause)), + ); + }, + ); + + return Object.freeze({ append, findById }); +}; diff --git a/app/verticals/inventory/src/persistence/inventory-source-assertion-table.ts b/app/verticals/inventory/src/persistence/inventory-source-assertion-table.ts new file mode 100644 index 000000000..5e744a661 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-source-assertion-table.ts @@ -0,0 +1,180 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, jsonb, primaryKey, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { InventorySourceAssertion } from '../../shared/domain/inventory-source-assertion.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryExternalStockCorrelations } from './external-stock-correlation-table.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; +import { inventoryStockLocations } from './stock-location-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +const INVENTORY_SOURCE_ASSERTIONS_TABLE = 'inventory.source_assertions'; +const INVENTORY_SOURCE_ASSERTION_COVERAGE_TABLE = 'inventory.source_assertion_coverage'; + +export const inventorySourceAssertionImmutabilityContract = { + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE OR DELETE', + functionName: 'inventory.reject_source_assertion_mutation', + tables: [INVENTORY_SOURCE_ASSERTIONS_TABLE, INVENTORY_SOURCE_ASSERTION_COVERAGE_TABLE], + timing: 'BEFORE', + triggerNames: ['inventory_source_assertions_immutable_trg', 'inventory_source_assertion_coverage_immutable_trg'], +} as const; + +/** The migration verifier rechecks JSON provenance against these exact relational scope columns. */ +export const inventorySourceAssertionScopeVerifierContract = { + constraintNames: { + assertion: 'inventory_source_assertions_exact_scope_ck', + coverage: 'inventory_source_assertion_coverage_exact_scope_ck', + }, + coverageTable: INVENTORY_SOURCE_ASSERTION_COVERAGE_TABLE, + coverageTriggerName: 'inventory_source_assertion_coverage_exact_scope_trg', + event: 'INSERT', + functionName: 'inventory.enforce_source_assertion_exact_scope', + table: INVENTORY_SOURCE_ASSERTIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_source_assertions_exact_scope_trg', +} as const; + +export const inventorySourceAssertionCoverageCompletenessContract = { + assertionJsonPath: 'coverage', + childTable: 'inventory.source_assertion_coverage', + constraintTriggerName: 'inventory_source_assertion_coverage_complete_trg', + effectRequiredState: 'APPLIED', + functionName: 'inventory.enforce_source_assertion_coverage_complete', + mode: 'DEFERRABLE INITIALLY DEFERRED', + parentTable: 'inventory.source_assertions', + relation: 'BIJECTION', +} as const; + +export const inventorySourceAssertions = inventorySchema.table.withRLS( + 'source_assertions', + { + assertionId: uuid('assertion_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + authorityConfigurationId: uuid('authority_configuration_id').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + issuerAuthority: text('issuer_authority').notNull(), + itemCorrelationId: uuid('item_correlation_id').notNull(), + locationCorrelationId: uuid('location_correlation_id').notNull(), + positionId: uuid('position_id').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockLocationId: uuid('stock_location_id').notNull(), + unitModuleId: text('unit_module_id').notNull(), + unitResourceId: uuid('unit_resource_id').notNull(), + unitResourceType: text('unit_resource_type').notNull(), + unitTenantId: uuid('unit_tenant_id').notNull(), + quantityAmount: text('quantity_amount').notNull(), + factMeaning: text('fact_meaning').notNull(), + businessObservedAt: timestamp('business_observed_at', { withTimezone: true }).notNull(), + orderingEvidenceKind: text('ordering_evidence_kind').notNull(), + orderingEvidenceValue: text('ordering_evidence_value').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + sourceReference: text('source_reference').notNull(), + receivedAt: timestamp('received_at', { withTimezone: true }).notNull(), + assertionJson: jsonb('assertion_json').$type().notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_source_assertions_tenant_id_uk').on(table.tenantId, table.assertionId), + index('inventory_source_assertions_position_observed_idx').on( + table.tenantId, + table.positionId, + table.businessObservedAt, + ), + foreignKey({ + columns: [table.tenantId, table.authorityConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_source_assertions_authority_configuration_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_source_assertions_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_source_assertions_item_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockLocationId], + foreignColumns: [inventoryStockLocations.tenantId, inventoryStockLocations.stockLocationId], + name: 'inventory_source_assertions_location_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.itemCorrelationId], + foreignColumns: [inventoryExternalStockCorrelations.tenantId, inventoryExternalStockCorrelations.correlationId], + name: 'inventory_source_assertions_item_correlation_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.locationCorrelationId], + foreignColumns: [inventoryExternalStockCorrelations.tenantId, inventoryExternalStockCorrelations.correlationId], + name: 'inventory_source_assertions_location_correlation_fk', + }).onDelete('restrict'), + check( + 'inventory_source_assertions_meaning_ck', + sql`${table.factMeaning} = 'ABSOLUTE_PHYSICAL_ON_HAND' and ${table.issuerBackendKind} = 'external_business_system'`, + ), + check( + 'inventory_source_assertions_authority_ck', + sql`${table.issuerAuthority} in ('SELECTED_BACKEND', 'HISTORICAL_PRE_CUTOVER_ISSUER')`, + ), + check( + 'inventory_source_assertions_unit_ck', + sql`${table.unitModuleId} = 'commerce.catalog' and ${table.unitResourceType} = 'commerce.catalog.product-unit' and ${table.unitTenantId} = ${table.tenantId}`, + ), + check( + 'inventory_source_assertions_text_ck', + sql`length(btrim(${table.customerConfigurationId})) between 1 and 300 and length(btrim(${table.issuerBackendId})) between 1 and 300 and length(btrim(${table.quantityAmount})) between 1 and 50 and length(btrim(${table.orderingEvidenceValue})) between 1 and 300 and length(btrim(${table.ownerEvidenceRef})) between 1 and 300 and length(btrim(${table.sourceReference})) between 1 and 300`, + ), + check( + 'inventory_source_assertions_ordering_ck', + sql`${table.orderingEvidenceKind} in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')`, + ), + ...tenantRlsPolicies('inventory_source_assertions_tenant', table.tenantId), + ], +); + +export const inventorySourceAssertionCoverage = inventorySchema.table.withRLS( + 'source_assertion_coverage', + { + tenantId: uuid('tenant_id').notNull(), + assertionId: uuid('assertion_id').notNull(), + effectId: uuid('effect_id').notNull(), + relation: text('relation').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.assertionId, table.effectId], + name: 'inventory_source_assertion_coverage_pk', + }), + foreignKey({ + columns: [table.tenantId, table.assertionId], + foreignColumns: [inventorySourceAssertions.tenantId, inventorySourceAssertions.assertionId], + name: 'inventory_source_assertion_coverage_assertion_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.effectId], + foreignColumns: [inventoryPhysicalStockEffects.tenantId, inventoryPhysicalStockEffects.effectId], + name: 'inventory_source_assertion_coverage_effect_fk', + }).onDelete('restrict'), + check( + 'inventory_source_assertion_coverage_relation_ck', + sql`${table.relation} in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')`, + ), + check( + 'inventory_source_assertion_coverage_evidence_ck', + sql`length(btrim(${table.ownerEvidenceRef})) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_source_assertion_coverage_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/inventory-source-conflict-repository.ts b/app/verticals/inventory/src/persistence/inventory-source-conflict-repository.ts new file mode 100644 index 000000000..f1cf454a8 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-source-conflict-repository.ts @@ -0,0 +1,162 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, desc, eq } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + InventorySourceConflictNotFound, + InventorySourceConflictRejected, + InventorySourceConflictSchema, + InventorySourceConflictUnavailable, + StockPositionFactConflictScopeSchema, + inventorySourceConflictsHaveSameOpenEvidence, +} from '../../shared/domain/inventory-source-conflict.ts'; +import type { InventorySourceConflict } from '../../shared/domain/inventory-source-conflict.ts'; +import type { InventorySourceConflictRef } from '../../shared/resources/inventory-source-conflict.ts'; +import type { InventorySourceConflictPersistence } from '../services/inventory-source-conflict.service.ts'; +import { inventorySourceConflictRevisions } from './inventory-source-conflict-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const unavailable = (reason: string, cause?: unknown) => { + const failure = new InventorySourceConflictUnavailable({ + code: 'inventory_source_conflict_unavailable', + reason, + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const rejected = (conflictRef: InventorySourceConflictRef, reason: InventorySourceConflictRejected['reason']) => + new InventorySourceConflictRejected({ code: 'inventory_source_conflict_rejected', conflictRef, reason }); + +const notFound = (conflictRef: InventorySourceConflictRef) => + new InventorySourceConflictNotFound({ code: 'inventory_source_conflict_not_found', conflictRef }); + +const mapWriteError = (conflictRef: InventorySourceConflictRef, cause: unknown) => { + const uniqueViolationSqlState = ['23', '505'].join(''); + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_source_conflict_revisions_pk', + ); + return Option.isSome(identity) + ? rejected(conflictRef, 'CONFLICT_REVISION_CONFLICT') + : unavailable('Inventory Source Conflict evidence could not be persisted', cause); +}; + +const valuesFor = (conflict: InventorySourceConflict) => ({ + conflictId: conflict.conflictRef.resourceId, + conflictJson: conflict, + conflictType: conflict.conflictType, + currentTruth: conflict.currentTruth, + customerConfigurationId: conflict.scope.customerConfigurationId, + detectedAt: DateTime.toDateUtc(DateTime.makeUnsafe(conflict.detectedAt)), + factMeaning: Schema.is(StockPositionFactConflictScopeSchema)(conflict.scope) ? conflict.scope.factMeaning : null, + positionId: Schema.is(StockPositionFactConflictScopeSchema)(conflict.scope) + ? conflict.scope.positionRef.resourceId + : null, + resolvedAt: + conflict.status === 'RESOLVED' ? DateTime.toDateUtc(DateTime.makeUnsafe(conflict.resolution.resolvedAt)) : null, + revision: conflict.revision, + status: conflict.status, + tenantId: conflict.conflictRef.tenantId, +}); + +const decode = (row: typeof inventorySourceConflictRevisions.$inferSelect) => + Schema.decodeEffect(InventorySourceConflictSchema)(row.conflictJson).pipe( + Effect.mapError((cause) => unavailable('Stored Inventory Source Conflict evidence is invalid', cause)), + ); + +export const inventorySourceConflictPersistenceForScope = ( + transaction: ScopedTransaction, + scope: Pick, +): InventorySourceConflictPersistence => { + const readRows = (conflictRef: InventorySourceConflictRef, lock: boolean) => { + const query = transaction + .select() + .from(inventorySourceConflictRevisions) + .where( + and( + eq(inventorySourceConflictRevisions.tenantId, scope.tenantId), + eq(inventorySourceConflictRevisions.conflictId, conflictRef.resourceId), + ), + ) + .orderBy(desc(inventorySourceConflictRevisions.revision)) + .limit(1); + return (lock ? query.for('update') : query).pipe( + Effect.mapError((cause) => unavailable('Inventory Source Conflict evidence is unavailable', cause)), + ); + }; + + const findLatest: InventorySourceConflictPersistence['findLatest'] = Effect.fn( + 'InventorySourceConflictPersistence.findLatest', + )(function* findLatestConflict(conflictRef) { + if (conflictRef.tenantId !== scope.tenantId) { + return yield* unavailable('Inventory Source Conflict Tenant scope does not match the trusted scope'); + } + const [row] = yield* readRows(conflictRef, false); + return row === undefined ? Option.none() : Option.some(yield* decode(row)); + }); + + const appendOpen: InventorySourceConflictPersistence['appendOpen'] = Effect.fn( + 'InventorySourceConflictPersistence.appendOpen', + )(function* appendOpenConflict(conflict) { + if (conflict.conflictRef.tenantId !== scope.tenantId || conflict.revision !== 1 || conflict.status !== 'OPEN') { + return yield* rejected(conflict.conflictRef, 'TENANT_SCOPE_MISMATCH'); + } + const [inserted] = yield* transaction + .insert(inventorySourceConflictRevisions) + .values(valuesFor(conflict)) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError((cause) => mapWriteError(conflict.conflictRef, cause))); + if (inserted !== undefined) { + const decoded = yield* decode(inserted); + return decoded.status === 'OPEN' + ? decoded + : yield* unavailable('New Inventory Source Conflict was not stored as OPEN'); + } + const [existing] = yield* readRows(conflict.conflictRef, true); + if (existing === undefined) { + return yield* unavailable('Conflicting Inventory Source Conflict identity could not be read'); + } + const decoded = yield* decode(existing); + return decoded.status === 'OPEN' && inventorySourceConflictsHaveSameOpenEvidence(decoded, conflict) + ? decoded + : yield* rejected(conflict.conflictRef, 'CONFLICT_ID_CONFLICT'); + }); + + const appendResolution: InventorySourceConflictPersistence['appendResolution'] = Effect.fn( + 'InventorySourceConflictPersistence.appendResolution', + )(function* appendResolutionRevision(expected, resolved) { + const [row] = yield* readRows(expected.conflictRef, true); + if (row === undefined) { + return yield* notFound(expected.conflictRef); + } + const latest = yield* decode(row); + if (latest.status === 'RESOLVED') { + return yield* rejected(expected.conflictRef, 'ALREADY_RESOLVED'); + } + if (latest.revision !== expected.revision || !inventorySourceConflictsHaveSameOpenEvidence(latest, expected)) { + return yield* rejected(expected.conflictRef, 'CONFLICT_REVISION_CONFLICT'); + } + const [inserted] = yield* transaction + .insert(inventorySourceConflictRevisions) + .values(valuesFor(resolved)) + .returning() + .pipe(Effect.mapError((cause) => mapWriteError(resolved.conflictRef, cause))); + if (inserted === undefined) { + return yield* unavailable('Inventory Source Conflict resolution insert returned no row'); + } + const decoded = yield* decode(inserted); + return decoded.status === 'RESOLVED' + ? decoded + : yield* unavailable('Inventory Source Conflict resolution was not terminal'); + }); + + return Object.freeze({ appendOpen, appendResolution, findLatest }); +}; diff --git a/app/verticals/inventory/src/persistence/inventory-source-conflict-table.ts b/app/verticals/inventory/src/persistence/inventory-source-conflict-table.ts new file mode 100644 index 000000000..ffb4a2027 --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-source-conflict-table.ts @@ -0,0 +1,82 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, jsonb, primaryKey, text, timestamp, uuid } from 'drizzle-orm/pg-core'; + +import type { InventorySourceConflict } from '../../shared/domain/inventory-source-conflict.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +const INVENTORY_SOURCE_CONFLICT_REVISIONS_TABLE = 'inventory.source_conflict_revisions'; + +/** Every lifecycle transition is a new immutable revision; resolution never rewrites source evidence. */ +export const inventorySourceConflictRevisionContract = { + errorCondition: 'check_violation', + event: 'INSERT OR UPDATE OR DELETE', + functionName: 'inventory.enforce_source_conflict_revision', + immutableTriggerName: 'inventory_source_conflict_revisions_immutable_trg', + sequenceTriggerName: 'inventory_source_conflict_revisions_sequence_trg', + table: INVENTORY_SOURCE_CONFLICT_REVISIONS_TABLE, + timing: 'BEFORE', +} as const; + +/** Migration verification rechecks the complete JSON evidence against these relational scope columns. */ +export const inventorySourceConflictScopeVerifierContract = { + event: 'INSERT', + functionName: 'inventory.enforce_source_conflict_exact_scope', + table: INVENTORY_SOURCE_CONFLICT_REVISIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_source_conflict_revisions_exact_scope_trg', +} as const; + +export const inventorySourceConflictRevisions = inventorySchema.table.withRLS( + 'source_conflict_revisions', + { + tenantId: uuid('tenant_id').notNull(), + conflictId: uuid('conflict_id').notNull(), + revision: integer('revision').notNull(), + status: text('status').notNull(), + conflictType: text('conflict_type').notNull(), + currentTruth: text('current_truth').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + positionId: uuid('position_id'), + factMeaning: text('fact_meaning'), + detectedAt: timestamp('detected_at', { withTimezone: true }).notNull(), + resolvedAt: timestamp('resolved_at', { withTimezone: true }), + conflictJson: jsonb('conflict_json').$type().notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.conflictId, table.revision], + name: 'inventory_source_conflict_revisions_pk', + }), + index('inventory_source_conflict_latest_idx').on(table.tenantId, table.conflictId, table.revision), + index('inventory_source_conflict_position_idx').on(table.tenantId, table.positionId, table.status), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_source_conflict_revisions_position_fk', + }).onDelete('restrict'), + check('inventory_source_conflict_revision_ck', sql`${table.revision} in (1, 2)`), + check( + 'inventory_source_conflict_status_ck', + sql`(${table.revision} = 1 and ${table.status} = 'OPEN' and ${table.currentTruth} = 'INDETERMINATE' and ${table.resolvedAt} is null) or (${table.revision} = 2 and ${table.status} = 'RESOLVED' and ${table.currentTruth} in ('CURRENT', 'CONFIGURATION_SINGULAR') and ${table.resolvedAt} is not null and ${table.resolvedAt} >= ${table.detectedAt})`, + ), + check( + 'inventory_source_conflict_type_ck', + sql`${table.conflictType} in ('CORRELATION', 'FACT_VALUE', 'BACKEND_CONFIGURATION', 'ASSERTION_INTEGRITY')`, + ), + check( + 'inventory_source_conflict_scope_ck', + sql`(${table.conflictType} in ('BACKEND_CONFIGURATION', 'CORRELATION') and ${table.positionId} is null and ${table.factMeaning} is null) or (${table.conflictType} in ('FACT_VALUE', 'ASSERTION_INTEGRITY') and ${table.positionId} is not null and ${table.factMeaning} = 'ABSOLUTE_PHYSICAL_ON_HAND')`, + ), + check( + 'inventory_source_conflict_customer_configuration_ck', + sql`${table.customerConfigurationId} = btrim(${table.customerConfigurationId}) and length(${table.customerConfigurationId}) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_source_conflict_revisions_tenant', table.tenantId), + ], +); + +/* oxlint-enable perfectionist/sort-objects */ diff --git a/app/verticals/inventory/src/persistence/inventory-source-import-ledger-repository.ts b/app/verticals/inventory/src/persistence/inventory-source-import-ledger-repository.ts new file mode 100644 index 000000000..28a70aebe --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-source-import-ledger-repository.ts @@ -0,0 +1,143 @@ +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import { Effect, Match, Option, Schema } from 'effect'; + +import { + InventorySourceImportLedgerEntrySchema, + InventorySourceImportUnavailable, +} from '../../shared/domain/inventory-source-import-outcome.ts'; +import type { + InventorySourceImportLedgerEntry, + InventorySourceImportLedgerPersistence, +} from '../../shared/domain/inventory-source-import-outcome.ts'; +import type { InventorySourceAssertionProposal } from '../../shared/domain/inventory-source-assertion.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; +import { inventorySourceImportLedger } from './inventory-source-import-ledger-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const unavailable = (cause?: unknown) => { + const failure = new InventorySourceImportUnavailable({ + code: 'inventory_source_import_unavailable', + reason: 'Inventory Source Import persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const orderingValue = (proposal: InventorySourceAssertionProposal) => + Match.value(proposal.orderingEvidence).pipe( + Match.tag('SOURCE_REVISION', ({ revision }) => revision), + Match.tag('OWNER_ORDER_KEY', ({ key }) => key), + Match.exhaustive, + ); + +const rowValues = (entry: InventorySourceImportLedgerEntry) => ({ + actionInvocationId: entry.actionInvocationId, + assertionId: entry.proposal.assertionId, + customerConfigurationId: entry.proposal.customerConfigurationId, + factMeaning: entry.proposal.factMeaning, + issuerBackendId: entry.proposal.issuer.backendId, + issuerBackendKind: entry.proposal.issuer.backendKind, + itemIndex: entry.itemIndex, + orderingEvidenceKind: entry.proposal.orderingEvidence._tag, + orderingEvidenceValue: orderingValue(entry.proposal), + outcomeJson: entry.outcome, + positionId: entry.proposal.positionRef.resourceId, + proposalJson: entry.proposal, + sourceReference: entry.proposal.sourceReference, + status: entry.outcome.status, + tenantId: entry.proposal.positionRef.tenantId, +}); + +const decodeEntry = (row: typeof inventorySourceImportLedger.$inferSelect) => + Schema.decodeEffect(InventorySourceImportLedgerEntrySchema)({ + actionInvocationId: row.actionInvocationId, + itemIndex: row.itemIndex, + outcome: row.outcomeJson, + proposal: row.proposalJson, + }).pipe(Effect.mapError(unavailable)); + +export const inventorySourceImportLedgerPersistenceForScope = ( + transaction: ScopedTransaction, + scope: Pick, +): InventorySourceImportLedgerPersistence => { + const findByInvocationItem: InventorySourceImportLedgerPersistence['findByInvocationItem'] = Effect.fn( + 'InventorySourceImportLedger.findByInvocationItem', + )(function* findByInvocationItem(actionInvocationId, itemIndex) { + const [row] = yield* transaction + .select() + .from(inventorySourceImportLedger) + .where( + and( + eq(inventorySourceImportLedger.tenantId, scope.tenantId), + eq(inventorySourceImportLedger.actionInvocationId, actionInvocationId), + eq(inventorySourceImportLedger.itemIndex, itemIndex), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + return row === undefined ? Option.none() : Option.some(yield* decodeEntry(row)); + }); + + const lockAndReadAcceptedHistory: InventorySourceImportLedgerPersistence['lockAndReadAcceptedHistory'] = Effect.fn( + 'InventorySourceImportLedger.lockAndReadAcceptedHistory', + )(function* lockAndReadAcceptedHistory(proposal) { + if (proposal.positionRef.tenantId !== scope.tenantId) { + return []; + } + yield* transaction + .select({ positionId: inventoryStockPositions.stockPositionId }) + .from(inventoryStockPositions) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.stockPositionId, proposal.positionRef.resourceId), + ), + ) + .for('update') + .pipe(Effect.mapError(unavailable)); + const rows = yield* transaction + .select() + .from(inventorySourceImportLedger) + .where( + and( + eq(inventorySourceImportLedger.tenantId, scope.tenantId), + eq(inventorySourceImportLedger.customerConfigurationId, proposal.customerConfigurationId), + eq(inventorySourceImportLedger.issuerBackendKind, proposal.issuer.backendKind), + eq(inventorySourceImportLedger.issuerBackendId, proposal.issuer.backendId), + eq(inventorySourceImportLedger.factMeaning, proposal.factMeaning), + eq(inventorySourceImportLedger.positionId, proposal.positionRef.resourceId), + eq(inventorySourceImportLedger.status, 'ACCEPTED'), + ), + ) + .pipe(Effect.mapError(unavailable)); + // oxlint-disable-next-line unicorn/no-array-method-this-argument -- Effect.forEach's curried overload takes concurrency options, not Array#forEach thisArg; expires: 2027-03-31. + return yield* Effect.forEach((row: (typeof rows)[number]) => decodeEntry(row), { concurrency: 1 })(rows); + }); + + const append: InventorySourceImportLedgerPersistence['append'] = Effect.fn('InventorySourceImportLedger.append')( + function* append(entry) { + if ( + entry.proposal.positionRef.tenantId !== scope.tenantId || + !Schema.is(InventorySourceImportLedgerEntrySchema)(entry) + ) { + return yield* unavailable(); + } + const [inserted] = yield* transaction + .insert(inventorySourceImportLedger) + .values(rowValues(entry)) + .returning() + .pipe(Effect.mapError(unavailable)); + if (inserted === undefined) { + return yield* unavailable(); + } + return yield* decodeEntry(inserted); + }, + ); + + return Object.freeze({ append, findByInvocationItem, lockAndReadAcceptedHistory }); +}; diff --git a/app/verticals/inventory/src/persistence/inventory-source-import-ledger-table.ts b/app/verticals/inventory/src/persistence/inventory-source-import-ledger-table.ts new file mode 100644 index 000000000..0fd513f6c --- /dev/null +++ b/app/verticals/inventory/src/persistence/inventory-source-import-ledger-table.ts @@ -0,0 +1,115 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { + check, + foreignKey, + index, + integer, + jsonb, + primaryKey, + text, + timestamp, + uniqueIndex, + uuid, +} from 'drizzle-orm/pg-core'; + +import type { InventorySourceImportOutcome } from '../../shared/domain/inventory-source-import-outcome.ts'; +import type { InventorySourceAssertionProposal } from '../../shared/domain/inventory-source-assertion.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +export const inventorySourceImportLedger = inventorySchema.table.withRLS( + 'source_import_ledger', + { + tenantId: uuid('tenant_id').notNull(), + actionInvocationId: uuid('action_invocation_id').notNull(), + itemIndex: integer('item_index').notNull(), + assertionId: uuid('assertion_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + factMeaning: text('fact_meaning').notNull(), + positionId: uuid('position_id').notNull(), + sourceReference: text('source_reference').notNull(), + orderingEvidenceKind: text('ordering_evidence_kind').notNull(), + orderingEvidenceValue: text('ordering_evidence_value').notNull(), + status: text('status').notNull(), + proposalJson: jsonb('proposal_json').$type().notNull(), + outcomeJson: jsonb('outcome_json').$type().notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.actionInvocationId, table.itemIndex], + name: 'inventory_source_import_ledger_pk', + }), + index('inventory_source_import_ledger_stream_idx').on( + table.tenantId, + table.customerConfigurationId, + table.issuerBackendKind, + table.issuerBackendId, + table.factMeaning, + table.positionId, + table.recordedAt, + ), + uniqueIndex('inventory_source_import_accepted_assertion_uk') + .on(table.tenantId, table.assertionId) + .where(sql`${table.status} = 'ACCEPTED'`), + uniqueIndex('inventory_source_import_accepted_source_identity_uk') + .on( + table.tenantId, + table.customerConfigurationId, + table.issuerBackendKind, + table.issuerBackendId, + table.factMeaning, + table.positionId, + table.sourceReference, + ) + .where(sql`${table.status} = 'ACCEPTED'`), + uniqueIndex('inventory_source_import_accepted_revision_uk') + .on( + table.tenantId, + table.customerConfigurationId, + table.issuerBackendKind, + table.issuerBackendId, + table.factMeaning, + table.positionId, + table.orderingEvidenceKind, + table.orderingEvidenceValue, + ) + .where(sql`${table.status} = 'ACCEPTED'`), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_source_import_ledger_position_fk', + }).onDelete('restrict'), + check('inventory_source_import_ledger_item_index_ck', sql`${table.itemIndex} >= 0`), + check( + 'inventory_source_import_ledger_meaning_ck', + sql`${table.factMeaning} = 'ABSOLUTE_PHYSICAL_ON_HAND' and ${table.issuerBackendKind} = 'external_business_system'`, + ), + check( + 'inventory_source_import_ledger_ordering_ck', + sql`${table.orderingEvidenceKind} in ('SOURCE_REVISION', 'OWNER_ORDER_KEY')`, + ), + check( + 'inventory_source_import_ledger_status_ck', + sql`${table.status} in ('ACCEPTED', 'DUPLICATE', 'STALE', 'REJECTED', 'INDETERMINATE')`, + ), + check( + 'inventory_source_import_ledger_text_ck', + sql`length(btrim(${table.customerConfigurationId})) between 1 and 300 and length(btrim(${table.issuerBackendId})) between 1 and 300 and length(btrim(${table.sourceReference})) between 1 and 300 and length(btrim(${table.orderingEvidenceValue})) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_source_import_ledger_tenant', table.tenantId), + ], +); + +/** The migration enforces immutable evidence and exact JSON/column scope, including accepted assertion existence. */ +export const inventorySourceImportLedgerVerifierContract = { + acceptedAssertionForeignKey: 'inventory_source_import_ledger_accepted_assertion_fk', + functionName: 'inventory.enforce_source_import_ledger_exact_scope', + immutableTriggerName: 'inventory_source_import_ledger_immutable_trg', + scopeTriggerName: 'inventory_source_import_ledger_exact_scope_trg', + table: 'inventory.source_import_ledger', +} as const; diff --git a/app/verticals/inventory/src/persistence/physical-stock-effect-repository.ts b/app/verticals/inventory/src/persistence/physical-stock-effect-repository.ts new file mode 100644 index 000000000..f290d1a3a --- /dev/null +++ b/app/verticals/inventory/src/persistence/physical-stock-effect-repository.ts @@ -0,0 +1,231 @@ +import { defineScopedRoutine } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, eq, sql } from 'drizzle-orm'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + PhysicalStockEffectIdSchema, + PhysicalStockEffectRecordSchema, + PhysicalStockEffectUnavailable, +} from '../../shared/domain/physical-stock-effect.ts'; +import type { + PhysicalStockEffectId, + PhysicalStockEffectRecord, + PhysicalStockEffectRequest, +} from '../../shared/domain/physical-stock-effect.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const workerRowSchema = Schema.Struct({ record: PhysicalStockEffectRecordSchema }); +export const readPhysicalStockEffectForWorkerRoutine = defineScopedRoutine({ + name: 'read_physical_stock_effect_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.read-physical-stock-effect-for-worker', + schema: 'inventory', +}); +export const finalizePhysicalStockEffectForWorkerRoutine = defineScopedRoutine({ + name: 'finalize_physical_stock_effect_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.finalize-physical-stock-effect-for-worker', + schema: 'inventory', +}); + +export interface PhysicalStockEffectPersistence { + readonly createOrRead: ( + request: PhysicalStockEffectRequest, + ) => Effect.Effect< + { readonly effect: PhysicalStockEffectRecord; readonly outcome: 'EXISTING' | 'INSERTED' }, + PhysicalStockEffectUnavailable + >; + readonly read: ( + effectId: PhysicalStockEffectId, + ) => Effect.Effect, PhysicalStockEffectUnavailable>; + readonly saveTerminal: ( + expected: PhysicalStockEffectRequest, + terminal: Exclude, + ) => Effect.Effect; +} + +const unavailable = (effectId: PhysicalStockEffectId | undefined, cause?: unknown) => { + const failure = + effectId === undefined + ? new PhysicalStockEffectUnavailable({ + code: 'physical_stock_effect_unavailable', + reason: 'Physical stock effect persistence is temporarily unavailable', + retryable: true, + }) + : new PhysicalStockEffectUnavailable({ + code: 'physical_stock_effect_unavailable', + effectId, + reason: 'Physical stock effect persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const candidateForRow = (row: typeof inventoryPhysicalStockEffects.$inferSelect) => { + if (row.state === 'APPLIED') { + return { _tag: row.state, evidence: row.evidenceJson, request: row.requestJson }; + } + if (row.state === 'REJECTED' || row.state === 'INDETERMINATE') { + return { _tag: row.state, reason: row.terminalReason, request: row.requestJson }; + } + return { _tag: 'REQUESTED', request: row.requestJson }; +}; + +const decodeRow = (row: typeof inventoryPhysicalStockEffects.$inferSelect) => { + const candidate = candidateForRow(row); + return Schema.decodeEffect(PhysicalStockEffectIdSchema)(row.effectId).pipe( + Effect.mapError((cause) => unavailable(undefined, cause)), + Effect.flatMap((decodedEffectId) => + Schema.decodeUnknownEffect(PhysicalStockEffectRecordSchema)(candidate).pipe( + Effect.mapError((cause) => unavailable(decodedEffectId, cause)), + ), + ), + ); +}; + +const terminalValues = (terminal: Exclude) => + Match.value(terminal).pipe( + Match.tag('APPLIED', ({ evidence }) => ({ + evidenceJson: evidence, + state: 'APPLIED' as const, + terminalReason: null, + updatedAt: sql`now()`, + })), + Match.tag('REJECTED', ({ reason }) => ({ + evidenceJson: null, + state: 'REJECTED' as const, + terminalReason: reason, + updatedAt: sql`now()`, + })), + Match.tag('INDETERMINATE', ({ reason }) => ({ + evidenceJson: null, + state: 'INDETERMINATE' as const, + terminalReason: reason, + updatedAt: sql`now()`, + })), + Match.exhaustive, + ); + +export const physicalStockEffectPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): PhysicalStockEffectPersistence => { + const readRows = (effectId: PhysicalStockEffectId) => + transaction + .select() + .from(inventoryPhysicalStockEffects) + .where( + and( + eq(inventoryPhysicalStockEffects.tenantId, scope.tenantId), + eq(inventoryPhysicalStockEffects.effectId, effectId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(effectId, cause))); + + const read: PhysicalStockEffectPersistence['read'] = (effectId) => + readRows(effectId).pipe( + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeRow(row).pipe(Effect.asSome))), + ); + + const createOrRead: PhysicalStockEffectPersistence['createOrRead'] = Effect.fn( + 'PhysicalStockEffectPersistence.createOrRead', + )(function* createOrReadEffect(request) { + if (request.positionRef.tenantId !== scope.tenantId) { + return yield* unavailable(request.effectId); + } + const [inserted] = yield* transaction + .insert(inventoryPhysicalStockEffects) + .values({ + backendConfigurationId: request.backendConfigurationRef.resourceId, + backendId: request.backendId, + customerConfigurationId: request.customerConfigurationId, + effectId: request.effectId, + kind: request.kind, + legalEntityId: request.legalEntityId, + positionId: request.positionRef.resourceId, + quantityAmount: request.quantity.amount, + requestedAt: DateTime.toDateUtc(DateTime.makeUnsafe(request.requestedAt)), + requestJson: request, + state: 'REQUESTED', + stockItemId: request.stockItemRef.resourceId, + stockLocationId: request.stockLocationRef.resourceId, + tenantId: scope.tenantId, + unitResourceId: request.quantity.unitRef.resourceId, + }) + .onConflictDoNothing({ target: inventoryPhysicalStockEffects.effectId }) + .returning() + .pipe(Effect.mapError((cause) => unavailable(request.effectId, cause))); + if (inserted !== undefined) { + return { effect: yield* decodeRow(inserted), outcome: 'INSERTED' as const }; + } + const existing = yield* read(request.effectId); + return yield* Option.match(existing, { + onNone: () => Effect.fail(unavailable(request.effectId)), + onSome: (effect) => Effect.succeed({ effect, outcome: 'EXISTING' as const }), + }); + }); + + const saveTerminal: PhysicalStockEffectPersistence['saveTerminal'] = Effect.fn( + 'PhysicalStockEffectPersistence.saveTerminal', + )(function* saveTerminalEffect(expected, terminal) { + const [updated] = yield* transaction + .update(inventoryPhysicalStockEffects) + .set(terminalValues(terminal)) + .where( + and( + eq(inventoryPhysicalStockEffects.tenantId, scope.tenantId), + eq(inventoryPhysicalStockEffects.effectId, expected.effectId), + eq(inventoryPhysicalStockEffects.state, 'REQUESTED'), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => unavailable(expected.effectId, cause))); + if (updated !== undefined) { + return yield* decodeRow(updated); + } + const current = yield* read(expected.effectId); + return yield* Effect.fromOption(current).pipe(Effect.mapError((cause) => unavailable(expected.effectId, cause))); + }); + + return Object.freeze({ createOrRead, read, saveTerminal }); +}; + +/** Worker adapter over the Core-verified, lifetime-bound owner scope. */ +export const physicalStockEffectPersistenceForWorkerScope = ( + scope: OutboxWorkerLegalEntityScope, +): PhysicalStockEffectPersistence => ({ + createOrRead: (request) => Effect.fail(unavailable(request.effectId)), + read: (effectId) => + scope.routineInvoker.invoke(readPhysicalStockEffectForWorkerRoutine, [effectId]).pipe( + Effect.mapError((cause) => unavailable(effectId, cause)), + Effect.map(([row]) => (row === undefined ? Option.none() : Option.some(row.record))), + ), + saveTerminal: (expected, terminal) => + scope.routineInvoker.invoke(finalizePhysicalStockEffectForWorkerRoutine, [expected.effectId, terminal]).pipe( + Effect.mapError((cause) => unavailable(expected.effectId, cause)), + Effect.flatMap(([row]) => + row === undefined ? Effect.fail(unavailable(expected.effectId)) : Effect.succeed(row.record), + ), + ), +}); diff --git a/app/verticals/inventory/src/persistence/physical-stock-effect-table.ts b/app/verticals/inventory/src/persistence/physical-stock-effect-table.ts new file mode 100644 index 000000000..982a281a9 --- /dev/null +++ b/app/verticals/inventory/src/persistence/physical-stock-effect-table.ts @@ -0,0 +1,96 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { + PhysicalStockEffectEvidence, + PhysicalStockEffectRequest, +} from '../../shared/domain/physical-stock-effect.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +export const inventoryPhysicalStockEffectInsertionVerifierContract = { + constraintName: 'inventory_physical_stock_effects_exact_scope_ck', + event: 'INSERT', + functionName: 'inventory.enforce_physical_stock_effect_scope', + table: 'inventory.physical_stock_effects', + timing: 'BEFORE', + triggerName: 'inventory_physical_stock_effects_exact_scope_trg', +} as const; + +export const inventoryPhysicalStockEffectIdentityTriggerContract = { + columns: [ + 'effect_id', + 'tenant_id', + 'kind', + 'customer_configuration_id', + 'legal_entity_id', + 'position_id', + 'stock_item_id', + 'stock_location_id', + 'unit_resource_id', + 'quantity_amount', + 'backend_configuration_id', + 'backend_id', + 'request_json', + 'requested_at', + ], + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE OR DELETE', + functionName: 'inventory.reject_physical_stock_effect_identity_mutation', + terminalConstraintName: 'inventory_physical_stock_effects_terminal_transition_ck', + table: 'inventory.physical_stock_effects', + timing: 'BEFORE', + triggerName: 'inventory_physical_stock_effects_immutable_identity_trg', +} as const; + +export const inventoryPhysicalStockEffects = inventorySchema.table.withRLS( + 'physical_stock_effects', + { + effectId: uuid('effect_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + kind: text('kind').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + legalEntityId: uuid('legal_entity_id').notNull(), + positionId: uuid('position_id').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockLocationId: uuid('stock_location_id').notNull(), + unitResourceId: uuid('unit_resource_id').notNull(), + quantityAmount: text('quantity_amount').notNull(), + backendConfigurationId: uuid('backend_configuration_id').notNull(), + backendId: text('backend_id').notNull(), + state: text('state').default('REQUESTED').notNull(), + requestJson: jsonb('request_json').$type().notNull(), + evidenceJson: jsonb('evidence_json').$type(), + terminalReason: text('terminal_reason'), + requestedAt: timestamp('requested_at', { withTimezone: true }).notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_physical_stock_effects_tenant_id_uk').on(table.tenantId, table.effectId), + index('inventory_physical_stock_effects_position_idx').on(table.tenantId, table.positionId, table.requestedAt), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_physical_stock_effects_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.backendConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_physical_stock_effects_backend_configuration_fk', + }).onDelete('restrict'), + check('inventory_physical_stock_effects_kind_ck', sql`${table.kind} in ('RECEIPT', 'ISSUE')`), + check( + 'inventory_physical_stock_effects_state_ck', + sql`${table.state} in ('REQUESTED', 'APPLIED', 'REJECTED', 'INDETERMINATE')`, + ), + check( + 'inventory_physical_stock_effects_terminal_ck', + sql`(${table.state} = 'REQUESTED' and ${table.evidenceJson} is null and ${table.terminalReason} is null) or (${table.state} = 'APPLIED' and ${table.evidenceJson} is not null and ${table.terminalReason} is null) or (${table.state} in ('REJECTED', 'INDETERMINATE') and ${table.evidenceJson} is null and ${table.terminalReason} is not null)`, + ), + ...tenantRlsPolicies('inventory_physical_stock_effects_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/reservation-allocation-candidate-repository.ts b/app/verticals/inventory/src/persistence/reservation-allocation-candidate-repository.ts new file mode 100644 index 000000000..072139972 --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-allocation-candidate-repository.ts @@ -0,0 +1,251 @@ +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq, isNull, ne, or } from 'drizzle-orm'; +import { Effect, Match, Option } from 'effect'; + +import { InventoryReservationCreateUnavailable } from '../../shared/domain/inventory-reservation-create.ts'; +import type { + ReservationCreateAllocation, + ReservationCreateEffect, +} from '../../shared/domain/inventory-reservation-create.ts'; +import { commerceScopeMatchesRelation } from '../../shared/domain/stock-sharing-eligibility.ts'; +import type { ReservationAuthorityEffectIdSchema } from '../../shared/domain/reservation-issuer-failure-fields.ts'; +import type { + ReservationAllocationCandidateReader, + ReservationPositionEligibility, +} from '../services/reservation-allocation-planner.ts'; +import { inventoryObligationAllocations, inventoryObligations } from './inventory-obligation-table.ts'; +import { listUnresolvedReservationCreateEffects } from './reservation-create-effect-repository.ts'; +import { inventoryReservationReleaseEffects } from './reservation-release-effect-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; +import { stockPositionPersistenceForScope } from './stock-position-repository.ts'; +import { stockSharingEligibilityPersistenceForScope } from './stock-sharing-eligibility-repository.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const unavailable = (effectId: typeof ReservationAuthorityEffectIdSchema.Type, reason: string, cause?: unknown) => { + const failure = new InventoryReservationCreateUnavailable({ + code: 'inventory_reservation_create_unavailable', + effectId, + reason, + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +interface Decimal { + readonly coefficient: bigint; + readonly scale: number; +} + +const decimal = (value: string): Decimal => { + const [integer = '0', fraction = ''] = value.split('.'); + return { coefficient: BigInt(`${integer}${fraction}`), scale: fraction.length }; +}; + +const add = (left: Decimal, right: Decimal): Decimal => { + const scale = Math.max(left.scale, right.scale); + return { + coefficient: + left.coefficient * 10n ** BigInt(scale - left.scale) + right.coefficient * 10n ** BigInt(scale - right.scale), + scale, + }; +}; + +const amount = ({ coefficient, scale }: Decimal): string => { + const digits = coefficient.toString().padStart(scale + 1, '0'); + if (scale === 0) { + return digits; + } + const integer = digits.slice(0, -scale); + const fraction = digits.slice(-scale).replace(/0+$/u, ''); + return fraction.length === 0 ? integer : `${integer}.${fraction}`; +}; + +const activeAllocations = (record: ReservationCreateEffect): readonly ReservationCreateAllocation[] => + Match.value(record).pipe( + Match.tag('RECONCILIATION_REQUIRED', ({ constrainedAllocations }) => constrainedAllocations), + Match.tag('INDETERMINATE', ({ possibleConstrainedAllocations }) => possibleConstrainedAllocations), + Match.tag('REQUESTED', ({ request }) => + request.reservation.requirements.flatMap(({ allocations }) => + allocations.map(({ positionRef, ...allocation }) => ({ ...allocation, stockPositionRef: positionRef })), + ), + ), + Match.tag('ESTABLISHED', () => []), + Match.tag('RESOLVED_NO_RESERVATION', () => []), + Match.exhaustive, + ); + +const sumAmounts = (values: Iterable) => { + let total: Decimal = { coefficient: 0n, scale: 0 }; + for (const value of values) { + total = add(total, decimal(value)); + } + return total; +}; + +const unresolvedAmountsForPosition = ( + unresolved: readonly ReservationCreateEffect[], + stockPositionId: string, +): string[] => { + const values: string[] = []; + for (const effect of unresolved) { + for (const allocation of activeAllocations(effect)) { + if (allocation.stockPositionRef.resourceId === stockPositionId) { + values.push(allocation.quantity.amount); + } + } + } + return values; +}; + +const buildCandidate = Effect.fn('ReservationAllocationCandidateReader.buildCandidate')(function* buildCandidate({ + effectId, + positions, + scope, + stockPositionId, + transaction, + unresolved, +}: { + readonly effectId: typeof ReservationAuthorityEffectIdSchema.Type; + readonly positions: ReturnType; + readonly scope: OperationalScope; + readonly stockPositionId: string; + readonly transaction: ScopedTransaction; + readonly unresolved: readonly ReservationCreateEffect[]; +}) { + const ref = { + moduleId: 'commerce.inventory' as const, + resourceId: stockPositionId, + resourceType: 'commerce.inventory.stock-position' as const, + tenantId: scope.tenantId, + }; + const [current, obligationRows] = yield* Effect.all( + [ + positions.read(ref).pipe( + Effect.mapError((cause) => unavailable(effectId, 'Stock Position candidate is unavailable', cause)), + Effect.flatMap( + Option.match({ + onNone: () => Effect.fail(unavailable(effectId, 'Locked Stock Position candidate disappeared')), + onSome: Effect.succeed, + }), + ), + ), + transaction + .select({ amount: inventoryObligationAllocations.allocatedAmount }) + .from(inventoryObligationAllocations) + .innerJoin( + inventoryObligations, + and( + eq(inventoryObligations.tenantId, inventoryObligationAllocations.tenantId), + eq(inventoryObligations.obligationId, inventoryObligationAllocations.obligationId), + ), + ) + .leftJoin( + inventoryReservationReleaseEffects, + and( + eq(inventoryReservationReleaseEffects.tenantId, inventoryObligationAllocations.tenantId), + eq(inventoryReservationReleaseEffects.reservationId, inventoryObligationAllocations.obligationId), + ), + ) + .where( + and( + eq(inventoryObligationAllocations.tenantId, scope.tenantId), + eq(inventoryObligationAllocations.stockPositionId, stockPositionId), + eq(inventoryObligations.lifecycleMeaning, 'PROVISIONAL_RESERVATION'), + or( + isNull(inventoryReservationReleaseEffects.releaseEffectRecordId), + ne(inventoryReservationReleaseEffects.currentState, 'RELEASED'), + ), + ), + ) + .pipe( + Effect.mapError((cause) => + unavailable(effectId, 'Current successful Reservation Allocations are unavailable', cause), + ), + ), + ], + { concurrency: 2 }, + ); + const obligationReserved = sumAmounts(obligationRows.map(({ amount: value }) => value)); + const unresolvedReserved = sumAmounts(unresolvedAmountsForPosition(unresolved, stockPositionId)); + return { + position: current, + reservedAmount: amount(add(obligationReserved, unresolvedReserved)), + }; +}); + +export const reservationAllocationCandidateReaderForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): ReservationAllocationCandidateReader => { + const positions = stockPositionPersistenceForScope(transaction, scope); + + return { + lockCurrentForItem: Effect.fn('ReservationAllocationCandidateReader.lockCurrentForItem')( + function* lockCurrentForItem(effectId, authority, demand) { + if (authority.tenantId !== scope.tenantId || demand.stockItem.stockItemRef.tenantId !== scope.tenantId) { + return yield* unavailable(effectId, 'Reservation candidate scope does not match trusted Tenant'); + } + const rows = yield* transaction + .select({ stockPositionId: inventoryStockPositions.stockPositionId }) + .from(inventoryStockPositions) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.customerConfigurationId, authority.customerConfigurationId), + eq(inventoryStockPositions.ownerConfigurationId, authority.configurationId), + eq(inventoryStockPositions.stockItemId, demand.stockItem.stockItemRef.resourceId), + eq(inventoryStockPositions.lifecycleState, 'CURRENT'), + ), + ) + .orderBy(inventoryStockPositions.stockPositionId) + .for('update') + .pipe(Effect.mapError((cause) => unavailable(effectId, 'Stock Position candidates are unavailable', cause))); + // oxlint-disable-next-line effect-native/no-sequential-independent-yields -- Candidate rows must be locked before unresolved-effect availability is snapshotted; expires: 2027-03-31. + const unresolved = yield* listUnresolvedReservationCreateEffects(transaction, scope).pipe( + Effect.mapError((cause) => + unavailable(effectId, 'Unresolved Reservation constraints are unavailable', cause), + ), + ); + return yield* Effect.forEach( + rows, + ({ stockPositionId }) => + buildCandidate({ effectId, positions, scope, stockPositionId, transaction, unresolved }), + { concurrency: 1 }, + ); + }, + ), + }; +}; + +export const reservationPositionEligibilityForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): ReservationPositionEligibility => { + const persistence = stockSharingEligibilityPersistenceForScope(transaction, scope); + return { + isEligible: (effectId, authority, position, context) => + persistence + .listCurrent({ + customerConfigurationId: authority.customerConfigurationId, + ownerConfigurationRef: { + moduleId: 'commerce.inventory', + resourceId: authority.configurationId, + resourceType: 'commerce.inventory.inventory-backend-configuration', + tenantId: authority.tenantId, + }, + positionRef: position.ref, + }) + .pipe( + Effect.mapError((cause) => unavailable(effectId, 'Stock Sharing Eligibility evidence is unavailable', cause)), + Effect.map((relations) => + relations.some( + (relation) => relation.lifecycle === 'CURRENT' && commerceScopeMatchesRelation(relation.subject, context), + ), + ), + ), + }; +}; diff --git a/app/verticals/inventory/src/persistence/reservation-confirmation-repository.ts b/app/verticals/inventory/src/persistence/reservation-confirmation-repository.ts new file mode 100644 index 000000000..dcc66df2e --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-confirmation-repository.ts @@ -0,0 +1,416 @@ +import { defineScopedRoutine, findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, asc, eq, or } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + ReservationConfirmationRejected, + ReservationConfirmationSchema, + ReservationConfirmationUnavailable, +} from '../../shared/domain/reservation-confirmation.ts'; +import type { + ReservationConfirmation, + ReservationConfirmationError, + ReservationConfirmationPersistence, +} from '../../shared/domain/reservation-confirmation.ts'; +import type { ReservationConfirmationRef } from '../../shared/resources/reservation-confirmation.ts'; +import { currentBindingRequirementsMatch, lockBindingCorrectionScopes } from './binding-correction-serialization.ts'; +import { + inventoryReservationConfirmationHistory, + inventoryReservationConfirmationScopeContract, + inventoryReservationConfirmations, +} from './reservation-confirmation-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type ConfirmationRow = typeof inventoryReservationConfirmations.$inferSelect; +type HistoryRow = typeof inventoryReservationConfirmationHistory.$inferSelect; +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; + +const confirmationRecordRowSchema = Schema.Struct({ record: ReservationConfirmationSchema }); +const confirmationWriteRowSchema = Schema.Struct({ + outcome: Schema.Literals(['EXISTING', 'INSERTED']), + record: ReservationConfirmationSchema, +}); + +export const findReservationConfirmationByRefForWorkerRoutine = defineScopedRoutine({ + name: 'find_reservation_confirmation_by_ref_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + ], + resultSchema: confirmationRecordRowSchema, + routineKey: 'inventory.find-reservation-confirmation-by-ref-for-worker', + schema: 'inventory', +}); + +export const findReservationConfirmationByAttemptForWorkerRoutine = defineScopedRoutine({ + name: 'find_reservation_confirmation_by_attempt_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + { source: 'input', type: 'text' }, + ], + resultSchema: confirmationRecordRowSchema, + routineKey: 'inventory.find-reservation-confirmation-by-attempt-for-worker', + schema: 'inventory', +}); + +export const createOrReadReservationConfirmationForWorkerRoutine = defineScopedRoutine({ + name: 'create_or_read_reservation_confirmation_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: confirmationWriteRowSchema, + routineKey: 'inventory.create-or-read-reservation-confirmation-for-worker', + schema: 'inventory', +}); + +export const readReservationConfirmationHistoryForWorkerRoutine = defineScopedRoutine({ + name: 'read_reservation_confirmation_history_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + ], + resultSchema: confirmationRecordRowSchema, + routineKey: 'inventory.read-reservation-confirmation-history-for-worker', + schema: 'inventory', +}); + +export const saveReservationConfirmationRevisionForWorkerRoutine = defineScopedRoutine({ + name: 'save_reservation_confirmation_revision_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'jsonb' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: confirmationRecordRowSchema, + routineKey: 'inventory.save-reservation-confirmation-revision-for-worker', + schema: 'inventory', +}); + +const unavailable = (cause?: unknown) => { + const failure = new ReservationConfirmationUnavailable({ + code: 'reservation_confirmation_unavailable', + reason: 'Reservation Confirmation persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const rejected = (reason: ReservationConfirmationRejected['reason'], confirmationRef?: ReservationConfirmationRef) => + confirmationRef === undefined + ? new ReservationConfirmationRejected({ code: 'reservation_confirmation_rejected', reason }) + : new ReservationConfirmationRejected({ code: 'reservation_confirmation_rejected', confirmationRef, reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); + +export const mapReservationConfirmationWriteError = (cause: unknown): ReservationConfirmationError => { + const revision = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_reservation_confirmation_history_revision_uk', + ); + if (Option.isSome(revision)) { + return rejected('REVISION_CONFLICT'); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + [ + 'reservation_confirmations_pkey', + 'inventory_reservation_confirmations_scope_id_uk', + 'inventory_reservation_confirmations_authority_effect_uk', + ].includes(constraint ?? ''), + ); + if (Option.isSome(identity)) { + return rejected('CONFIRMATION_IDENTITY_CONFLICT'); + } + const sibling = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_reservation_confirmations_reservation_attempt_uk', + ); + if (Option.isSome(sibling)) { + return rejected('SIBLING_CONFIRMATION_FORBIDDEN'); + } + const { constraintNames } = inventoryReservationConfirmationScopeContract; + const scopeConstraints = new Set([ + constraintNames.authority, + constraintNames.reservation, + constraintNames.snapshot, + ]); + const scope = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === foreignKeyViolationSqlState && + [ + 'inventory_reservation_confirmations_reservation_fk', + 'inventory_reservation_confirmations_backend_configuration_fk', + ].includes(constraint ?? '')) || + (code === checkViolationSqlState && scopeConstraints.has(constraint ?? '')), + ); + return Option.isSome(scope) ? rejected('RESERVATION_SCOPE_MISMATCH') : unavailable(cause); +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const valuesFor = (confirmation: ReservationConfirmation) => ({ + attemptId: confirmation.reservation.origin.attemptId, + authorityEffectId: confirmation.authorityEvidence.effectId, + confirmationId: confirmation.ref.resourceId, + currentHealthState: confirmation.health.state, + currentRevision: confirmation.revision, + expiresAt: instantAsDate(confirmation.expiresAt), + issuedAt: instantAsDate(confirmation.issuedAt), + issuerBackendId: confirmation.authorityEvidence.issuer.backendId, + issuerBackendKind: confirmation.authorityEvidence.issuer.backend, + ownerConfigurationId: confirmation.reservation.authority.configurationId, + ownerEvidenceRef: confirmation.issuanceRank.ownerEvidenceRef, + reservationId: confirmation.reservation.ref.resourceId, + snapshot: confirmation, + tenantId: confirmation.ref.tenantId, + updatedAt: instantAsDate(confirmation.health.observation.effectiveAt), +}); + +const decodeSnapshot = (snapshot: ReservationConfirmation) => + Schema.decodeEffect(ReservationConfirmationSchema)(snapshot).pipe(Effect.mapError(unavailable)); + +export const decodeReservationConfirmationHistoryRows = (rows: readonly HistoryRow[]) => + Effect.forEach(rows, ({ snapshot }) => decodeSnapshot(snapshot), { concurrency: 1 }); + +export const reservationConfirmationPersistenceForScope = ( + transaction: ScopedTransaction, + operationScope: OperationalScope, +): ReservationConfirmationPersistence => { + const requireTenant = ( + tenantId: string, + confirmationRef?: ReservationConfirmationRef, + ): Effect.Effect => + tenantId === operationScope.tenantId + ? Effect.void + : Effect.fail(rejected('TENANT_SCOPE_MISMATCH', confirmationRef)); + + const decodeRow = (row: ConfirmationRow) => decodeSnapshot(row.snapshot); + + const appendHistory = (confirmation: ReservationConfirmation) => + transaction + .insert(inventoryReservationConfirmationHistory) + .values({ + confirmationId: confirmation.ref.resourceId, + healthState: confirmation.health.state, + revision: confirmation.revision, + snapshot: confirmation, + tenantId: confirmation.ref.tenantId, + transitionedAt: instantAsDate(confirmation.health.observation.effectiveAt), + }) + .pipe(Effect.mapError(mapReservationConfirmationWriteError), Effect.asVoid); + + const findByRef: ReservationConfirmationPersistence['findByRef'] = Effect.fn( + 'ReservationConfirmationPersistence.findByRef', + )(function* findConfirmation(ref) { + yield* requireTenant(ref.tenantId, ref); + const [row] = yield* transaction + .select() + .from(inventoryReservationConfirmations) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, operationScope.tenantId), + eq(inventoryReservationConfirmations.confirmationId, ref.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }); + + const findByReservationAttempt: ReservationConfirmationPersistence['findByReservationAttempt'] = Effect.fn( + 'ReservationConfirmationPersistence.findByReservationAttempt', + )(function* findConfirmationByReservationAttempt(reservationRef, attemptId) { + yield* requireTenant(reservationRef.tenantId); + const [row] = yield* transaction + .select() + .from(inventoryReservationConfirmations) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, operationScope.tenantId), + eq(inventoryReservationConfirmations.reservationId, reservationRef.resourceId), + eq(inventoryReservationConfirmations.attemptId, attemptId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }); + + const createOrRead: ReservationConfirmationPersistence['createOrRead'] = Effect.fn( + 'ReservationConfirmationPersistence.createOrRead', + )(function* createOrReadConfirmation(candidate) { + yield* requireTenant(candidate.ref.tenantId, candidate.ref); + const bindingRequirements = candidate.reservation.requirements.map((requirement) => ({ + bindingId: requirement.bindingRef.resourceId, + exactSelectionMeaning: requirement.exactSelectionMeaning, + stockItemId: requirement.stockItem.stockItemRef.resourceId, + tenantId: candidate.ref.tenantId, + })); + yield* lockBindingCorrectionScopes(transaction, bindingRequirements).pipe(Effect.mapError(unavailable)); + const [existingBeforeInsert] = yield* transaction + .select() + .from(inventoryReservationConfirmations) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, operationScope.tenantId), + or( + eq(inventoryReservationConfirmations.confirmationId, candidate.ref.resourceId), + and( + eq(inventoryReservationConfirmations.reservationId, candidate.reservation.ref.resourceId), + eq(inventoryReservationConfirmations.attemptId, candidate.reservation.origin.attemptId), + ), + eq(inventoryReservationConfirmations.authorityEffectId, candidate.authorityEvidence.effectId), + ), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + if (existingBeforeInsert !== undefined) { + return { confirmation: yield* decodeRow(existingBeforeInsert), outcome: 'EXISTING' as const }; + } + const bindingsRemainCurrent = yield* currentBindingRequirementsMatch(transaction, bindingRequirements).pipe( + Effect.mapError(unavailable), + ); + if (!bindingsRemainCurrent) { + return yield* rejected('RESERVATION_SCOPE_MISMATCH', candidate.ref); + } + const [inserted] = yield* transaction + .insert(inventoryReservationConfirmations) + .values(valuesFor(candidate)) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError(mapReservationConfirmationWriteError)); + if (inserted !== undefined) { + const persisted = yield* decodeRow(inserted); + yield* appendHistory(persisted); + return { confirmation: persisted, outcome: 'INSERTED' as const }; + } + const [existing] = yield* transaction + .select() + .from(inventoryReservationConfirmations) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, operationScope.tenantId), + or( + eq(inventoryReservationConfirmations.confirmationId, candidate.ref.resourceId), + and( + eq(inventoryReservationConfirmations.reservationId, candidate.reservation.ref.resourceId), + eq(inventoryReservationConfirmations.attemptId, candidate.reservation.origin.attemptId), + ), + eq(inventoryReservationConfirmations.authorityEffectId, candidate.authorityEvidence.effectId), + ), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + if (existing === undefined) { + return yield* unavailable(); + } + return { confirmation: yield* decodeRow(existing), outcome: 'EXISTING' as const }; + }); + + const readHistory: ReservationConfirmationPersistence['readHistory'] = (ref) => + requireTenant(ref.tenantId, ref).pipe( + Effect.flatMap(() => + transaction + .select() + .from(inventoryReservationConfirmationHistory) + .where( + and( + eq(inventoryReservationConfirmationHistory.tenantId, operationScope.tenantId), + eq(inventoryReservationConfirmationHistory.confirmationId, ref.resourceId), + ), + ) + .orderBy(asc(inventoryReservationConfirmationHistory.revision)) + .pipe(Effect.mapError(unavailable), Effect.flatMap(decodeReservationConfirmationHistoryRows)), + ), + ); + + const saveRevision: ReservationConfirmationPersistence['saveRevision'] = Effect.fn( + 'ReservationConfirmationPersistence.saveRevision', + )(function* saveConfirmationRevision({ current, next }) { + yield* requireTenant(current.ref.tenantId, current.ref); + const [row] = yield* transaction + .update(inventoryReservationConfirmations) + .set(valuesFor(next)) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, operationScope.tenantId), + eq(inventoryReservationConfirmations.confirmationId, current.ref.resourceId), + eq(inventoryReservationConfirmations.currentRevision, current.revision), + ), + ) + .returning() + .pipe(Effect.mapError(mapReservationConfirmationWriteError)); + if (row === undefined) { + return yield* rejected('REVISION_CONFLICT', current.ref); + } + const persisted = yield* decodeRow(row); + yield* appendHistory(persisted); + return persisted; + }); + + return Object.freeze({ createOrRead, findByRef, findByReservationAttempt, readHistory, saveRevision }); +}; + +export const reservationConfirmationPersistenceForWorkerScope = ( + scope: OutboxWorkerLegalEntityScope, +): ReservationConfirmationPersistence => ({ + createOrRead: (candidate) => + scope.routineInvoker.invoke(createOrReadReservationConfirmationForWorkerRoutine, [candidate]).pipe( + Effect.mapError(mapReservationConfirmationWriteError), + Effect.flatMap(([row]) => + row === undefined + ? Effect.fail(unavailable()) + : Effect.succeed({ confirmation: row.record, outcome: row.outcome }), + ), + ), + findByRef: (ref) => + scope.routineInvoker.invoke(findReservationConfirmationByRefForWorkerRoutine, [ref.resourceId]).pipe( + Effect.mapError((cause) => unavailable(cause)), + Effect.map(([row]) => Option.fromNullishOr(row?.record)), + ), + findByReservationAttempt: (reservationRef, attemptId) => + scope.routineInvoker + .invoke(findReservationConfirmationByAttemptForWorkerRoutine, [reservationRef.resourceId, attemptId]) + .pipe( + Effect.mapError((cause) => unavailable(cause)), + Effect.map(([row]) => Option.fromNullishOr(row?.record)), + ), + readHistory: (ref) => + scope.routineInvoker.invoke(readReservationConfirmationHistoryForWorkerRoutine, [ref.resourceId]).pipe( + Effect.mapError((cause) => unavailable(cause)), + Effect.map((rows) => rows.map(({ record }) => record)), + ), + saveRevision: ({ current, next }) => + scope.routineInvoker.invoke(saveReservationConfirmationRevisionForWorkerRoutine, [current, next]).pipe( + Effect.mapError(mapReservationConfirmationWriteError), + Effect.flatMap(([row]) => + row === undefined ? Effect.fail(rejected('REVISION_CONFLICT', current.ref)) : Effect.succeed(row.record), + ), + ), +}); diff --git a/app/verticals/inventory/src/persistence/reservation-confirmation-table.ts b/app/verticals/inventory/src/persistence/reservation-confirmation-table.ts new file mode 100644 index 000000000..8f4edc00b --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-confirmation-table.ts @@ -0,0 +1,147 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { ReservationConfirmation } from '../../shared/domain/reservation-confirmation.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryObligations } from './inventory-obligation-table.ts'; + +export const inventoryReservationConfirmations = inventorySchema.table.withRLS( + 'reservation_confirmations', + { + confirmationId: uuid('confirmation_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + reservationId: uuid('reservation_id').notNull(), + attemptId: text('attempt_id').notNull(), + ownerConfigurationId: uuid('owner_configuration_id').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + authorityEffectId: text('authority_effect_id').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + issuedAt: timestamp('issued_at', { withTimezone: true }).notNull(), + expiresAt: timestamp('expires_at', { withTimezone: true }).notNull(), + currentHealthState: text('current_health_state').default('VALID').notNull(), + currentRevision: integer('current_revision').default(1).notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_reservation_confirmations_scope_id_uk').on(table.tenantId, table.confirmationId), + uniqueIndex('inventory_reservation_confirmations_reservation_attempt_uk').on( + table.tenantId, + table.reservationId, + table.attemptId, + ), + uniqueIndex('inventory_reservation_confirmations_authority_effect_uk').on(table.tenantId, table.authorityEffectId), + index('inventory_reservation_confirmations_health_rank_idx').on( + table.tenantId, + table.currentHealthState, + table.issuedAt, + table.ownerEvidenceRef, + ), + foreignKey({ + columns: [table.tenantId, table.reservationId], + foreignColumns: [inventoryObligations.tenantId, inventoryObligations.obligationId], + name: 'inventory_reservation_confirmations_reservation_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.ownerConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_reservation_confirmations_backend_configuration_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_confirmations_meaning_ck', + sql`char_length(btrim(${table.attemptId})) between 1 and 300 and char_length(btrim(${table.issuerBackendId})) between 1 and 300 and char_length(btrim(${table.authorityEffectId})) between 1 and 300 and char_length(btrim(${table.ownerEvidenceRef})) between 1 and 300 and ${table.issuerBackendKind} in ('external_business_system', 'ontos_wms') and ${table.issuedAt} < ${table.expiresAt}`, + ), + check( + 'inventory_reservation_confirmations_health_ck', + sql`${table.currentHealthState} in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and ${table.currentRevision} >= 1`, + ), + ...tenantRlsPolicies('inventory_reservation_confirmations_tenant', table.tenantId), + ], +); + +export const inventoryReservationConfirmationHistory = inventorySchema.table.withRLS( + 'reservation_confirmation_history', + { + historyId: uuid('history_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + confirmationId: uuid('confirmation_id').notNull(), + revision: integer('revision').notNull(), + healthState: text('health_state').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + transitionedAt: timestamp('transitioned_at', { withTimezone: true }).notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_reservation_confirmation_history_scope_id_uk').on(table.tenantId, table.historyId), + uniqueIndex('inventory_reservation_confirmation_history_revision_uk').on( + table.tenantId, + table.confirmationId, + table.revision, + ), + foreignKey({ + columns: [table.tenantId, table.confirmationId], + foreignColumns: [inventoryReservationConfirmations.tenantId, inventoryReservationConfirmations.confirmationId], + name: 'inventory_reservation_confirmation_history_confirmation_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_confirmation_history_health_ck', + sql`${table.healthState} in ('VALID', 'AT_RISK', 'REVOKED', 'EXPIRED', 'UNVERIFIABLE') and ${table.revision} >= 1`, + ), + ...tenantRlsPolicies('inventory_reservation_confirmation_history_tenant', table.tenantId), + ], +); + +export const inventoryReservationConfirmationScopeContract = { + constraintNames: { + authority: 'inventory_reservation_confirmations_exact_authority_ck', + reservation: 'inventory_reservation_confirmations_exact_reservation_ck', + snapshot: 'inventory_reservation_confirmations_snapshot_ck', + }, + event: 'INSERT OR UPDATE', + functionName: 'inventory.enforce_reservation_confirmation_scope', + table: 'inventory.reservation_confirmations', + timing: 'BEFORE', + triggerName: 'inventory_reservation_confirmations_scope_trg', +} as const; + +export const inventoryReservationConfirmationLifecycleContract = { + immutableColumns: [ + 'confirmation_id', + 'tenant_id', + 'reservation_id', + 'attempt_id', + 'owner_configuration_id', + 'issuer_backend_kind', + 'issuer_backend_id', + 'authority_effect_id', + 'owner_evidence_ref', + 'issued_at', + 'expires_at', + 'created_at', + ], + monotonicRevision: true, + terminalStates: ['REVOKED', 'EXPIRED'], + allowedRecoveryStates: ['AT_RISK', 'UNVERIFIABLE'], + event: 'UPDATE OR DELETE', + functionName: 'inventory.enforce_reservation_confirmation_lifecycle', + table: 'inventory.reservation_confirmations', + timing: 'BEFORE', + triggerName: 'inventory_reservation_confirmations_lifecycle_trg', +} as const; + +export const inventoryReservationConfirmationHistoryImmutabilityContract = { + deleteTriggerName: 'inventory_reservation_confirmation_history_no_delete_trg', + functionName: 'inventory.reject_reservation_confirmation_history_mutation', + table: 'inventory.reservation_confirmation_history', + updateTriggerName: 'inventory_reservation_confirmation_history_no_update_trg', +} as const; + +export const INVENTORY_RESERVATION_CONFIRMATION_TABLES = [ + inventoryReservationConfirmationHistory, + inventoryReservationConfirmations, +] as const; diff --git a/app/verticals/inventory/src/persistence/reservation-create-effect-repository.ts b/app/verticals/inventory/src/persistence/reservation-create-effect-repository.ts new file mode 100644 index 000000000..44499e739 --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-create-effect-repository.ts @@ -0,0 +1,276 @@ +import { defineScopedRoutine, findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, eq, inArray, sql } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + InventoryReservationCreateRejected, + InventoryReservationCreateUnavailable, + EstablishedReservationCreateEffectSchema, + ReservationCreateEffectSchema, +} from '../../shared/domain/inventory-reservation-create.ts'; +import type { + InventoryReservationCreateRequest, + ReservationCreateEffect, +} from '../../shared/domain/inventory-reservation-create.ts'; +import type { ReservationAuthorityEffectIdSchema } from '../../shared/domain/reservation-issuer-failure-fields.ts'; +import { ReservationAuthorityEffectIdSchema as ReservationAuthorityEffectId } from '../../shared/domain/reservation-issuer-failure-fields.ts'; +import type { ReservationCreateEffectPersistence } from '../services/inventory-reservation-create.service.ts'; +import { inventoryReservationCreateEffects } from './reservation-create-effect-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +const workerRowSchema = Schema.Struct({ record: ReservationCreateEffectSchema }); +export const readReservationCreateEffectForWorkerRoutine = defineScopedRoutine({ + name: 'read_reservation_create_effect_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.read-reservation-create-effect-for-worker', + schema: 'inventory', +}); +export const finalizeReservationCreateEffectForWorkerRoutine = defineScopedRoutine({ + name: 'finalize_reservation_create_effect_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.finalize-reservation-create-effect-for-worker', + schema: 'inventory', +}); + +const unavailable = (effectId: typeof ReservationAuthorityEffectIdSchema.Type, cause?: unknown) => { + const failure = new InventoryReservationCreateUnavailable({ + code: 'inventory_reservation_create_unavailable', + effectId, + reason: 'Reservation create-effect persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const rejected = ( + effectId: typeof ReservationAuthorityEffectIdSchema.Type, + reason: InventoryReservationCreateRejected['reason'], +) => new InventoryReservationCreateRejected({ code: 'inventory_reservation_create_rejected', effectId, reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); +const invalidEffectId = ReservationAuthorityEffectId.make('invalid-reservation-create-effect'); +const unknownEffectId = ReservationAuthorityEffectId.make('unknown-reservation-create-effect'); +const unresolvedEffectsId = ReservationAuthorityEffectId.make('unresolved-reservation-create-effects'); + +export const mapReservationCreateEffectWriteError = ( + effectId: typeof ReservationAuthorityEffectIdSchema.Type, + cause: unknown, +) => { + const staleBinding = findPostgresFailure( + cause, + ({ code, constraint }) => + code === checkViolationSqlState && constraint === 'inventory_reservation_create_effects_stale_binding_ck', + ); + if (Option.isSome(staleBinding)) { + return rejected(effectId, 'INVALID_BACKEND_OBSERVATION'); + } + const attempt = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_reservation_create_effects_attempt_uk', + ); + if (Option.isSome(attempt)) { + return rejected(effectId, 'ATTEMPT_HAS_UNRESOLVED_EFFECT'); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_reservation_create_effects_pkey', + ); + return Option.isSome(identity) ? rejected(effectId, 'EFFECT_ID_CONFLICT') : unavailable(effectId, cause); +}; + +const decodeRow = (row: typeof inventoryReservationCreateEffects.$inferSelect) => + Schema.decodeEffect(ReservationAuthorityEffectId)(row.effectId).pipe( + Effect.mapError((cause) => unavailable(invalidEffectId, cause)), + Effect.flatMap((decodedEffectId) => + Schema.decodeEffect(ReservationCreateEffectSchema)(row.recordJson).pipe( + Effect.mapError((cause) => unavailable(decodedEffectId, cause)), + ), + ), + ); + +const insertValues = (request: InventoryReservationCreateRequest) => { + const record = { _tag: 'REQUESTED' as const, request }; + return { + attemptId: request.reservation.origin.attemptId, + backendConfigurationId: request.authority.configurationId, + backendId: request.authority.selection.backendId, + customerConfigurationId: request.authority.customerConfigurationId, + effectId: request.effectId, + legalEntityId: request.legalEntityId, + mutationId: request.mutationId, + recordJson: record, + requestedAt: DateTime.toDateUtc(DateTime.makeUnsafe(request.requestedAt)), + requestJson: request, + reservationId: request.reservation.ref.resourceId, + sourceActionInvocationId: request.sourceActionInvocationId, + state: record._tag, + tenantId: request.authority.tenantId, + }; +}; + +export const reservationCreateEffectPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): ReservationCreateEffectPersistence => { + const readRows = (effectId: typeof ReservationAuthorityEffectIdSchema.Type) => + transaction + .select() + .from(inventoryReservationCreateEffects) + .where( + and( + eq(inventoryReservationCreateEffects.tenantId, scope.tenantId), + eq(inventoryReservationCreateEffects.effectId, effectId), + ), + ) + .for('update') + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(effectId, cause))); + + const read: ReservationCreateEffectPersistence['read'] = (effectId) => + readRows(effectId).pipe( + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeRow(row).pipe(Effect.asSome))), + ); + + const findByAttempt: ReservationCreateEffectPersistence['findByAttempt'] = (attemptId) => + transaction + .select() + .from(inventoryReservationCreateEffects) + .where( + and( + eq(inventoryReservationCreateEffects.tenantId, scope.tenantId), + eq(inventoryReservationCreateEffects.attemptId, attemptId), + ), + ) + .for('update') + .limit(1) + .pipe( + Effect.mapError((cause) => unavailable(unknownEffectId, cause)), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeRow(row).pipe(Effect.asSome))), + ); + + const createOrRead: ReservationCreateEffectPersistence['createOrRead'] = Effect.fn( + 'ReservationCreateEffectPersistence.createOrRead', + )(function* createOrReadEffect(request) { + if (request.authority.tenantId !== scope.tenantId) { + return yield* rejected(request.effectId, 'TENANT_SCOPE_MISMATCH'); + } + const [inserted] = yield* transaction + .insert(inventoryReservationCreateEffects) + .values(insertValues(request)) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError((cause) => mapReservationCreateEffectWriteError(request.effectId, cause))); + if (inserted !== undefined) { + return { effect: yield* decodeRow(inserted), outcome: 'INSERTED' as const }; + } + const existing = yield* read(request.effectId); + if (Option.isSome(existing)) { + return { effect: existing.value, outcome: 'EXISTING' as const }; + } + const competing = yield* findByAttempt(request.reservation.origin.attemptId); + return yield* Option.match(competing, { + onNone: () => Effect.fail(unavailable(request.effectId)), + onSome: (record) => + Effect.fail( + rejected( + request.effectId, + Schema.is(EstablishedReservationCreateEffectSchema)(record) + ? 'ATTEMPT_ALREADY_BOUND' + : 'ATTEMPT_HAS_UNRESOLVED_EFFECT', + ), + ), + }); + }); + + const save: ReservationCreateEffectPersistence['save'] = Effect.fn('ReservationCreateEffectPersistence.save')( + function* saveEffect(expected, next) { + if (expected.request.effectId !== next.request.effectId || next.request.authority.tenantId !== scope.tenantId) { + return yield* rejected(expected.request.effectId, 'EFFECT_ID_CONFLICT'); + } + const [updated] = yield* transaction + .update(inventoryReservationCreateEffects) + .set({ recordJson: next, state: next._tag, updatedAt: sql`now()` }) + .where( + and( + eq(inventoryReservationCreateEffects.tenantId, scope.tenantId), + eq(inventoryReservationCreateEffects.effectId, expected.request.effectId), + eq(inventoryReservationCreateEffects.state, expected._tag), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => mapReservationCreateEffectWriteError(expected.request.effectId, cause))); + if (updated !== undefined) { + return yield* decodeRow(updated); + } + const current = yield* read(expected.request.effectId); + return yield* Effect.fromOption(current).pipe( + Effect.mapError((cause) => unavailable(expected.request.effectId, cause)), + ); + }, + ); + + return Object.freeze({ createOrRead, findByAttempt, read, save }); +}; + +/** Current unresolved effects constrain planned/known Allocations until authoritative resolution. */ +export const listUnresolvedReservationCreateEffects = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): Effect.Effect => + transaction + .select() + .from(inventoryReservationCreateEffects) + .where( + and( + eq(inventoryReservationCreateEffects.tenantId, scope.tenantId), + inArray(inventoryReservationCreateEffects.state, ['REQUESTED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE']), + ), + ) + .pipe( + Effect.mapError((cause) => unavailable(unresolvedEffectsId, cause)), + Effect.flatMap((rows) => Effect.forEach(rows, decodeRow, { concurrency: 1 })), + ); + +/** Worker adapter over the Core-verified, lifetime-bound owner scope. */ +export const reservationCreateEffectPersistenceForWorkerScope = ( + scope: OutboxWorkerLegalEntityScope, +): ReservationCreateEffectPersistence => ({ + createOrRead: (request) => Effect.fail(unavailable(request.effectId)), + findByAttempt: () => Effect.fail(unavailable(unknownEffectId)), + read: (effectId) => + scope.routineInvoker.invoke(readReservationCreateEffectForWorkerRoutine, [effectId]).pipe( + Effect.mapError((cause) => unavailable(effectId, cause)), + Effect.map(([row]) => (row === undefined ? Option.none() : Option.some(row.record))), + ), + save: (expected, terminal) => + scope.routineInvoker + .invoke(finalizeReservationCreateEffectForWorkerRoutine, [expected.request.effectId, terminal]) + .pipe( + Effect.mapError((cause) => mapReservationCreateEffectWriteError(expected.request.effectId, cause)), + Effect.flatMap(([row]) => + row === undefined ? Effect.fail(unavailable(expected.request.effectId)) : Effect.succeed(row.record), + ), + ), +}); diff --git a/app/verticals/inventory/src/persistence/reservation-create-effect-table.ts b/app/verticals/inventory/src/persistence/reservation-create-effect-table.ts new file mode 100644 index 000000000..fa7c16aa8 --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-create-effect-table.ts @@ -0,0 +1,80 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, jsonb, primaryKey, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { + InventoryReservationCreateRequest, + ReservationCreateEffect, +} from '../../shared/domain/inventory-reservation-create.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; + +export const inventoryReservationCreateEffects = inventorySchema.table.withRLS( + 'reservation_create_effects', + { + effectId: text('effect_id').notNull(), + tenantId: uuid('tenant_id').notNull(), + legalEntityId: uuid('legal_entity_id').notNull(), + mutationId: uuid('mutation_id').notNull(), + attemptId: text('attempt_id').notNull(), + reservationId: uuid('reservation_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + backendConfigurationId: uuid('backend_configuration_id').notNull(), + backendId: text('backend_id').notNull(), + state: text('state').default('REQUESTED').notNull(), + requestJson: jsonb('request_json').$type().notNull(), + recordJson: jsonb('record_json').$type().notNull(), + requestedAt: timestamp('requested_at', { withTimezone: true }).notNull(), + sourceActionInvocationId: uuid('source_action_invocation_id').notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ columns: [table.tenantId, table.effectId], name: 'inventory_reservation_create_effects_pkey' }), + uniqueIndex('inventory_reservation_create_effects_attempt_uk').on(table.tenantId, table.attemptId), + uniqueIndex('inventory_reservation_create_effects_mutation_uk').on(table.tenantId, table.mutationId), + uniqueIndex('inventory_reservation_create_effects_reservation_uk').on(table.tenantId, table.reservationId), + index('inventory_reservation_create_effects_state_idx').on(table.tenantId, table.state, table.updatedAt), + foreignKey({ + columns: [table.tenantId, table.backendConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_reservation_create_effects_backend_configuration_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_create_effects_identity_ck', + sql`char_length(btrim(${table.effectId})) between 1 and 300 and char_length(btrim(${table.attemptId})) between 1 and 300 and char_length(btrim(${table.customerConfigurationId})) between 1 and 300 and char_length(btrim(${table.backendId})) between 1 and 300`, + ), + check( + 'inventory_reservation_create_effects_state_ck', + sql`${table.state} in ('REQUESTED', 'ESTABLISHED', 'RECONCILIATION_REQUIRED', 'INDETERMINATE', 'RESOLVED_NO_RESERVATION')`, + ), + ...tenantRlsPolicies('inventory_reservation_create_effects_tenant', table.tenantId), + ], +); + +export const inventoryReservationCreateEffectTransitionContract = { + constraintName: 'inventory_reservation_create_effects_transition_ck', + functionName: 'inventory.enforce_reservation_create_effect_transition', + immutableColumns: [ + 'effect_id', + 'tenant_id', + 'legal_entity_id', + 'mutation_id', + 'attempt_id', + 'reservation_id', + 'customer_configuration_id', + 'backend_configuration_id', + 'backend_id', + 'request_json', + 'requested_at', + 'source_action_invocation_id', + ], + terminalStates: ['ESTABLISHED', 'RESOLVED_NO_RESERVATION'], + transitions: [ + 'REQUESTED -> ESTABLISHED|RECONCILIATION_REQUIRED|INDETERMINATE|RESOLVED_NO_RESERVATION', + 'RECONCILIATION_REQUIRED|INDETERMINATE -> ESTABLISHED|RECONCILIATION_REQUIRED|INDETERMINATE|RESOLVED_NO_RESERVATION', + 'ESTABLISHED -> ESTABLISHED exact replay only', + 'RESOLVED_NO_RESERVATION -> RESOLVED_NO_RESERVATION exact replay only', + ], + triggerName: 'inventory_reservation_create_effects_transition_trg', +} as const; diff --git a/app/verticals/inventory/src/persistence/reservation-release-effect-repository.ts b/app/verticals/inventory/src/persistence/reservation-release-effect-repository.ts new file mode 100644 index 000000000..b743d6586 --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-release-effect-repository.ts @@ -0,0 +1,297 @@ +import { defineScopedRoutine, findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, eq } from 'drizzle-orm'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + InventoryReservationReleaseRejected, + ReservationReleaseEffectIdSchema, + ReservationReleaseEffectSchema, + RequestedReleaseEffectSchema, +} from '../../shared/domain/inventory-reservation-release.ts'; +import type { + InventoryReservationReleaseError, + ReservationReleaseEffect, +} from '../../shared/domain/inventory-reservation-release.ts'; +import type { ReservationReleaseEffectPersistence } from '../services/inventory-reservation-release.service.ts'; +import { reservationReleaseUnavailable } from '../services/inventory-reservation-release.service.ts'; +import { + inventoryReservationReleaseEffectHistory, + inventoryReservationReleaseEffects, +} from './reservation-release-effect-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type EffectRow = typeof inventoryReservationReleaseEffects.$inferSelect; + +const workerRowSchema = Schema.Struct({ record: ReservationReleaseEffectSchema }); +export const readReservationReleaseEffectForWorkerRoutine = defineScopedRoutine({ + name: 'read_reservation_release_effect_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.read-reservation-release-effect-for-worker', + schema: 'inventory', +}); +export const finalizeReservationReleaseEffectForWorkerRoutine = defineScopedRoutine({ + name: 'finalize_reservation_release_effect_for_worker', + ownerModuleKey: 'commerce.inventory', + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'integer' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: workerRowSchema, + routineKey: 'inventory.finalize-reservation-release-effect-for-worker', + schema: 'inventory', +}); + +const rejected = ( + effectId: typeof ReservationReleaseEffectIdSchema.Type, + reason: InventoryReservationReleaseRejected['reason'], +) => new InventoryReservationReleaseRejected({ code: 'inventory_reservation_release_rejected', effectId, reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const persistenceUnavailableReason = 'Reservation Release persistence is temporarily unavailable'; +export const mapReservationReleaseEffectWriteError = ( + effectId: typeof ReservationReleaseEffectIdSchema.Type, + cause: unknown, +): InventoryReservationReleaseError => { + const sibling = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_reservation_release_effects_reservation_uk', + ); + if (Option.isSome(sibling)) { + return rejected(effectId, 'SIBLING_RELEASE_EFFECT_FORBIDDEN'); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + [ + 'inventory_reservation_release_effects_scope_effect_uk', + 'inventory_reservation_release_effects_mutation_uk', + ].includes(constraint ?? ''), + ); + if (Option.isSome(identity)) { + return rejected(effectId, 'EFFECT_ID_CONFLICT'); + } + const revision = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_reservation_release_effect_history_revision_uk', + ); + return Option.isSome(revision) + ? rejected(effectId, 'REVISION_CONFLICT') + : reservationReleaseUnavailable(effectId, persistenceUnavailableReason, cause); +}; + +const decodeRow = (row: EffectRow) => + Schema.decodeEffect(ReservationReleaseEffectSchema)(row.snapshot).pipe( + Effect.mapError((cause) => + reservationReleaseUnavailable( + ReservationReleaseEffectIdSchema.make(row.releaseEffectId), + 'Persisted Reservation Release effect is invalid', + cause, + ), + ), + ); + +const transitionedAt = (effect: ReservationReleaseEffect) => + Match.value(effect).pipe( + Match.tag('REQUESTED', ({ request }) => request.requestedAt), + Match.tag('RELEASED', ({ releasedAt }) => releasedAt), + Match.tag('NOT_RELEASABLE', 'INDETERMINATE', ({ observedAt }) => observedAt), + Match.exhaustive, + ); + +const valuesFor = (effect: ReservationReleaseEffect) => { + const releaseColumns = Match.value(effect).pipe( + Match.tag('RELEASED', ({ ownerEvidenceRef, releasedAt }) => ({ + ownerEvidenceRef, + releasedAt: DateTime.toDateUtc(DateTime.makeUnsafe(releasedAt)), + })), + Match.tag('REQUESTED', 'INDETERMINATE', 'NOT_RELEASABLE', () => ({ + ownerEvidenceRef: null, + releasedAt: null, + })), + Match.exhaustive, + ); + return { + attemptId: effect.request.reservation.origin.attemptId, + currentRevision: effect.revision, + currentState: effect._tag, + issuerBackendId: effect.request.reservation.authority.selection.backendId, + issuerBackendKind: effect.request.reservation.authority.selection.backend, + legalEntityId: effect.request.legalEntityId, + mutationId: effect.request.mutationId, + ownerConfigurationId: effect.request.reservation.authority.configurationId, + ownerEvidenceRef: releaseColumns.ownerEvidenceRef, + releasedAt: releaseColumns.releasedAt, + releaseEffectId: effect.request.effectId, + requestedAt: DateTime.toDateUtc(DateTime.makeUnsafe(effect.request.requestedAt)), + reservationId: effect.request.reservation.ref.resourceId, + snapshot: effect, + sourceActionInvocationId: effect.request.sourceActionInvocationId, + tenantId: effect.request.reservation.ref.tenantId, + updatedAt: DateTime.toDateUtc(DateTime.makeUnsafe(transitionedAt(effect))), + }; +}; + +export const reservationReleaseEffectPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): ReservationReleaseEffectPersistence => { + const read: ReservationReleaseEffectPersistence['read'] = (effectId) => + transaction + .select() + .from(inventoryReservationReleaseEffects) + .where( + and( + eq(inventoryReservationReleaseEffects.tenantId, scope.tenantId), + eq(inventoryReservationReleaseEffects.releaseEffectId, effectId), + ), + ) + .for('update') + .limit(1) + .pipe( + Effect.mapError((cause) => reservationReleaseUnavailable(effectId, persistenceUnavailableReason, cause)), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeRow(row).pipe(Effect.asSome))), + ); + + const findByReservation: ReservationReleaseEffectPersistence['findByReservation'] = (ref) => + ref.tenantId === scope.tenantId + ? transaction + .select() + .from(inventoryReservationReleaseEffects) + .where( + and( + eq(inventoryReservationReleaseEffects.tenantId, scope.tenantId), + eq(inventoryReservationReleaseEffects.reservationId, ref.resourceId), + ), + ) + .for('update') + .limit(1) + .pipe( + Effect.mapError((cause) => reservationReleaseUnavailable(undefined, persistenceUnavailableReason, cause)), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : decodeRow(row).pipe(Effect.asSome))), + ) + : Effect.fail(rejected(ReservationReleaseEffectIdSchema.make('cross-tenant-release'), 'TENANT_SCOPE_MISMATCH')); + + const appendHistory = (effect: ReservationReleaseEffect) => + transaction + .insert(inventoryReservationReleaseEffectHistory) + .values({ + releaseEffectId: effect.request.effectId, + revision: effect.revision, + snapshot: effect, + state: effect._tag, + tenantId: effect.request.reservation.ref.tenantId, + transitionedAt: DateTime.toDateUtc(DateTime.makeUnsafe(transitionedAt(effect))), + }) + .pipe( + Effect.mapError((cause) => mapReservationReleaseEffectWriteError(effect.request.effectId, cause)), + Effect.asVoid, + ); + + const createOrRead: ReservationReleaseEffectPersistence['createOrRead'] = Effect.fn( + 'ReservationReleaseEffectPersistence.createOrRead', + )(function* createOrRead(candidate) { + if ( + !Schema.is(RequestedReleaseEffectSchema)(candidate) || + candidate.request.reservation.ref.tenantId !== scope.tenantId + ) { + return yield* rejected(candidate.request.effectId, 'TENANT_SCOPE_MISMATCH'); + } + const [inserted] = yield* transaction + .insert(inventoryReservationReleaseEffects) + .values(valuesFor(candidate)) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError((cause) => mapReservationReleaseEffectWriteError(candidate.request.effectId, cause))); + if (inserted !== undefined) { + const persisted = yield* decodeRow(inserted); + yield* appendHistory(persisted); + return { effect: persisted, outcome: 'INSERTED' as const }; + } + const existing = yield* read(candidate.request.effectId); + if (Option.isSome(existing)) { + return { effect: existing.value, outcome: 'EXISTING' as const }; + } + const sibling = yield* findByReservation(candidate.request.reservation.ref); + return yield* Option.match(sibling, { + onNone: () => + Effect.fail( + reservationReleaseUnavailable(candidate.request.effectId, 'Release insert conflict could not be resolved'), + ), + onSome: () => Effect.fail(rejected(candidate.request.effectId, 'SIBLING_RELEASE_EFFECT_FORBIDDEN')), + }); + }); + + const save: ReservationReleaseEffectPersistence['save'] = Effect.fn('ReservationReleaseEffectPersistence.save')( + function* saveEffect(expected, next) { + if ( + expected.request.effectId !== next.request.effectId || + next.request.reservation.ref.tenantId !== scope.tenantId || + next.revision !== expected.revision + 1 + ) { + return yield* rejected(expected.request.effectId, 'REVISION_CONFLICT'); + } + const [updated] = yield* transaction + .update(inventoryReservationReleaseEffects) + .set(valuesFor(next)) + .where( + and( + eq(inventoryReservationReleaseEffects.tenantId, scope.tenantId), + eq(inventoryReservationReleaseEffects.releaseEffectId, expected.request.effectId), + eq(inventoryReservationReleaseEffects.currentRevision, expected.revision), + eq(inventoryReservationReleaseEffects.currentState, expected._tag), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => mapReservationReleaseEffectWriteError(expected.request.effectId, cause))); + if (updated === undefined) { + return yield* rejected(expected.request.effectId, 'REVISION_CONFLICT'); + } + const persisted = yield* decodeRow(updated); + yield* appendHistory(persisted); + return persisted; + }, + ); + + return Object.freeze({ createOrRead, findByReservation, read, save }); +}; + +export const reservationReleaseEffectPersistenceForWorkerScope = ( + scope: OutboxWorkerLegalEntityScope, +): ReservationReleaseEffectPersistence => ({ + createOrRead: (candidate) => + Effect.fail(reservationReleaseUnavailable(candidate.request.effectId, 'Worker cannot create Release intents')), + findByReservation: () => + Effect.fail(reservationReleaseUnavailable(undefined, 'Worker cannot search unrelated Release intents')), + read: (effectId) => + scope.routineInvoker.invoke(readReservationReleaseEffectForWorkerRoutine, [effectId]).pipe( + Effect.mapError((cause) => reservationReleaseUnavailable(effectId, 'Release effect read failed', cause)), + Effect.map(([row]) => (row === undefined ? Option.none() : Option.some(row.record))), + ), + save: (expected, next) => + scope.routineInvoker + .invoke(finalizeReservationReleaseEffectForWorkerRoutine, [expected.request.effectId, expected.revision, next]) + .pipe( + Effect.mapError((cause) => + reservationReleaseUnavailable(expected.request.effectId, 'Release effect finalization failed', cause), + ), + Effect.flatMap(([row]) => + row === undefined + ? Effect.fail(reservationReleaseUnavailable(expected.request.effectId, 'Release effect was not finalized')) + : Effect.succeed(row.record), + ), + ), +}); diff --git a/app/verticals/inventory/src/persistence/reservation-release-effect-table.ts b/app/verticals/inventory/src/persistence/reservation-release-effect-table.ts new file mode 100644 index 000000000..ef2ee7860 --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-release-effect-table.ts @@ -0,0 +1,135 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { ReservationReleaseEffect } from '../../shared/domain/inventory-reservation-release.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryObligations } from './inventory-obligation-table.ts'; + +export const inventoryReservationReleaseEffects = inventorySchema.table.withRLS( + 'reservation_release_effects', + { + releaseEffectRecordId: uuid('release_effect_record_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + releaseEffectId: text('release_effect_id').notNull(), + mutationId: uuid('mutation_id').notNull(), + sourceActionInvocationId: uuid('source_action_invocation_id').notNull(), + legalEntityId: uuid('legal_entity_id').notNull(), + reservationId: uuid('reservation_id').notNull(), + attemptId: text('attempt_id').notNull(), + ownerConfigurationId: uuid('owner_configuration_id').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + currentState: text('current_state').default('REQUESTED').notNull(), + currentRevision: integer('current_revision').default(1).notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + requestedAt: timestamp('requested_at', { withTimezone: true }).notNull(), + releasedAt: timestamp('released_at', { withTimezone: true }), + ownerEvidenceRef: text('owner_evidence_ref'), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_reservation_release_effects_scope_effect_uk').on(table.tenantId, table.releaseEffectId), + uniqueIndex('inventory_reservation_release_effects_reservation_uk').on(table.tenantId, table.reservationId), + uniqueIndex('inventory_reservation_release_effects_mutation_uk').on(table.tenantId, table.mutationId), + index('inventory_reservation_release_effects_state_idx').on(table.tenantId, table.currentState, table.updatedAt), + foreignKey({ + columns: [table.tenantId, table.reservationId], + foreignColumns: [inventoryObligations.tenantId, inventoryObligations.obligationId], + name: 'inventory_reservation_release_effects_reservation_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.ownerConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_reservation_release_effects_backend_configuration_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_release_effects_meaning_ck', + sql`char_length(btrim(${table.releaseEffectId})) between 1 and 300 and char_length(btrim(${table.attemptId})) between 1 and 300 and char_length(btrim(${table.issuerBackendId})) between 1 and 300 and ${table.issuerBackendKind} in ('external_business_system', 'ontos_wms') and ${table.currentState} in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and ${table.currentRevision} >= 1 and ((${table.currentState} = 'RELEASED' and ${table.releasedAt} is not null and ${table.ownerEvidenceRef} is not null) or (${table.currentState} <> 'RELEASED' and ${table.releasedAt} is null and ${table.ownerEvidenceRef} is null))`, + ), + ...tenantRlsPolicies('inventory_reservation_release_effects_tenant', table.tenantId), + ], +); + +export const inventoryReservationReleaseEffectHistory = inventorySchema.table.withRLS( + 'reservation_release_effect_history', + { + historyId: uuid('history_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + releaseEffectId: text('release_effect_id').notNull(), + revision: integer('revision').notNull(), + state: text('state').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + transitionedAt: timestamp('transitioned_at', { withTimezone: true }).notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_reservation_release_effect_history_scope_id_uk').on(table.tenantId, table.historyId), + uniqueIndex('inventory_reservation_release_effect_history_revision_uk').on( + table.tenantId, + table.releaseEffectId, + table.revision, + ), + foreignKey({ + columns: [table.tenantId, table.releaseEffectId], + foreignColumns: [inventoryReservationReleaseEffects.tenantId, inventoryReservationReleaseEffects.releaseEffectId], + name: 'inventory_reservation_release_effect_history_effect_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_release_effect_history_meaning_ck', + sql`${table.state} in ('REQUESTED', 'INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE') and ${table.revision} >= 1`, + ), + ...tenantRlsPolicies('inventory_reservation_release_effect_history_tenant', table.tenantId), + ], +); + +export const inventoryReservationReleaseEffectTransitionContract = { + allowedTransitions: { + INDETERMINATE: ['INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE'], + NOT_RELEASABLE: [], + RELEASED: [], + REQUESTED: ['INDETERMINATE', 'RELEASED', 'NOT_RELEASABLE'], + }, + immutableColumns: [ + 'release_effect_record_id', + 'tenant_id', + 'release_effect_id', + 'mutation_id', + 'source_action_invocation_id', + 'legal_entity_id', + 'reservation_id', + 'attempt_id', + 'owner_configuration_id', + 'issuer_backend_kind', + 'issuer_backend_id', + 'requested_at', + 'created_at', + ], + monotonicRevision: true, + functionName: 'inventory.enforce_reservation_release_effect_transition', + table: 'inventory.reservation_release_effects', + triggerName: 'inventory_reservation_release_effects_transition_trg', +} as const; + +export const inventoryReservationReleaseEffectScopeContract = { + functionName: 'inventory.enforce_reservation_release_effect_scope', + table: 'inventory.reservation_release_effects', + timing: 'BEFORE', + triggerEvent: 'INSERT OR UPDATE', + triggerName: 'inventory_reservation_release_effects_scope_trg', +} as const; + +export const inventoryReservationReleaseEffectHistoryImmutabilityContract = { + deleteTriggerName: 'inventory_reservation_release_effect_history_no_delete_trg', + functionName: 'inventory.reject_reservation_release_effect_history_mutation', + table: 'inventory.reservation_release_effect_history', + updateTriggerName: 'inventory_reservation_release_effect_history_no_update_trg', +} as const; + +export const INVENTORY_RESERVATION_RELEASE_TABLES = [ + inventoryReservationReleaseEffectHistory, + inventoryReservationReleaseEffects, +] as const; diff --git a/app/verticals/inventory/src/persistence/reservation-shortage-impact-repository.ts b/app/verticals/inventory/src/persistence/reservation-shortage-impact-repository.ts new file mode 100644 index 000000000..90e03e7b0 --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-shortage-impact-repository.ts @@ -0,0 +1,485 @@ +import { defineScopedRoutine } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import type { OutboxWorkerLegalEntityScope } from '@app/core-runtime/outbox/worker'; +import { and, eq, isNull, ne, or } from 'drizzle-orm'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + ReservationShortageImpactInputSchema, + deriveReservationShortageFencedAmount, +} from '../../shared/domain/reservation-shortage-impact.ts'; +import type { PhysicalStockEffectEvidence } from '../../shared/domain/physical-stock-effect.ts'; +import { advanceReservationConfirmationHealth } from '../../shared/domain/reservation-confirmation.ts'; +import { ExactStockQuantityAmountSchema } from '../../shared/domain/stock-position.ts'; +import { reservationConfirmationPersistenceForScope } from './reservation-confirmation-repository.ts'; +import { + ReservationShortageImpactTriggerSchema, + ReservationShortageImpactUnavailable, +} from '../services/reservation-shortage-impact.service.ts'; +import type { + ReservationShortageImpactPersistence, + ReservationShortageImpactTrigger, +} from '../services/reservation-shortage-impact.service.ts'; +import { inventoryObligationAllocations, inventoryObligations } from './inventory-obligation-table.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; +import { inventoryReservationConfirmations } from './reservation-confirmation-table.ts'; +import { inventoryReservationReleaseEffects } from './reservation-release-effect-table.ts'; +import { + inventoryReservationShortageImpactDecisions, + inventoryReservationShortageImpacts, +} from './reservation-shortage-impact-table.ts'; +import { inventoryStockCorrections } from './stock-correction-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; + +const contextRowSchema = Schema.Struct({ + context: Schema.Struct({ + causeEvidenceRef: Schema.String, + evaluationInput: ReservationShortageImpactInputSchema, + fencedAmount: ExactStockQuantityAmountSchema, + positionRevision: Schema.Int, + }), +}); +const appliedRowSchema = Schema.Struct({ found: Schema.Boolean }); +const applyRowSchema = Schema.Struct({ applied: Schema.Boolean }); + +export const findReservationShortageImpactForWorkerRoutine = defineScopedRoutine({ + name: 'find_reservation_shortage_impact_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'uuid' }, + ], + resultSchema: appliedRowSchema, + routineKey: 'inventory.find-reservation-shortage-impact-for-worker', + schema: 'inventory', +}); + +export const readReservationShortageImpactContextForWorkerRoutine = defineScopedRoutine({ + name: 'read_reservation_shortage_impact_context_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + { source: 'input', type: 'timestamptz' }, + ], + resultSchema: contextRowSchema, + routineKey: 'inventory.read-reservation-shortage-impact-context-for-worker', + schema: 'inventory', +}); + +export const applyReservationShortageImpactForWorkerRoutine = defineScopedRoutine({ + name: 'apply_reservation_shortage_impact_for_worker', + ownerModuleKey: INVENTORY_MODULE_ID, + parameters: [ + { source: 'tenantId', type: 'uuid' }, + { source: 'legalEntityId', type: 'uuid' }, + { source: 'input', type: 'text' }, + { source: 'input', type: 'uuid' }, + { source: 'input', type: 'uuid' }, + { source: 'input', type: 'timestamptz' }, + { source: 'input', type: 'jsonb' }, + ], + resultSchema: applyRowSchema, + routineKey: 'inventory.apply-reservation-shortage-impact-for-worker', + schema: 'inventory', +}); + +const unavailable = (trigger?: ReservationShortageImpactTrigger, cause?: unknown) => { + const failure = + trigger === undefined + ? new ReservationShortageImpactUnavailable({ + code: 'reservation_shortage_impact_unavailable', + reason: 'Reservation shortage impact persistence is temporarily unavailable', + retryable: true, + }) + : new ReservationShortageImpactUnavailable({ + changeId: trigger.changeId, + code: 'reservation_shortage_impact_unavailable', + reason: 'Reservation shortage impact persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); +const instantAsString = (instant: Date) => DateTime.formatIso(DateTime.fromDateUnsafe(instant)); + +const sourceValues = (trigger: ReservationShortageImpactTrigger) => + trigger.changeKind === 'CORRECTION' + ? { physicalEffectId: null, stockCorrectionId: trigger.changeId } + : { physicalEffectId: trigger.changeId, stockCorrectionId: null }; + +const triggerForRow = (row: typeof inventoryReservationShortageImpacts.$inferSelect) => + Schema.decodeUnknownEffect(ReservationShortageImpactTriggerSchema)({ + changeId: row.changeId, + changeKind: row.changeKind, + occurredAt: instantAsString(row.occurredAt), + positionRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.positionId, + resourceType: 'commerce.inventory.stock-position', + tenantId: row.tenantId, + }, + }).pipe(Effect.mapError((cause) => unavailable(undefined, cause))); + +const healthEvidenceRef = (trigger: ReservationShortageImpactTrigger, causeEvidenceRef: string) => + `stock-change:${trigger.changeKind.toLowerCase()}:${causeEvidenceRef}`.slice(0, 300); + +const exactPositionSourceEvidence = ( + source: + | { readonly appliedAt: Date; readonly evidenceRef: string; readonly observedAt: Date } + | { + readonly record: Pick | null; + }, +) => { + if ('evidenceRef' in source) { + return { evidenceRef: source.evidenceRef, observedAt: source.observedAt, occurredAt: source.appliedAt }; + } + if (source.record === null) { + return null; + } + const appliedAt = instantAsDate(source.record.appliedAt); + return { evidenceRef: source.record.backendEvidenceRef, observedAt: appliedAt, occurredAt: appliedAt }; +}; + +export const reservationShortageImpactPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): ReservationShortageImpactPersistence => { + const findApplied: ReservationShortageImpactPersistence['findApplied'] = Effect.fn( + 'ReservationShortageImpactPersistence.findApplied', + )(function* findAppliedImpact(trigger) { + if (trigger.positionRef.tenantId !== scope.tenantId) { + return yield* unavailable(trigger); + } + const [row] = yield* transaction + .select() + .from(inventoryReservationShortageImpacts) + .where( + and( + eq(inventoryReservationShortageImpacts.tenantId, scope.tenantId), + eq(inventoryReservationShortageImpacts.changeKind, trigger.changeKind), + eq(inventoryReservationShortageImpacts.changeId, trigger.changeId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + return row === undefined ? Option.none() : Option.some({ trigger: yield* triggerForRow(row) }); + }); + + const readContext: ReservationShortageImpactPersistence['readContext'] = Effect.fn( + 'ReservationShortageImpactPersistence.readContext', + )(function* readImpactContext(trigger) { + if (trigger.positionRef.tenantId !== scope.tenantId) { + return yield* unavailable(trigger); + } + const [position] = yield* transaction + .select() + .from(inventoryStockPositions) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.stockPositionId, trigger.positionRef.resourceId), + eq(inventoryStockPositions.lifecycleState, 'CURRENT'), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + if (position?.onHandState !== 'CURRENT' || position.onHandAmount === null) { + return yield* unavailable(trigger); + } + + const sourceRows = + trigger.changeKind === 'CORRECTION' + ? yield* transaction + .select({ + appliedAt: inventoryStockCorrections.appliedAt, + evidenceRef: inventoryStockCorrections.ownerEvidenceRef, + observedAt: inventoryStockCorrections.businessObservedAt, + }) + .from(inventoryStockCorrections) + .where( + and( + eq(inventoryStockCorrections.tenantId, scope.tenantId), + eq(inventoryStockCorrections.correctionId, trigger.changeId), + eq(inventoryStockCorrections.positionId, trigger.positionRef.resourceId), + eq(inventoryStockCorrections.state, 'APPLIED'), + eq(inventoryStockCorrections.appliedAt, instantAsDate(trigger.occurredAt)), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))) + : yield* transaction + .select({ record: inventoryPhysicalStockEffects.evidenceJson }) + .from(inventoryPhysicalStockEffects) + .where( + and( + eq(inventoryPhysicalStockEffects.tenantId, scope.tenantId), + eq(inventoryPhysicalStockEffects.effectId, trigger.changeId), + eq(inventoryPhysicalStockEffects.positionId, trigger.positionRef.resourceId), + eq(inventoryPhysicalStockEffects.kind, trigger.changeKind), + eq(inventoryPhysicalStockEffects.state, 'APPLIED'), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + const [source] = sourceRows; + const exactSource = source === undefined ? undefined : exactPositionSourceEvidence(source); + if ( + exactSource === undefined || + exactSource === null || + exactSource.occurredAt.getTime() !== instantAsDate(trigger.occurredAt).getTime() || + position.onHandEvidenceRef !== exactSource.evidenceRef || + position.onHandObservedAt?.getTime() !== exactSource.observedAt.getTime() + ) { + return yield* unavailable(trigger); + } + + const rows = yield* transaction + .select({ + confirmation: inventoryReservationConfirmations.snapshot, + lifecycleMeaning: inventoryObligations.lifecycleMeaning, + }) + .from(inventoryReservationConfirmations) + .innerJoin( + inventoryObligations, + and( + eq(inventoryObligations.tenantId, inventoryReservationConfirmations.tenantId), + eq(inventoryObligations.obligationId, inventoryReservationConfirmations.reservationId), + ), + ) + .innerJoin( + inventoryObligationAllocations, + and( + eq(inventoryObligationAllocations.tenantId, inventoryReservationConfirmations.tenantId), + eq(inventoryObligationAllocations.obligationId, inventoryReservationConfirmations.reservationId), + eq(inventoryObligationAllocations.stockPositionId, trigger.positionRef.resourceId), + ), + ) + .leftJoin( + inventoryReservationReleaseEffects, + and( + eq(inventoryReservationReleaseEffects.tenantId, inventoryReservationConfirmations.tenantId), + eq(inventoryReservationReleaseEffects.reservationId, inventoryReservationConfirmations.reservationId), + ), + ) + .where( + and( + eq(inventoryReservationConfirmations.tenantId, scope.tenantId), + or( + isNull(inventoryReservationReleaseEffects.releaseEffectRecordId), + ne(inventoryReservationReleaseEffects.currentState, 'RELEASED'), + ), + ), + ) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + const candidatesById = new Map(); + for (const row of rows) { + candidatesById.set(row.confirmation.ref.resourceId, row); + } + const evaluationInput = yield* Schema.decodeUnknownEffect(ReservationShortageImpactInputSchema)({ + affectedPositionRef: trigger.positionRef, + availableQuantity: { + amount: position.onHandAmount, + unitRef: { + moduleId: position.stockUnitModuleId, + resourceId: position.stockUnitResourceId, + resourceType: position.stockUnitResourceType, + tenantId: position.stockUnitTenantId, + }, + }, + candidates: [...candidatesById.values()].map(({ confirmation, lifecycleMeaning }) => ({ + allocations: confirmation.reservation.requirements.flatMap(({ allocations }) => allocations), + confirmation, + poolBoundary: lifecycleMeaning === 'COMMITTED_OBLIGATION' ? 'COMMITTED_OBLIGATION' : 'NONE', + })), + }).pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + const fencedAmount = yield* deriveReservationShortageFencedAmount(evaluationInput).pipe( + Effect.mapError((cause) => unavailable(trigger, cause)), + ); + return { + causeEvidenceRef: exactSource.evidenceRef, + evaluationInput, + fencedAmount, + positionRevision: position.revision, + }; + }); + + const apply: ReservationShortageImpactPersistence['apply'] = Effect.fn('ReservationShortageImpactPersistence.apply')( + function* applyImpact(trigger, context, evaluation) { + const evaluationMetadata = Match.value(evaluation).pipe( + Match.tag('DETERMINATE', ({ decisions }) => ({ + decisionCount: decisions.length, + reason: null, + reconciliationRequired: false, + status: 'DETERMINATE' as const, + })), + Match.tag('INDETERMINATE', ({ candidateRefs, reason }) => ({ + decisionCount: candidateRefs.length, + reason, + reconciliationRequired: true, + status: 'INDETERMINATE' as const, + })), + Match.exhaustive, + ); + const [inserted] = yield* transaction + .insert(inventoryReservationShortageImpacts) + .values({ + availableAmount: context.evaluationInput.availableQuantity.amount, + changeId: trigger.changeId, + changeKind: trigger.changeKind, + fencedAmount: context.fencedAmount, + occurredAt: instantAsDate(trigger.occurredAt), + positionId: trigger.positionRef.resourceId, + positionRevision: context.positionRevision, + tenantId: scope.tenantId, + ...evaluationMetadata, + ...sourceValues(trigger), + }) + .onConflictDoNothing() + .returning() + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + if (inserted === undefined) { + return; + } + + const confirmationPersistence = reservationConfirmationPersistenceForScope(transaction, scope); + const candidates = new Map( + context.evaluationInput.candidates.map((candidate) => [candidate.confirmation.ref.resourceId, candidate]), + ); + /* oxlint-disable effect-native/prefer-effect-fn-for-operations, sonarjs/no-nested-functions -- This ordered transaction fold must retain the preceding Confirmation revision before writing each decision; expires: 2027-03-31. */ + const decisionValues = yield* Match.value(evaluation).pipe( + Match.tag('DETERMINATE', ({ decisions }) => + Effect.forEach( + decisions, + (decision, index) => + Effect.gen(function* makeDeterminateDecision() { + const candidate = candidates.get(decision.confirmationRef.resourceId); + if (candidate === undefined) { + return yield* unavailable(trigger); + } + const before = candidate.confirmation; + const after = + decision.capacity === 'SHORTAGE' && before.health.state === 'VALID' + ? yield* advanceReservationConfirmationHealth(before, { + _tag: 'MATERIAL_IMPAIRMENT', + effectiveAt: trigger.occurredAt, + ownerEvidenceRef: healthEvidenceRef(trigger, context.causeEvidenceRef), + }).pipe(Effect.mapError((cause) => unavailable(trigger, cause))) + : before; + if (after.revision !== before.revision) { + yield* confirmationPersistence + .saveRevision({ current: before, next: after }) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + } + return { + affectedAmount: decision.affectedQuantity.amount, + changeId: trigger.changeId, + changeKind: trigger.changeKind, + confirmationId: decision.confirmationRef.resourceId, + confirmationRevisionAfter: after.revision, + confirmationRevisionBefore: before.revision, + decision: decision.capacity, + healthAfter: after.health.state, + healthBefore: before.health.state, + priorityOrdinal: index + 1, + rankIssuedAt: instantAsDate(decision.issuanceRank.issuedAt), + rankOwnerEvidenceRef: decision.issuanceRank.ownerEvidenceRef, + tenantId: scope.tenantId, + } satisfies typeof inventoryReservationShortageImpactDecisions.$inferInsert; + }), + { concurrency: 1 }, + ), + ), + Match.tag('INDETERMINATE', ({ candidateRefs }) => + Effect.forEach( + candidateRefs, + (confirmationRef) => { + const candidate = candidates.get(confirmationRef.resourceId); + if (candidate === undefined) { + return Effect.fail(unavailable(trigger)); + } + const { confirmation } = candidate; + return Effect.succeed({ + affectedAmount: null, + changeId: trigger.changeId, + changeKind: trigger.changeKind, + confirmationId: confirmation.ref.resourceId, + confirmationRevisionAfter: confirmation.revision, + confirmationRevisionBefore: confirmation.revision, + decision: 'ORDER_UNRESOLVABLE', + healthAfter: confirmation.health.state, + healthBefore: confirmation.health.state, + priorityOrdinal: null, + rankIssuedAt: instantAsDate(confirmation.issuanceRank.issuedAt), + rankOwnerEvidenceRef: confirmation.issuanceRank.ownerEvidenceRef, + tenantId: scope.tenantId, + } satisfies typeof inventoryReservationShortageImpactDecisions.$inferInsert); + }, + { concurrency: 1 }, + ), + ), + Match.exhaustive, + ); + /* oxlint-enable effect-native/prefer-effect-fn-for-operations, sonarjs/no-nested-functions */ + if (decisionValues.length > 0) { + yield* transaction + .insert(inventoryReservationShortageImpactDecisions) + .values(decisionValues) + .pipe(Effect.mapError((cause) => unavailable(trigger, cause))); + } + }, + ); + + return Object.freeze({ apply, findApplied, readContext }); +}; + +export const reservationShortageImpactPersistenceForWorkerScope = ( + scope: OutboxWorkerLegalEntityScope, +): ReservationShortageImpactPersistence => ({ + apply: (trigger, _context, evaluation) => + scope.routineInvoker + .invoke(applyReservationShortageImpactForWorkerRoutine, [ + trigger.changeKind, + trigger.changeId, + trigger.positionRef.resourceId, + trigger.occurredAt, + evaluation, + ]) + .pipe( + Effect.mapError((cause) => unavailable(trigger, cause)), + Effect.flatMap(([row]) => (row?.applied === true ? Effect.void : Effect.fail(unavailable(trigger)))), + ), + findApplied: (trigger) => + scope.routineInvoker + .invoke(findReservationShortageImpactForWorkerRoutine, [trigger.changeKind, trigger.changeId]) + .pipe( + Effect.mapError((cause) => unavailable(trigger, cause)), + Effect.map(([row]) => (row?.found === true ? Option.some({ trigger }) : Option.none())), + ), + readContext: (trigger) => + scope.routineInvoker + .invoke(readReservationShortageImpactContextForWorkerRoutine, [ + trigger.changeKind, + trigger.changeId, + trigger.positionRef.resourceId, + trigger.occurredAt, + ]) + .pipe( + Effect.mapError((cause) => unavailable(trigger, cause)), + Effect.flatMap(([row]) => + row === undefined ? Effect.fail(unavailable(trigger)) : Effect.succeed(row.context), + ), + ), +}); diff --git a/app/verticals/inventory/src/persistence/reservation-shortage-impact-table.ts b/app/verticals/inventory/src/persistence/reservation-shortage-impact-table.ts new file mode 100644 index 000000000..33050d6be --- /dev/null +++ b/app/verticals/inventory/src/persistence/reservation-shortage-impact-table.ts @@ -0,0 +1,174 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { + boolean, + check, + foreignKey, + index, + integer, + numeric, + primaryKey, + text, + timestamp, + uniqueIndex, + uuid, +} from 'drizzle-orm/pg-core'; + +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; +import { inventoryReservationConfirmations } from './reservation-confirmation-table.ts'; +import { inventoryStockCorrections } from './stock-correction-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +export const inventoryReservationShortageImpacts = inventorySchema.table.withRLS( + 'reservation_shortage_impacts', + { + tenantId: uuid('tenant_id').notNull(), + changeKind: text('change_kind').notNull(), + changeId: uuid('change_id').notNull(), + physicalEffectId: uuid('physical_effect_id'), + stockCorrectionId: uuid('stock_correction_id'), + positionId: uuid('position_id').notNull(), + positionRevision: integer('position_revision').notNull(), + availableAmount: numeric('available_amount', { precision: 38, scale: 9 }).notNull(), + fencedAmount: numeric('fenced_amount', { precision: 38, scale: 9 }).notNull(), + occurredAt: timestamp('occurred_at', { withTimezone: true }).notNull(), + status: text('status').notNull(), + reconciliationRequired: boolean('reconciliation_required').notNull(), + reason: text('reason'), + decisionCount: integer('decision_count').notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.changeKind, table.changeId], + name: 'inventory_reservation_shortage_impacts_pk', + }), + uniqueIndex('inventory_reservation_shortage_impacts_effect_uk') + .on(table.tenantId, table.physicalEffectId) + .where(sql`${table.physicalEffectId} is not null`), + uniqueIndex('inventory_reservation_shortage_impacts_correction_uk') + .on(table.tenantId, table.stockCorrectionId) + .where(sql`${table.stockCorrectionId} is not null`), + index('inventory_reservation_shortage_impacts_position_time_idx').on( + table.tenantId, + table.positionId, + table.occurredAt, + ), + index('inventory_reservation_shortage_impacts_unresolved_idx') + .on(table.tenantId, table.positionId) + .where(sql`${table.status} = 'INDETERMINATE'`), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_reservation_shortage_impacts_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.physicalEffectId], + foreignColumns: [inventoryPhysicalStockEffects.tenantId, inventoryPhysicalStockEffects.effectId], + name: 'inventory_reservation_shortage_impacts_effect_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockCorrectionId], + foreignColumns: [inventoryStockCorrections.tenantId, inventoryStockCorrections.correctionId], + name: 'inventory_reservation_shortage_impacts_correction_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_shortage_impacts_source_ck', + sql`(${table.changeKind} in ('RECEIPT', 'ISSUE') and ${table.physicalEffectId} = ${table.changeId} and ${table.stockCorrectionId} is null) or (${table.changeKind} = 'CORRECTION' and ${table.stockCorrectionId} = ${table.changeId} and ${table.physicalEffectId} is null)`, + ), + check( + 'inventory_reservation_shortage_impacts_outcome_ck', + sql`(${table.status} = 'DETERMINATE' and ${table.reconciliationRequired} = false and ${table.reason} is null) or (${table.status} = 'INDETERMINATE' and ${table.reconciliationRequired} = true and ${table.reason} = 'AUTHORITATIVE_ISSUANCE_ORDER_UNRESOLVABLE')`, + ), + check( + 'inventory_reservation_shortage_impacts_quantity_ck', + sql`${table.positionRevision} >= 1 and ${table.availableAmount} >= 0 and ${table.fencedAmount} >= 0 and ${table.decisionCount} >= 0`, + ), + ...tenantRlsPolicies('inventory_reservation_shortage_impacts_tenant', table.tenantId), + ], +); + +export const inventoryReservationShortageImpactDecisions = inventorySchema.table.withRLS( + 'reservation_shortage_impact_decisions', + { + tenantId: uuid('tenant_id').notNull(), + changeKind: text('change_kind').notNull(), + changeId: uuid('change_id').notNull(), + confirmationId: uuid('confirmation_id').notNull(), + priorityOrdinal: integer('priority_ordinal'), + decision: text('decision').notNull(), + affectedAmount: numeric('affected_amount', { precision: 38, scale: 9 }), + healthBefore: text('health_before').notNull(), + healthAfter: text('health_after').notNull(), + confirmationRevisionBefore: integer('confirmation_revision_before').notNull(), + confirmationRevisionAfter: integer('confirmation_revision_after').notNull(), + rankIssuedAt: timestamp('rank_issued_at', { withTimezone: true }).notNull(), + rankOwnerEvidenceRef: text('rank_owner_evidence_ref').notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.changeKind, table.changeId, table.confirmationId], + name: 'inventory_reservation_shortage_impact_decisions_pk', + }), + uniqueIndex('inventory_reservation_shortage_impact_decisions_priority_uk') + .on(table.tenantId, table.changeKind, table.changeId, table.priorityOrdinal) + .where(sql`${table.priorityOrdinal} is not null`), + index('inventory_reservation_shortage_impact_decisions_confirmation_idx').on( + table.tenantId, + table.confirmationId, + table.recordedAt, + ), + foreignKey({ + columns: [table.tenantId, table.changeKind, table.changeId], + foreignColumns: [ + inventoryReservationShortageImpacts.tenantId, + inventoryReservationShortageImpacts.changeKind, + inventoryReservationShortageImpacts.changeId, + ], + name: 'inventory_reservation_shortage_impact_decisions_impact_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.confirmationId], + foreignColumns: [inventoryReservationConfirmations.tenantId, inventoryReservationConfirmations.confirmationId], + name: 'inventory_reservation_shortage_impact_decisions_confirmation_fk', + }).onDelete('restrict'), + check( + 'inventory_reservation_shortage_impact_decisions_meaning_ck', + sql`${table.decision} in ('HONORABLE', 'SHORTAGE', 'ORDER_UNRESOLVABLE') and ${table.healthBefore} in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and ${table.healthAfter} in ('VALID', 'AT_RISK', 'UNVERIFIABLE') and ${table.confirmationRevisionBefore} >= 1 and ${table.confirmationRevisionAfter} >= ${table.confirmationRevisionBefore} and char_length(btrim(${table.rankOwnerEvidenceRef})) between 1 and 300 and ((${table.decision} = 'ORDER_UNRESOLVABLE' and ${table.priorityOrdinal} is null and ${table.affectedAmount} is null) or (${table.decision} in ('HONORABLE', 'SHORTAGE') and ${table.priorityOrdinal} >= 1 and ${table.affectedAmount} > 0))`, + ), + ...tenantRlsPolicies('inventory_reservation_shortage_impact_decisions_tenant', table.tenantId), + ], +); + +export const inventoryReservationShortageImpactContract = { + decisionSet: { + constraintTrigger: 'inventory_reservation_shortage_impacts_decision_set_trg', + functionName: 'inventory.verify_reservation_shortage_impact_decisions', + timing: 'AFTER INSERT DEFERRABLE INITIALLY DEFERRED', + }, + immutability: { + functionName: 'inventory.reject_reservation_shortage_impact_mutation', + tables: ['inventory.reservation_shortage_impacts', 'inventory.reservation_shortage_impact_decisions'], + triggers: [ + 'inventory_reservation_shortage_impacts_no_mutation_trg', + 'inventory_reservation_shortage_impact_decisions_no_mutation_trg', + ], + }, + routines: { + apply: 'inventory.apply_reservation_shortage_impact_for_worker', + find: 'inventory.find_reservation_shortage_impact_for_worker', + readContext: 'inventory.read_reservation_shortage_impact_context_for_worker', + }, + source: { + functionName: 'inventory.enforce_reservation_shortage_impact_source', + triggerName: 'inventory_reservation_shortage_impacts_source_trg', + }, +} as const; + +export const INVENTORY_RESERVATION_SHORTAGE_IMPACT_TABLES = [ + inventoryReservationShortageImpactDecisions, + inventoryReservationShortageImpacts, +] as const; diff --git a/app/verticals/inventory/src/persistence/stock-correction-repository.ts b/app/verticals/inventory/src/persistence/stock-correction-repository.ts new file mode 100644 index 000000000..5de625cf0 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-correction-repository.ts @@ -0,0 +1,594 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq } from 'drizzle-orm'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { + PhysicalStockEffectIdSchema, + PhysicalStockEffectRecordSchema, +} from '../../shared/domain/physical-stock-effect.ts'; +import type { PhysicalStockEffectRecord } from '../../shared/domain/physical-stock-effect.ts'; +import { + AppliedStockCorrectionSchema, + IndeterminateStockCorrectionSchema, + StockCorrectionConflict, + StockCorrectionRecordSchema, + StockCorrectionRejected, + StockCorrectionUnavailable, +} from '../../shared/domain/stock-correction.ts'; +import type { StockCorrectionId, StockCorrectionRecord } from '../../shared/domain/stock-correction.ts'; +import { + CurrentOnHandEvidenceSchema, + IndeterminateOnHandEvidenceSchema, + StockPositionSchema, +} from '../../shared/domain/stock-position.ts'; +import type { StockPosition, StockPositionOnHandEvidence } from '../../shared/domain/stock-position.ts'; +import type { StockPositionRef } from '../../shared/resources/stock-position.ts'; +import type { StockCorrectionPersistence } from '../services/stock-correction.service.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; +import { inventoryStockCorrectionOpenReconciliations, inventoryStockCorrections } from './stock-correction-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type StockPositionRow = typeof inventoryStockPositions.$inferSelect; + +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; +const STOCK_POSITION_RESOURCE_TYPE = 'commerce.inventory.stock-position' as const; + +const unavailable = (correctionId?: StockCorrectionId, cause?: unknown) => { + const failure = + correctionId === undefined + ? new StockCorrectionUnavailable({ + code: 'stock_correction_unavailable', + reason: 'Stock Correction persistence is temporarily unavailable', + retryable: true, + }) + : new StockCorrectionUnavailable({ + code: 'stock_correction_unavailable', + correctionId, + reason: 'Stock Correction persistence is temporarily unavailable', + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const conflict = (correctionId: StockCorrectionId, reason: StockCorrectionConflict['reason'], cause?: unknown) => { + const failure = new StockCorrectionConflict({ code: 'stock_correction_conflict', correctionId, reason }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const rejected = (correctionId: StockCorrectionId, reason: StockCorrectionRejected['reason'], cause?: unknown) => { + const failure = new StockCorrectionRejected({ code: 'stock_correction_rejected', correctionId, reason }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const uniqueViolationSqlState = ['23', '505'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); + +const mapCorrectionWriteError = (correctionId: StockCorrectionId, cause: unknown) => { + const postgres = findPostgresFailure(cause, () => true); + if (Option.isNone(postgres)) { + return unavailable(correctionId, cause); + } + const { code, constraint } = postgres.value; + if (code === uniqueViolationSqlState) { + if (constraint === 'inventory_stock_corrections_assertion_uk') { + return conflict(correctionId, 'ASSERTION_ALREADY_USED', cause); + } + if (constraint === 'inventory_stock_corrections_source_evidence_uk') { + return conflict(correctionId, 'EVIDENCE_ALREADY_USED', cause); + } + if (constraint === 'inventory_stock_corrections_reconciles_uk') { + return conflict(correctionId, 'OPEN_RECONCILIATION_MISMATCH', cause); + } + if (constraint === 'stock_corrections_pkey' || constraint === 'inventory_stock_corrections_tenant_id_uk') { + return conflict(correctionId, 'CORRECTION_ID_CONFLICT', cause); + } + } + if (code === foreignKeyViolationSqlState) { + if (constraint === 'inventory_stock_corrections_assertion_fk') { + return rejected(correctionId, 'SOURCE_ASSERTION_NOT_FOUND', cause); + } + if (constraint === 'inventory_stock_corrections_source_evidence_fk') { + return rejected(correctionId, 'SOURCE_EVIDENCE_NOT_FOUND', cause); + } + if (constraint === 'inventory_stock_corrections_position_fk') { + return rejected(correctionId, 'POSITION_NOT_FOUND', cause); + } + if (constraint === 'inventory_stock_corrections_authority_fk') { + return rejected(correctionId, 'AUTHORITY_NOT_SELECTED', cause); + } + if (constraint === 'inventory_stock_corrections_reconciles_fk') { + return conflict(correctionId, 'OPEN_RECONCILIATION_MISMATCH', cause); + } + } + if (code === checkViolationSqlState && constraint === 'inventory_stock_correction_open_transition_ck') { + return conflict(correctionId, 'OPEN_RECONCILIATION_MISMATCH', cause); + } + if (code === checkViolationSqlState && constraint === 'inventory_stock_corrections_exact_scope_ck') { + return rejected(correctionId, 'SOURCE_ASSERTION_SCOPE_MISMATCH', cause); + } + if (code === checkViolationSqlState && constraint === 'inventory_stock_corrections_evidence_ck') { + return rejected(correctionId, 'CORRECTION_NOT_PERMITTED', cause); + } + return unavailable(correctionId, cause); +}; + +const positionRefFor = (row: StockPositionRow) => ({ + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockPositionId, + resourceType: STOCK_POSITION_RESOURCE_TYPE, + tenantId: row.tenantId, +}); + +const unitRefFor = (row: StockPositionRow) => ({ + moduleId: row.stockUnitModuleId, + resourceId: row.stockUnitResourceId, + resourceType: row.stockUnitResourceType, + tenantId: row.stockUnitTenantId, +}); + +const authorityRefFor = (row: StockPositionRow) => ({ + moduleId: INVENTORY_MODULE_ID, + resourceId: row.ownerConfigurationId, + resourceType: 'commerce.inventory.inventory-backend-configuration' as const, + tenantId: row.tenantId, +}); + +const storedNumericPattern = /^(?[0-9]+)(?:\.(?[0-9]+))?$/u; + +const canonicalAmount = (amount: string | null): string => { + if (amount === null) { + return ''; + } + const groups = storedNumericPattern.exec(amount)?.groups; + if (groups?.['integer'] === undefined) { + return amount; + } + const integer = BigInt(groups['integer']).toString(); + const fraction = (groups['fraction'] ?? '').replace(/0+$/u, ''); + return fraction.length === 0 ? integer : `${integer}.${fraction}`; +}; + +const onHandFor = (row: StockPositionRow) => { + const ownerConfigurationRef = authorityRefFor(row); + const unitRef = unitRefFor(row); + if (row.onHandState === 'CURRENT') { + return { + _tag: 'CURRENT', + evidenceRef: row.onHandEvidenceRef ?? '', + meaning: 'ON_HAND', + observedAt: row.onHandObservedAt?.toISOString() ?? '', + ownerConfigurationRef, + quantity: { amount: canonicalAmount(row.onHandAmount), unitRef }, + } as const; + } + if (row.onHandState === 'STALE') { + return { + _tag: 'STALE', + evidenceRef: row.onHandEvidenceRef ?? '', + lastKnownQuantity: { amount: canonicalAmount(row.onHandAmount), unitRef }, + lastObservedAt: row.onHandObservedAt?.toISOString() ?? '', + meaning: 'ON_HAND', + ownerConfigurationRef, + } as const; + } + return { _tag: row.onHandState, meaning: 'ON_HAND' as const, ownerConfigurationRef, unitRef }; +}; + +const decodePositionRow = (row: StockPositionRow) => + Schema.decodeUnknownEffect(StockPositionSchema)({ + createdAt: row.createdAt.toISOString(), + endedAt: row.endedAt?.toISOString() ?? null, + lifecycle: row.lifecycleState, + onHand: onHandFor(row), + ref: positionRefFor(row), + revision: row.revision, + scope: { + customerConfigurationId: row.customerConfigurationId, + stockItemRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockItemId, + resourceType: 'commerce.inventory.stock-item', + tenantId: row.tenantId, + }, + stockLocationRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockLocationId, + resourceType: 'commerce.inventory.stock-location', + tenantId: row.tenantId, + }, + unitRef: unitRefFor(row), + }, + }).pipe(Effect.mapError((cause) => unavailable(undefined, cause))); + +const evidenceValues = (onHand: StockPositionOnHandEvidence) => + Match.value(onHand).pipe( + Match.tag('CURRENT', (current) => ({ + onHandAmount: current.quantity.amount, + onHandEvidenceRef: current.evidenceRef, + onHandObservedAt: DateTime.toDateUtc(DateTime.makeUnsafe(current.observedAt)), + onHandState: current._tag, + ownerConfigurationId: current.ownerConfigurationRef.resourceId, + })), + Match.tag('STALE', (stale) => ({ + onHandAmount: stale.lastKnownQuantity.amount, + onHandEvidenceRef: stale.evidenceRef, + onHandObservedAt: DateTime.toDateUtc(DateTime.makeUnsafe(stale.lastObservedAt)), + onHandState: stale._tag, + ownerConfigurationId: stale.ownerConfigurationRef.resourceId, + })), + Match.tag('UNKNOWN', 'MISSING', 'INDETERMINATE', (indeterminate) => ({ + onHandAmount: null, + onHandEvidenceRef: null, + onHandObservedAt: null, + onHandState: indeterminate._tag, + ownerConfigurationId: indeterminate.ownerConfigurationRef.resourceId, + })), + Match.exhaustive, + ); + +const decodeCorrectionRow = (row: typeof inventoryStockCorrections.$inferSelect) => + Schema.decodeEffect(StockCorrectionRecordSchema)(row.recordJson).pipe( + Effect.mapError((cause) => unavailable(undefined, cause)), + ); + +const physicalEffectCandidate = (row: typeof inventoryPhysicalStockEffects.$inferSelect) => { + if (row.state === 'APPLIED') { + return { _tag: row.state, evidence: row.evidenceJson, request: row.requestJson }; + } + if (row.state === 'REJECTED' || row.state === 'INDETERMINATE') { + return { _tag: row.state, reason: row.terminalReason, request: row.requestJson }; + } + return { _tag: 'REQUESTED', request: row.requestJson }; +}; + +const decodePhysicalEffectRow = (row: typeof inventoryPhysicalStockEffects.$inferSelect) => + Schema.decodeEffect(PhysicalStockEffectIdSchema)(row.effectId).pipe( + Effect.mapError((cause) => unavailable(undefined, cause)), + Effect.flatMap(() => + Schema.decodeUnknownEffect(PhysicalStockEffectRecordSchema)(physicalEffectCandidate(row)).pipe( + Effect.mapError((cause) => unavailable(undefined, cause)), + ), + ), + ); + +const sameRef = ( + left: { readonly resourceId: string; readonly tenantId: string }, + right: { readonly resourceId: string; readonly tenantId: string }, +) => left.resourceId === right.resourceId && left.tenantId === right.tenantId; + +const sameUnit = (left: StockPosition['scope']['unitRef'], right: StockPosition['scope']['unitRef']) => + left.moduleId === right.moduleId && + left.resourceId === right.resourceId && + left.resourceType === right.resourceType && + left.tenantId === right.tenantId; + +const validEvidenceBranch = (correction: StockCorrectionRecord): boolean => { + if (correction.evidenceKind === 'EXTERNAL_SOURCE_ASSERTION') { + return correction.sourceAssertionId !== null && correction.issuer.backendKind === 'external_business_system'; + } + return correction.sourceAssertionId === null && correction.issuer.backendKind === 'ontos_wms'; +}; + +const validateCorrectionOutcome = (correction: StockCorrectionRecord, nextPosition: StockPosition) => { + if (Schema.is(AppliedStockCorrectionSchema)(correction)) { + if (!Schema.is(CurrentOnHandEvidenceSchema)(nextPosition.onHand)) { + return rejected(correction.correctionId, 'CORRECTION_NOT_PERMITTED'); + } + if (!sameUnit(correction.correctedQuantity.unitRef, nextPosition.onHand.quantity.unitRef)) { + return rejected(correction.correctionId, 'UNIT_MISMATCH'); + } + return correction.correctedQuantity.amount === nextPosition.onHand.quantity.amount + ? null + : rejected(correction.correctionId, 'SOURCE_ASSERTION_SCOPE_MISMATCH'); + } + return Schema.is(IndeterminateOnHandEvidenceSchema)(nextPosition.onHand) + ? null + : rejected(correction.correctionId, 'CORRECTION_NOT_PERMITTED'); +}; + +const validateApply = ( + correction: StockCorrectionRecord, + nextPosition: StockPosition, + expectedPositionRevision: number, + reconcilesCorrectionId: StockCorrectionId | undefined, + tenantId: string, +) => { + if (correction.positionRef.tenantId !== tenantId || nextPosition.ref.tenantId !== tenantId) { + return rejected(correction.correctionId, 'TENANT_SCOPE_MISMATCH'); + } + if ( + !Schema.is(StockCorrectionRecordSchema)(correction) || + !Schema.is(StockPositionSchema)(nextPosition) || + !sameRef(correction.positionRef, nextPosition.ref) + ) { + return rejected(correction.correctionId, 'SOURCE_ASSERTION_SCOPE_MISMATCH'); + } + if ( + correction.customerConfigurationId !== nextPosition.scope.customerConfigurationId || + correction.authorityConfigurationRef.resourceId !== nextPosition.onHand.ownerConfigurationRef.resourceId + ) { + return rejected(correction.correctionId, 'CUSTOMER_CONFIGURATION_MISMATCH'); + } + if ( + correction.expectedPositionRevision !== expectedPositionRevision || + correction.positionRevisionAfter !== nextPosition.revision || + nextPosition.revision !== expectedPositionRevision + 1 + ) { + return conflict(correction.correctionId, 'POSITION_REVISION_CONFLICT'); + } + if (nextPosition.lifecycle !== 'CURRENT' || nextPosition.endedAt !== null) { + return rejected(correction.correctionId, 'POSITION_NOT_CURRENT'); + } + if (correction.reconcilesCorrectionId !== (reconcilesCorrectionId ?? null)) { + return conflict(correction.correctionId, 'OPEN_RECONCILIATION_MISMATCH'); + } + if (!validEvidenceBranch(correction)) { + return rejected(correction.correctionId, 'CORRECTION_NOT_PERMITTED'); + } + return validateCorrectionOutcome(correction, nextPosition); +}; + +/** Keeps the mutually exclusive owner-evidence identity explicit in the relational insert. */ +export const stockCorrectionEvidenceIdentityValues = ( + correction: Pick, +) => ({ + evidenceKind: correction.evidenceKind, + sourceAssertionId: correction.sourceAssertionId, + sourceEvidenceId: correction.sourceEvidenceId, +}); + +export const stockCorrectionPersistenceForScope = ( + transaction: ScopedTransaction, + scope: Pick, +): StockCorrectionPersistence => { + const correctionRows = (correctionId: StockCorrectionId) => + transaction + .select() + .from(inventoryStockCorrections) + .where( + and( + eq(inventoryStockCorrections.tenantId, scope.tenantId), + eq(inventoryStockCorrections.correctionId, correctionId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(correctionId, cause))); + + const positionRows = (positionRef: StockPositionRef) => + transaction + .select() + .from(inventoryStockPositions) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.stockPositionId, positionRef.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(undefined, cause))); + + const read: StockCorrectionPersistence['read'] = (correctionId) => + correctionRows(correctionId).pipe( + Effect.flatMap(([row]) => + row === undefined ? Effect.succeedNone : decodeCorrectionRow(row).pipe(Effect.asSome), + ), + ); + + const openReconciliationRows = (positionRef: StockPositionRef, forUpdate: boolean) => { + const query = transaction + .select({ correction: inventoryStockCorrections }) + .from(inventoryStockCorrectionOpenReconciliations) + .innerJoin( + inventoryStockCorrections, + and( + eq(inventoryStockCorrections.tenantId, inventoryStockCorrectionOpenReconciliations.tenantId), + eq(inventoryStockCorrections.correctionId, inventoryStockCorrectionOpenReconciliations.correctionId), + ), + ) + .where( + and( + eq(inventoryStockCorrectionOpenReconciliations.tenantId, scope.tenantId), + eq(inventoryStockCorrectionOpenReconciliations.positionId, positionRef.resourceId), + ), + ) + .limit(1); + return (forUpdate ? query.for('update') : query).pipe(Effect.mapError((cause) => unavailable(undefined, cause))); + }; + + const findOpenIndeterminate: StockCorrectionPersistence['findOpenIndeterminate'] = (positionRef) => { + if (positionRef.tenantId === scope.tenantId) { + return openReconciliationRows(positionRef, false).pipe( + Effect.flatMap(([row]) => + row === undefined ? Effect.succeedNone : decodeCorrectionRow(row.correction).pipe(Effect.asSome), + ), + ); + } + return Effect.fail(unavailable()); + }; + + const listAppliedEffectsForPosition: StockCorrectionPersistence['listAppliedEffectsForPosition'] = (positionRef) => { + if (positionRef.tenantId !== scope.tenantId) { + return Effect.fail(unavailable()); + } + return transaction + .select() + .from(inventoryPhysicalStockEffects) + .where( + and( + eq(inventoryPhysicalStockEffects.tenantId, scope.tenantId), + eq(inventoryPhysicalStockEffects.positionId, positionRef.resourceId), + eq(inventoryPhysicalStockEffects.state, 'APPLIED'), + ), + ) + .orderBy(asc(inventoryPhysicalStockEffects.requestedAt), asc(inventoryPhysicalStockEffects.effectId)) + .pipe( + Effect.mapError((cause) => unavailable(undefined, cause)), + Effect.flatMap((rows) => Effect.forEach(rows, (row) => decodePhysicalEffectRow(row), { concurrency: 1 })), + Effect.map((effects): readonly PhysicalStockEffectRecord[] => effects), + ); + }; + + const readCurrentPosition = Effect.fn('StockCorrectionPersistence.readCurrentPosition')(function* readPosition( + positionRef: StockPositionRef, + correctionId: StockCorrectionId, + ) { + const [row] = yield* positionRows(positionRef); + if (row === undefined) { + return yield* rejected(correctionId, 'POSITION_NOT_FOUND'); + } + return yield* decodePositionRow(row).pipe(Effect.mapError((cause) => unavailable(correctionId, cause))); + }); + + const apply: StockCorrectionPersistence['apply'] = Effect.fn('StockCorrectionPersistence.apply')( + function* applyCorrection(correction, nextPosition, expectedPositionRevision, reconcilesCorrectionId) { + const invalid = validateApply( + correction, + nextPosition, + expectedPositionRevision, + reconcilesCorrectionId, + scope.tenantId, + ); + if (invalid !== null) { + return yield* invalid; + } + + const [known] = yield* correctionRows(correction.correctionId); + if (known !== undefined) { + return { + correction: yield* decodeCorrectionRow(known), + outcome: 'EXISTING' as const, + position: yield* readCurrentPosition(correction.positionRef, correction.correctionId), + }; + } + + const [open] = yield* openReconciliationRows(correction.positionRef, true); + const openCorrectionId = open?.correction.correctionId; + if (openCorrectionId !== reconcilesCorrectionId) { + return yield* conflict(correction.correctionId, 'OPEN_RECONCILIATION_MISMATCH'); + } + + const [inserted] = yield* transaction + .insert(inventoryStockCorrections) + .values({ + actionInvocationId: correction.actionInvocationId, + appliedAt: DateTime.toDateUtc(DateTime.makeUnsafe(correction.appliedAt)), + authorityConfigurationId: correction.authorityConfigurationRef.resourceId, + businessObservedAt: DateTime.toDateUtc(DateTime.makeUnsafe(correction.businessObservedAt)), + correctedQuantityAmount: Match.value(correction).pipe( + Match.tag('APPLIED', ({ correctedQuantity }) => correctedQuantity.amount), + Match.tag('INDETERMINATE', () => null), + Match.exhaustive, + ), + correctionId: correction.correctionId, + coverageEvidenceJson: correction.coverageEvidence, + customerConfigurationId: correction.customerConfigurationId, + evaluatedMaterialEffectIdsJson: correction.evaluatedMaterialEffectIds, + ...stockCorrectionEvidenceIdentityValues(correction), + expectedPositionRevision, + issuerBackendId: correction.issuer.backendId, + issuerBackendKind: correction.issuer.backendKind, + ownerEvidenceRef: correction.ownerEvidenceRef, + positionId: correction.positionRef.resourceId, + positionRevisionAfter: correction.positionRevisionAfter, + principalId: correction.principalId, + reconcilesCorrectionId: reconcilesCorrectionId ?? null, + recordJson: correction, + sourceReference: correction.sourceReference, + state: correction._tag, + tenantId: scope.tenantId, + }) + .onConflictDoNothing({ target: inventoryStockCorrections.correctionId }) + .returning() + .pipe(Effect.mapError((cause) => mapCorrectionWriteError(correction.correctionId, cause))); + + if (inserted === undefined) { + const [existing] = yield* correctionRows(correction.correctionId); + if (existing === undefined) { + return yield* unavailable(correction.correctionId); + } + return { + correction: yield* decodeCorrectionRow(existing), + outcome: 'EXISTING' as const, + position: yield* readCurrentPosition(correction.positionRef, correction.correctionId), + }; + } + + const now = DateTime.toDateUtc(yield* DateTime.now); + const [updatedPosition] = yield* transaction + .update(inventoryStockPositions) + .set({ ...evidenceValues(nextPosition.onHand), revision: nextPosition.revision, updatedAt: now }) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.stockPositionId, nextPosition.ref.resourceId), + eq(inventoryStockPositions.lifecycleState, 'CURRENT'), + eq(inventoryStockPositions.revision, expectedPositionRevision), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => mapCorrectionWriteError(correction.correctionId, cause))); + if (updatedPosition === undefined) { + const [observed] = yield* positionRows(correction.positionRef); + if (observed === undefined) { + return yield* rejected(correction.correctionId, 'POSITION_NOT_FOUND'); + } + if (observed.lifecycleState === 'CURRENT') { + return yield* conflict(correction.correctionId, 'POSITION_REVISION_CONFLICT'); + } + return yield* rejected(correction.correctionId, 'POSITION_NOT_CURRENT'); + } + + if (Schema.is(IndeterminateStockCorrectionSchema)(correction)) { + yield* transaction + .insert(inventoryStockCorrectionOpenReconciliations) + .values({ + correctionId: correction.correctionId, + positionId: correction.positionRef.resourceId, + tenantId: scope.tenantId, + updatedAt: now, + }) + .onConflictDoUpdate({ + set: { correctionId: correction.correctionId, updatedAt: now }, + target: [ + inventoryStockCorrectionOpenReconciliations.tenantId, + inventoryStockCorrectionOpenReconciliations.positionId, + ], + }) + .pipe(Effect.mapError((cause) => mapCorrectionWriteError(correction.correctionId, cause))); + } else if (openCorrectionId !== undefined) { + yield* transaction + .delete(inventoryStockCorrectionOpenReconciliations) + .where( + and( + eq(inventoryStockCorrectionOpenReconciliations.tenantId, scope.tenantId), + eq(inventoryStockCorrectionOpenReconciliations.positionId, correction.positionRef.resourceId), + eq(inventoryStockCorrectionOpenReconciliations.correctionId, openCorrectionId), + ), + ) + .pipe(Effect.mapError((cause) => mapCorrectionWriteError(correction.correctionId, cause))); + } + + return { + correction: yield* decodeCorrectionRow(inserted), + outcome: 'INSERTED' as const, + position: yield* decodePositionRow(updatedPosition).pipe( + Effect.mapError((cause) => unavailable(correction.correctionId, cause)), + ), + }; + }, + ); + + return Object.freeze({ apply, findOpenIndeterminate, listAppliedEffectsForPosition, read }); +}; diff --git a/app/verticals/inventory/src/persistence/stock-correction-source-evidence-repository.ts b/app/verticals/inventory/src/persistence/stock-correction-source-evidence-repository.ts new file mode 100644 index 000000000..c650e0d7e --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-correction-source-evidence-repository.ts @@ -0,0 +1,250 @@ +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import type { Effect as EffectType } from 'effect'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { OwnerOrderKeyEvidenceSchema } from '../../shared/domain/inventory-source-assertion.ts'; +import { + OntosWmsCorrectionCoverageEvidenceSchema, + OntosWmsStockCorrectionSourceEvidenceSchema, + StockCorrectionUnavailable, +} from '../../shared/domain/stock-correction.ts'; +import type { + OntosWmsStockCorrectionSourceEvidence, + StockCorrectionSourceEvidenceId, +} from '../../shared/domain/stock-correction.ts'; +import type { StockCorrectionSourceEvidencePersistence } from '../services/stock-correction.service.ts'; +import { + inventoryStockCorrectionSourceEvidence, + inventoryStockCorrectionSourceEvidenceCoverage, + inventoryStockCorrectionSourceEvidenceCurrent, +} from './stock-correction-source-evidence-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +/** This writer is private to the trusted OntOS WMS owner boundary; Action payloads never receive it. */ +export interface TrustedStockCorrectionSourceEvidencePersistence extends StockCorrectionSourceEvidencePersistence { + readonly appendTrusted: ( + evidence: OntosWmsStockCorrectionSourceEvidence, + ) => EffectType.Effect; +} + +const unavailable = (evidenceId?: StockCorrectionSourceEvidenceId, cause?: unknown) => { + const failure = new StockCorrectionUnavailable({ + code: 'stock_correction_unavailable', + reason: + evidenceId === undefined + ? 'OntOS WMS correction evidence is temporarily unavailable' + : `OntOS WMS correction evidence ${evidenceId} is temporarily unavailable`, + retryable: true, + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const orderingValue = (evidence: OntosWmsStockCorrectionSourceEvidence) => + Match.value(evidence.orderingEvidence).pipe( + Match.tag('OWNER_ORDER_KEY', ({ key }) => key), + Match.tag('SOURCE_REVISION', ({ revision }) => revision), + Match.exhaustive, + ); + +const evidenceValues = (evidence: OntosWmsStockCorrectionSourceEvidence) => ({ + authorityConfigurationId: evidence.authorityConfiguration.configurationId, + businessObservedAt: instantAsDate(evidence.businessObservedAt), + customerConfigurationId: evidence.customerConfigurationId, + evidenceId: evidence.evidenceId, + evidenceJson: evidence, + factMeaning: evidence.factMeaning, + issuerBackendId: evidence.issuer.backendId, + issuerBackendKind: evidence.issuer.backendKind, + orderingEvidenceKind: evidence.orderingEvidence._tag, + orderingEvidenceValue: orderingValue(evidence), + ownerEvidenceRef: evidence.ownerEvidenceRef, + positionId: evidence.positionRef.resourceId, + quantityAmount: evidence.quantity.amount, + receivedAt: instantAsDate(evidence.receivedAt), + sourceReference: evidence.sourceReference, + stockItemId: evidence.stockItemRef.resourceId, + stockLocationId: evidence.stockLocationRef.resourceId, + tenantId: evidence.positionRef.tenantId, + unitModuleId: evidence.quantity.unitRef.moduleId, + unitResourceId: evidence.quantity.unitRef.resourceId, + unitResourceType: evidence.quantity.unitRef.resourceType, + unitTenantId: evidence.quantity.unitRef.tenantId, +}); + +const coverageMatches = ( + expected: OntosWmsStockCorrectionSourceEvidence['coverage'], + actual: readonly (typeof inventoryStockCorrectionSourceEvidenceCoverage.$inferSelect)[], +) => + expected.length === actual.length && + expected.every((entry) => + actual.some( + (row) => + row.evidenceId === entry.evidenceId && + row.effectId === entry.effectId && + row.ownerEvidenceRef === entry.ownerEvidenceRef && + row.relation === entry.relation, + ), + ); + +const isTrustedAppend = (evidence: OntosWmsStockCorrectionSourceEvidence, tenantId: string) => + Schema.is(OntosWmsStockCorrectionSourceEvidenceSchema)(evidence) && + evidence.positionRef.tenantId === tenantId && + evidence.authorityConfiguration.tenantId === tenantId && + evidence.authorityConfiguration.selection.backend === 'ontos_wms' && + evidence.authorityConfiguration.selection.stockCorrectionCapability === 'SUPPORTED' && + Schema.is(OwnerOrderKeyEvidenceSchema)(evidence.orderingEvidence) && + DateTime.toEpochMillis(DateTime.makeUnsafe(evidence.businessObservedAt)) >= + DateTime.toEpochMillis(DateTime.makeUnsafe(evidence.authorityConfiguration.selectedAt)); + +export const stockCorrectionSourceEvidencePersistenceForScope = ( + transaction: ScopedTransaction, + scope: Pick, +): TrustedStockCorrectionSourceEvidencePersistence => { + const findCurrentById: StockCorrectionSourceEvidencePersistence['findCurrentById'] = Effect.fn( + 'StockCorrectionSourceEvidencePersistence.findCurrentById', + )(function* findCurrentStockCorrectionSourceEvidence(evidenceId) { + const [row] = yield* transaction + .select({ evidenceJson: inventoryStockCorrectionSourceEvidence.evidenceJson }) + .from(inventoryStockCorrectionSourceEvidence) + .innerJoin( + inventoryStockCorrectionSourceEvidenceCurrent, + and( + eq(inventoryStockCorrectionSourceEvidenceCurrent.tenantId, inventoryStockCorrectionSourceEvidence.tenantId), + eq( + inventoryStockCorrectionSourceEvidenceCurrent.customerConfigurationId, + inventoryStockCorrectionSourceEvidence.customerConfigurationId, + ), + eq( + inventoryStockCorrectionSourceEvidenceCurrent.authorityConfigurationId, + inventoryStockCorrectionSourceEvidence.authorityConfigurationId, + ), + eq( + inventoryStockCorrectionSourceEvidenceCurrent.positionId, + inventoryStockCorrectionSourceEvidence.positionId, + ), + eq( + inventoryStockCorrectionSourceEvidenceCurrent.evidenceId, + inventoryStockCorrectionSourceEvidence.evidenceId, + ), + eq( + inventoryStockCorrectionSourceEvidenceCurrent.orderingEvidenceKind, + inventoryStockCorrectionSourceEvidence.orderingEvidenceKind, + ), + eq( + inventoryStockCorrectionSourceEvidenceCurrent.orderingEvidenceValue, + inventoryStockCorrectionSourceEvidence.orderingEvidenceValue, + ), + ), + ) + .where( + and( + eq(inventoryStockCorrectionSourceEvidence.tenantId, scope.tenantId), + eq(inventoryStockCorrectionSourceEvidence.evidenceId, evidenceId), + ), + ) + .limit(1) + .pipe(Effect.mapError((cause) => unavailable(evidenceId, cause))); + if (row === undefined) { + return Option.none(); + } + const coverage = yield* transaction + .select() + .from(inventoryStockCorrectionSourceEvidenceCoverage) + .where( + and( + eq(inventoryStockCorrectionSourceEvidenceCoverage.tenantId, scope.tenantId), + eq(inventoryStockCorrectionSourceEvidenceCoverage.evidenceId, evidenceId), + ), + ) + .pipe(Effect.mapError((cause) => unavailable(evidenceId, cause))); + if (!coverageMatches(row.evidenceJson.coverage, coverage)) { + return yield* unavailable(evidenceId); + } + const decodedCoverage = yield* Effect.forEach( + coverage, + (entry) => + Schema.decodeUnknownEffect(OntosWmsCorrectionCoverageEvidenceSchema)({ + effectId: entry.effectId, + evidenceId: entry.evidenceId, + ownerEvidenceRef: entry.ownerEvidenceRef, + relation: entry.relation, + }).pipe(Effect.mapError((cause) => unavailable(evidenceId, cause))), + { concurrency: 1 }, + ); + const decoded = yield* Schema.decodeEffect(OntosWmsStockCorrectionSourceEvidenceSchema)({ + ...row.evidenceJson, + coverage: decodedCoverage, + }).pipe(Effect.mapError((cause) => unavailable(evidenceId, cause))); + return Option.some(decoded); + }); + + const appendTrusted: TrustedStockCorrectionSourceEvidencePersistence['appendTrusted'] = Effect.fn( + 'StockCorrectionSourceEvidencePersistence.appendTrusted', + )(function* appendTrustedStockCorrectionSourceEvidence(evidence) { + if (!isTrustedAppend(evidence, scope.tenantId)) { + return yield* unavailable(evidence.evidenceId); + } + const [inserted] = yield* transaction + .insert(inventoryStockCorrectionSourceEvidence) + .values(evidenceValues(evidence)) + .returning({ evidenceJson: inventoryStockCorrectionSourceEvidence.evidenceJson }) + .pipe(Effect.mapError((cause) => unavailable(evidence.evidenceId, cause))); + if (inserted === undefined) { + return yield* unavailable(evidence.evidenceId); + } + if (evidence.coverage.length > 0) { + yield* transaction + .insert(inventoryStockCorrectionSourceEvidenceCoverage) + .values( + evidence.coverage.map((entry) => ({ + effectId: entry.effectId, + evidenceId: entry.evidenceId, + ownerEvidenceRef: entry.ownerEvidenceRef, + relation: entry.relation, + tenantId: scope.tenantId, + })), + ) + .pipe(Effect.mapError((cause) => unavailable(evidence.evidenceId, cause))); + } + const now = DateTime.toDateUtc(yield* DateTime.now); + yield* transaction + .insert(inventoryStockCorrectionSourceEvidenceCurrent) + .values({ + authorityConfigurationId: evidence.authorityConfiguration.configurationId, + customerConfigurationId: evidence.customerConfigurationId, + evidenceId: evidence.evidenceId, + orderingEvidenceKind: evidence.orderingEvidence._tag, + orderingEvidenceValue: orderingValue(evidence), + positionId: evidence.positionRef.resourceId, + tenantId: scope.tenantId, + updatedAt: now, + }) + .onConflictDoUpdate({ + set: { + evidenceId: evidence.evidenceId, + orderingEvidenceKind: evidence.orderingEvidence._tag, + orderingEvidenceValue: orderingValue(evidence), + updatedAt: now, + }, + target: [ + inventoryStockCorrectionSourceEvidenceCurrent.tenantId, + inventoryStockCorrectionSourceEvidenceCurrent.customerConfigurationId, + inventoryStockCorrectionSourceEvidenceCurrent.authorityConfigurationId, + inventoryStockCorrectionSourceEvidenceCurrent.positionId, + ], + }) + .pipe(Effect.mapError((cause) => unavailable(evidence.evidenceId, cause))); + return yield* Schema.decodeEffect(OntosWmsStockCorrectionSourceEvidenceSchema)(inserted.evidenceJson).pipe( + Effect.mapError((cause) => unavailable(evidence.evidenceId, cause)), + ); + }); + + return Object.freeze({ appendTrusted, findCurrentById }); +}; diff --git a/app/verticals/inventory/src/persistence/stock-correction-source-evidence-table.ts b/app/verticals/inventory/src/persistence/stock-correction-source-evidence-table.ts new file mode 100644 index 000000000..3a9c9b25b --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-correction-source-evidence-table.ts @@ -0,0 +1,254 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, jsonb, primaryKey, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { OntosWmsStockCorrectionSourceEvidence } from '../../shared/domain/stock-correction.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryPhysicalStockEffects } from './physical-stock-effect-table.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; +import { inventoryStockLocations } from './stock-location-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +const SOURCE_EVIDENCE_TABLE = 'inventory.stock_correction_source_evidence'; +const SOURCE_EVIDENCE_COVERAGE_TABLE = 'inventory.stock_correction_source_evidence_coverage'; +const SOURCE_EVIDENCE_CURRENT_TABLE = 'inventory.stock_correction_source_evidence_current'; + +/** Evidence and its coverage are immutable; only the exact current-head pointer may advance. */ +export const inventoryStockCorrectionSourceEvidenceImmutabilityContract = { + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE OR DELETE', + functionName: 'inventory.reject_stock_correction_source_evidence_mutation', + tables: [SOURCE_EVIDENCE_TABLE, SOURCE_EVIDENCE_COVERAGE_TABLE], + timing: 'BEFORE', + triggerNames: [ + 'inventory_stock_correction_source_evidence_immutable_trg', + 'inventory_stock_correction_source_evidence_coverage_immutable_trg', + ], +} as const; + +/** Migration-owned verifier exact-matches relational scope/provenance with the trusted JSON. */ +export const inventoryStockCorrectionSourceEvidenceScopeVerifierContract = { + businessTime: 'AT_OR_AFTER_AUTHORITY_SELECTION', + constraintNames: { + coverage: 'inventory_stock_correction_source_evidence_coverage_exact_scope_ck', + evidence: 'inventory_stock_correction_source_evidence_exact_scope_ck', + }, + coverageTriggerName: 'inventory_stock_correction_source_evidence_coverage_exact_scope_trg', + event: 'INSERT', + functionName: 'inventory.enforce_stock_correction_source_evidence_exact_scope', + selectedAuthority: 'ONTOS_WMS_WITH_STOCK_CORRECTION_SUPPORTED', + table: SOURCE_EVIDENCE_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_correction_source_evidence_exact_scope_trg', +} as const; + +/** The deferred verifier proves the JSON coverage and relational rows are an exact bijection. */ +export const inventoryStockCorrectionSourceEvidenceCoverageCompletenessContract = { + childTable: SOURCE_EVIDENCE_COVERAGE_TABLE, + constraintName: 'inventory_stock_correction_source_evidence_coverage_complete_ck', + constraintTriggerName: 'inventory_stock_correction_source_evidence_coverage_complete_trg', + functionName: 'inventory.enforce_stock_correction_source_evidence_coverage_complete', + mode: 'DEFERRABLE INITIALLY DEFERRED', + parentTable: SOURCE_EVIDENCE_TABLE, + relation: 'BIJECTION', +} as const; + +/** One exact stream pointer advances only under the WMS owner's lexicographic ordering proof. */ +export const inventoryStockCorrectionSourceEvidenceCurrentOrderContract = { + constraintName: 'inventory_stock_correction_source_evidence_current_transition_ck', + event: 'INSERT OR UPDATE OR DELETE', + functionName: 'inventory.enforce_stock_correction_source_evidence_current_transition', + ordering: 'LEXICOGRAPHIC', + orderingEvidenceKind: 'OWNER_ORDER_KEY', + table: SOURCE_EVIDENCE_CURRENT_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_correction_source_evidence_current_transition_trg', +} as const; + +export const inventoryStockCorrectionSourceEvidence = inventorySchema.table.withRLS( + 'stock_correction_source_evidence', + { + evidenceId: uuid('evidence_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + authorityConfigurationId: uuid('authority_configuration_id').notNull(), + positionId: uuid('position_id').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockLocationId: uuid('stock_location_id').notNull(), + unitModuleId: text('unit_module_id').notNull(), + unitResourceId: uuid('unit_resource_id').notNull(), + unitResourceType: text('unit_resource_type').notNull(), + unitTenantId: uuid('unit_tenant_id').notNull(), + quantityAmount: text('quantity_amount').notNull(), + factMeaning: text('fact_meaning').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + businessObservedAt: timestamp('business_observed_at', { withTimezone: true }).notNull(), + orderingEvidenceKind: text('ordering_evidence_kind').notNull(), + orderingEvidenceValue: text('ordering_evidence_value').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + sourceReference: text('source_reference').notNull(), + receivedAt: timestamp('received_at', { withTimezone: true }).notNull(), + evidenceJson: jsonb('evidence_json').$type().notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_stock_correction_source_evidence_tenant_id_uk').on(table.tenantId, table.evidenceId), + uniqueIndex('inventory_stock_correction_source_evidence_scope_id_uk').on( + table.tenantId, + table.customerConfigurationId, + table.authorityConfigurationId, + table.positionId, + table.evidenceId, + ), + uniqueIndex('inventory_stock_correction_source_evidence_stream_order_uk').on( + table.tenantId, + table.customerConfigurationId, + table.authorityConfigurationId, + table.positionId, + table.orderingEvidenceKind, + table.orderingEvidenceValue, + ), + uniqueIndex('inventory_stock_correction_source_evidence_source_reference_uk').on( + table.tenantId, + table.customerConfigurationId, + table.authorityConfigurationId, + table.positionId, + table.sourceReference, + ), + index('inventory_stock_correction_source_evidence_stream_observed_idx').on( + table.tenantId, + table.customerConfigurationId, + table.authorityConfigurationId, + table.positionId, + table.businessObservedAt, + ), + foreignKey({ + columns: [table.tenantId, table.authorityConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_stock_correction_source_evidence_authority_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_stock_correction_source_evidence_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_stock_correction_source_evidence_item_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockLocationId], + foreignColumns: [inventoryStockLocations.tenantId, inventoryStockLocations.stockLocationId], + name: 'inventory_stock_correction_source_evidence_location_fk', + }).onDelete('restrict'), + check( + 'inventory_stock_correction_source_evidence_meaning_ck', + sql`${table.factMeaning} = 'ABSOLUTE_PHYSICAL_ON_HAND' and ${table.issuerBackendKind} = 'ontos_wms'`, + ), + check( + 'inventory_stock_correction_source_evidence_ordering_ck', + sql`${table.orderingEvidenceKind} = 'OWNER_ORDER_KEY'`, + ), + check( + 'inventory_stock_correction_source_evidence_unit_ck', + sql`${table.unitModuleId} = 'commerce.catalog' and ${table.unitResourceType} = 'commerce.catalog.product-unit' and ${table.unitTenantId} = ${table.tenantId}`, + ), + check( + 'inventory_stock_correction_source_evidence_quantity_ck', + sql`${table.quantityAmount} ~ '^(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$' and length(split_part(${table.quantityAmount}, '.', 1)) <= 29 and (position('.' in ${table.quantityAmount}) = 0 or length(split_part(${table.quantityAmount}, '.', 2)) <= 9)`, + ), + check( + 'inventory_stock_correction_source_evidence_text_ck', + sql`${table.customerConfigurationId} = btrim(${table.customerConfigurationId}) and length(${table.customerConfigurationId}) between 1 and 300 and ${table.issuerBackendId} = btrim(${table.issuerBackendId}) and length(${table.issuerBackendId}) between 1 and 300 and ${table.orderingEvidenceValue} = btrim(${table.orderingEvidenceValue}) and length(${table.orderingEvidenceValue}) between 1 and 300 and ${table.ownerEvidenceRef} = btrim(${table.ownerEvidenceRef}) and length(${table.ownerEvidenceRef}) between 1 and 300 and ${table.sourceReference} = btrim(${table.sourceReference}) and length(${table.sourceReference}) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_stock_correction_source_evidence_tenant', table.tenantId), + ], +); + +export const inventoryStockCorrectionSourceEvidenceCoverage = inventorySchema.table.withRLS( + 'stock_correction_source_evidence_coverage', + { + tenantId: uuid('tenant_id').notNull(), + evidenceId: uuid('evidence_id').notNull(), + effectId: uuid('effect_id').notNull(), + relation: text('relation').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.evidenceId, table.effectId], + name: 'inventory_stock_correction_source_evidence_coverage_pk', + }), + foreignKey({ + columns: [table.tenantId, table.evidenceId], + foreignColumns: [ + inventoryStockCorrectionSourceEvidence.tenantId, + inventoryStockCorrectionSourceEvidence.evidenceId, + ], + name: 'inventory_stock_correction_source_evidence_coverage_evidence_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.effectId], + foreignColumns: [inventoryPhysicalStockEffects.tenantId, inventoryPhysicalStockEffects.effectId], + name: 'inventory_stock_correction_source_evidence_coverage_effect_fk', + }).onDelete('restrict'), + check( + 'inventory_stock_correction_source_evidence_coverage_relation_ck', + sql`${table.relation} in ('INCLUDES', 'EXCLUDES', 'PREDATES', 'UNKNOWN')`, + ), + check( + 'inventory_stock_correction_source_evidence_coverage_evidence_ck', + sql`${table.ownerEvidenceRef} = btrim(${table.ownerEvidenceRef}) and length(${table.ownerEvidenceRef}) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_stock_correction_source_evidence_coverage_tenant', table.tenantId), + ], +); + +export const inventoryStockCorrectionSourceEvidenceCurrent = inventorySchema.table.withRLS( + 'stock_correction_source_evidence_current', + { + tenantId: uuid('tenant_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + authorityConfigurationId: uuid('authority_configuration_id').notNull(), + positionId: uuid('position_id').notNull(), + evidenceId: uuid('evidence_id').notNull(), + orderingEvidenceKind: text('ordering_evidence_kind').notNull(), + orderingEvidenceValue: text('ordering_evidence_value').notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.customerConfigurationId, table.authorityConfigurationId, table.positionId], + name: 'inventory_stock_correction_source_evidence_current_pk', + }), + uniqueIndex('inventory_stock_correction_source_evidence_current_evidence_uk').on(table.tenantId, table.evidenceId), + foreignKey({ + columns: [ + table.tenantId, + table.customerConfigurationId, + table.authorityConfigurationId, + table.positionId, + table.evidenceId, + ], + foreignColumns: [ + inventoryStockCorrectionSourceEvidence.tenantId, + inventoryStockCorrectionSourceEvidence.customerConfigurationId, + inventoryStockCorrectionSourceEvidence.authorityConfigurationId, + inventoryStockCorrectionSourceEvidence.positionId, + inventoryStockCorrectionSourceEvidence.evidenceId, + ], + name: 'inventory_stock_correction_source_evidence_current_evidence_fk', + }).onDelete('restrict'), + check( + 'inventory_stock_correction_source_evidence_current_ordering_ck', + sql`${table.orderingEvidenceKind} = 'OWNER_ORDER_KEY' and length(btrim(${table.orderingEvidenceValue})) between 1 and 300`, + ), + ...tenantRlsPolicies('inventory_stock_correction_source_evidence_current_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/stock-correction-table.ts b/app/verticals/inventory/src/persistence/stock-correction-table.ts new file mode 100644 index 000000000..9e8a83210 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-correction-table.ts @@ -0,0 +1,222 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { + check, + foreignKey, + index, + integer, + jsonb, + numeric, + primaryKey, + text, + timestamp, + uniqueIndex, + uuid, +} from 'drizzle-orm/pg-core'; + +import type { StockCorrectionRecord } from '../../shared/domain/stock-correction.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventorySourceAssertions } from './inventory-source-assertion-table.ts'; +import { inventoryStockCorrectionSourceEvidence } from './stock-correction-source-evidence-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +const STOCK_CORRECTIONS_TABLE = 'inventory.stock_corrections'; +const STOCK_CORRECTION_OPEN_RECONCILIATIONS_TABLE = 'inventory.stock_correction_open_reconciliations'; + +/** + * Migration-owned verifier for the append-only correction evidence. It must exact-match the JSON + * record to the relational identity, evidence branch, Position, selected authority, absolute + * quantity, and optimistic revision columns before accepting an insert. External evidence must + * bind a Source Assertion; direct OntOS WMS owner evidence must not synthesize one. + */ +export const inventoryStockCorrectionExactScopeVerifierContract = { + constraintName: 'inventory_stock_corrections_exact_scope_ck', + event: 'INSERT', + functionName: 'inventory.enforce_stock_correction_exact_scope', + table: STOCK_CORRECTIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_corrections_exact_scope_trg', +} as const; + +/** Correction evidence is append-only. Reconciliation changes only the separate open marker. */ +export const inventoryStockCorrectionImmutabilityContract = { + columns: [ + 'correction_id', + 'tenant_id', + 'action_invocation_id', + 'principal_id', + 'customer_configuration_id', + 'position_id', + 'source_assertion_id', + 'source_evidence_id', + 'authority_configuration_id', + 'evidence_kind', + 'issuer_backend_kind', + 'issuer_backend_id', + 'owner_evidence_ref', + 'source_reference', + 'business_observed_at', + 'expected_position_revision', + 'position_revision_after', + 'state', + 'corrected_quantity_amount', + 'reconciles_correction_id', + 'coverage_evidence_json', + 'evaluated_material_effect_ids_json', + 'record_json', + 'applied_at', + ], + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE OR DELETE', + functionName: 'inventory.reject_stock_correction_mutation', + table: STOCK_CORRECTIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_corrections_immutable_trg', +} as const; + +/** + * The marker transition verifier permits only an exact reconciliation chain for one Position: + * insert an INDETERMINATE head, replace it with an INDETERMINATE correction that reconciles the + * old head, or delete it after a correction that reconciles the old head becomes APPLIED. + */ +export const inventoryStockCorrectionOpenTransitionContract = { + constraintName: 'inventory_stock_correction_open_transition_ck', + event: 'INSERT OR UPDATE OR DELETE', + functionName: 'inventory.enforce_stock_correction_open_transition', + table: STOCK_CORRECTION_OPEN_RECONCILIATIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_correction_open_transition_trg', +} as const; + +export const inventoryStockCorrections = inventorySchema.table.withRLS( + 'stock_corrections', + { + correctionId: uuid('correction_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + actionInvocationId: uuid('action_invocation_id').notNull(), + principalId: uuid('principal_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + positionId: uuid('position_id').notNull(), + sourceAssertionId: uuid('source_assertion_id'), + sourceEvidenceId: uuid('source_evidence_id'), + authorityConfigurationId: uuid('authority_configuration_id').notNull(), + evidenceKind: text('evidence_kind').notNull(), + issuerBackendKind: text('issuer_backend_kind').notNull(), + issuerBackendId: text('issuer_backend_id').notNull(), + ownerEvidenceRef: text('owner_evidence_ref').notNull(), + sourceReference: text('source_reference').notNull(), + businessObservedAt: timestamp('business_observed_at', { withTimezone: true }).notNull(), + expectedPositionRevision: integer('expected_position_revision').notNull(), + positionRevisionAfter: integer('position_revision_after').notNull(), + state: text('state').notNull(), + correctedQuantityAmount: numeric('corrected_quantity_amount', { precision: 38, scale: 9 }), + reconcilesCorrectionId: uuid('reconciles_correction_id'), + coverageEvidenceJson: jsonb('coverage_evidence_json').$type().notNull(), + evaluatedMaterialEffectIdsJson: jsonb('evaluated_material_effect_ids_json') + .$type() + .notNull(), + recordJson: jsonb('record_json').$type().notNull(), + appliedAt: timestamp('applied_at', { withTimezone: true }).notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_stock_corrections_tenant_id_uk').on(table.tenantId, table.correctionId), + uniqueIndex('inventory_stock_corrections_assertion_uk') + .on(table.tenantId, table.sourceAssertionId) + .where(sql`${table.sourceAssertionId} is not null`), + uniqueIndex('inventory_stock_corrections_source_evidence_uk') + .on(table.tenantId, table.sourceEvidenceId) + .where(sql`${table.sourceEvidenceId} is not null`), + uniqueIndex('inventory_stock_corrections_reconciles_uk') + .on(table.tenantId, table.reconcilesCorrectionId) + .where(sql`${table.reconcilesCorrectionId} is not null`), + index('inventory_stock_corrections_position_idx').on(table.tenantId, table.positionId, table.appliedAt), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_stock_corrections_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.sourceAssertionId], + foreignColumns: [inventorySourceAssertions.tenantId, inventorySourceAssertions.assertionId], + name: 'inventory_stock_corrections_assertion_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.sourceEvidenceId], + foreignColumns: [ + inventoryStockCorrectionSourceEvidence.tenantId, + inventoryStockCorrectionSourceEvidence.evidenceId, + ], + name: 'inventory_stock_corrections_source_evidence_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.authorityConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_stock_corrections_authority_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.reconcilesCorrectionId], + foreignColumns: [table.tenantId, table.correctionId], + name: 'inventory_stock_corrections_reconciles_fk', + }).onDelete('restrict'), + check( + 'inventory_stock_corrections_customer_configuration_ck', + sql`${table.customerConfigurationId} = btrim(${table.customerConfigurationId}) and length(${table.customerConfigurationId}) between 1 and 300`, + ), + check( + 'inventory_stock_corrections_provenance_text_ck', + sql`length(btrim(${table.issuerBackendId})) between 1 and 300 and length(btrim(${table.ownerEvidenceRef})) between 1 and 300 and length(btrim(${table.sourceReference})) between 1 and 300`, + ), + check( + 'inventory_stock_corrections_issuer_ck', + sql`${table.issuerBackendKind} in ('external_business_system', 'ontos_wms')`, + ), + check( + 'inventory_stock_corrections_evidence_ck', + sql`(${table.evidenceKind} = 'EXTERNAL_SOURCE_ASSERTION' and ${table.issuerBackendKind} = 'external_business_system' and ${table.sourceAssertionId} is not null and ${table.sourceEvidenceId} is null) or (${table.evidenceKind} = 'ONTOS_WMS_OWNER_EVIDENCE' and ${table.issuerBackendKind} = 'ontos_wms' and ${table.sourceAssertionId} is null and ${table.sourceEvidenceId} is not null)`, + ), + check('inventory_stock_corrections_state_ck', sql`${table.state} in ('APPLIED', 'INDETERMINATE')`), + check( + 'inventory_stock_corrections_quantity_ck', + sql`(${table.state} = 'APPLIED' and ${table.correctedQuantityAmount} is not null and ${table.correctedQuantityAmount} >= 0) or (${table.state} = 'INDETERMINATE' and ${table.correctedQuantityAmount} is null)`, + ), + check( + 'inventory_stock_corrections_revision_ck', + sql`${table.expectedPositionRevision} >= 1 and ${table.positionRevisionAfter} = ${table.expectedPositionRevision} + 1 and ${table.positionRevisionAfter} <= 2147483647`, + ), + ...tenantRlsPolicies('inventory_stock_corrections_tenant', table.tenantId), + ], +); + +/** One row per Position means an indeterminate outcome must be reconciled before a fresh mutation. */ +export const inventoryStockCorrectionOpenReconciliations = inventorySchema.table.withRLS( + 'stock_correction_open_reconciliations', + { + tenantId: uuid('tenant_id').notNull(), + positionId: uuid('position_id').notNull(), + correctionId: uuid('correction_id').notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + primaryKey({ + columns: [table.tenantId, table.positionId], + name: 'inventory_stock_correction_open_pk', + }), + uniqueIndex('inventory_stock_correction_open_correction_uk').on(table.tenantId, table.correctionId), + foreignKey({ + columns: [table.tenantId, table.positionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_stock_correction_open_position_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.correctionId], + foreignColumns: [inventoryStockCorrections.tenantId, inventoryStockCorrections.correctionId], + name: 'inventory_stock_correction_open_correction_fk', + }).onDelete('restrict'), + ...tenantRlsPolicies('inventory_stock_correction_open_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/stock-item-persistence-error.ts b/app/verticals/inventory/src/persistence/stock-item-persistence-error.ts new file mode 100644 index 000000000..113b1895f --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-item-persistence-error.ts @@ -0,0 +1,9 @@ +import { Schema } from 'effect'; + +export class StockItemPersistenceUnavailable extends Schema.TaggedError()( + 'StockItemPersistenceUnavailable', + { + code: Schema.Literal('stock_item_persistence_unavailable'), + reason: Schema.String, + }, +) {} diff --git a/app/verticals/inventory/src/persistence/stock-item-repository.ts b/app/verticals/inventory/src/persistence/stock-item-repository.ts new file mode 100644 index 000000000..a1251a5f6 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-item-repository.ts @@ -0,0 +1,163 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import { Context, DateTime, Effect, Option, Schema } from 'effect'; + +import { StockItemRejected, StockItemSchema } from '../../shared/domain/stock-item.ts'; +import type { ExactCatalogSelectionMeaningId, StockItem, StockItemInstant } from '../../shared/domain/stock-item.ts'; +import { StockItemPersistenceUnavailable } from './stock-item-persistence-error.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; + +type StockItemRepositoryError = StockItemRejected | StockItemPersistenceUnavailable; + +export interface StockItemRepositoryService { + readonly findByExactSelectionMeaning: ( + tenantId: string, + exactSelectionMeaningId: ExactCatalogSelectionMeaningId, + ) => Effect.Effect, StockItemPersistenceUnavailable>; + readonly findById: ( + tenantId: string, + stockItemId: string, + ) => Effect.Effect, StockItemPersistenceUnavailable>; + readonly insert: (item: StockItem) => Effect.Effect; + readonly retire: (item: StockItem, retiredAt: StockItemInstant) => Effect.Effect; +} + +export class StockItemRepository extends Context.Service()( + '@app/inventory/persistence/stock-item-repository/StockItemRepository', +) {} + +const unavailable = (cause?: unknown): StockItemPersistenceUnavailable => { + const failure = new StockItemPersistenceUnavailable({ + code: 'stock_item_persistence_unavailable', + reason: 'Stock Item persistence is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const uniqueViolationSqlState = ['23', '505'].join(''); + +// oxlint-disable-next-line anti-slop/no-unknown-parameters -- The SQL driver cause is opaque until Core's approved PostgreSQL decoder parses it. +export const mapStockItemWriteError = (error: unknown): StockItemRepositoryError => + Option.isSome( + findPostgresFailure( + error, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_stock_items_exact_meaning_uk', + ), + ) + ? new StockItemRejected({ + code: 'stock_item_rejected', + reason: 'exact_selection_meaning_already_registered', + }) + : unavailable(error); + +const decodeStockItem = Schema.decodeUnknownEffect(StockItemSchema); +const instantAsDate = (instant: StockItemInstant): Date => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const toDomain = (row: typeof inventoryStockItems.$inferSelect) => + decodeStockItem({ + createdAt: row.createdAt.toISOString(), + exactSelectionMeaning: { + id: row.exactSelectionMeaningId, + kind: row.exactSelectionKind, + }, + lifecycle: row.lifecycleState, + retiredAt: row.retiredAt?.toISOString() ?? null, + revision: row.revision, + stockItemRef: { + moduleId: 'commerce.inventory', + resourceId: row.stockItemId, + resourceType: 'commerce.inventory.stock-item', + tenantId: row.tenantId, + }, + unitRef: { + moduleId: row.stockUnitModuleId, + resourceId: row.stockUnitResourceId, + resourceType: row.stockUnitResourceType, + tenantId: row.stockUnitTenantId, + }, + }).pipe(Effect.mapError(unavailable)); + +export const makeDrizzleStockItemRepository = (transaction: ScopedTransaction): StockItemRepositoryService => ({ + findByExactSelectionMeaning: (tenantId, exactSelectionMeaningId) => + transaction + .select() + .from(inventoryStockItems) + .where( + and( + eq(inventoryStockItems.tenantId, tenantId), + eq(inventoryStockItems.exactSelectionMeaningId, exactSelectionMeaningId), + eq(inventoryStockItems.lifecycleState, 'CURRENT'), + ), + ) + .limit(1) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : toDomain(row).pipe(Effect.asSome))), + ), + findById: (tenantId, stockItemId) => + transaction + .select() + .from(inventoryStockItems) + .where(and(eq(inventoryStockItems.tenantId, tenantId), eq(inventoryStockItems.stockItemId, stockItemId))) + .limit(1) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap(([row]) => (row === undefined ? Effect.succeedNone : toDomain(row).pipe(Effect.asSome))), + ), + insert: (item) => + transaction + .insert(inventoryStockItems) + .values({ + createdAt: instantAsDate(item.createdAt), + exactSelectionKind: item.exactSelectionMeaning.kind, + exactSelectionMeaningId: item.exactSelectionMeaning.id, + lifecycleState: item.lifecycle, + retiredAt: item.retiredAt === null ? null : instantAsDate(item.retiredAt), + revision: item.revision, + stockItemId: item.stockItemRef.resourceId, + stockUnitModuleId: item.unitRef.moduleId, + stockUnitResourceId: item.unitRef.resourceId, + stockUnitResourceType: item.unitRef.resourceType, + stockUnitTenantId: item.unitRef.tenantId, + tenantId: item.stockItemRef.tenantId, + }) + .returning() + .pipe( + Effect.mapError(mapStockItemWriteError), + Effect.flatMap(([row]) => (row === undefined ? Effect.fail(unavailable()) : toDomain(row))), + ), + retire: (item, retiredAt) => + transaction + .update(inventoryStockItems) + .set({ lifecycleState: 'RETIRED', retiredAt: instantAsDate(retiredAt), revision: item.revision + 1 }) + .where( + and( + eq(inventoryStockItems.tenantId, item.stockItemRef.tenantId), + eq(inventoryStockItems.stockItemId, item.stockItemRef.resourceId), + eq(inventoryStockItems.lifecycleState, 'CURRENT'), + eq(inventoryStockItems.revision, item.revision), + ), + ) + .returning() + .pipe( + Effect.mapError(mapStockItemWriteError), + Effect.flatMap(([row]): Effect.Effect => + row === undefined + ? Effect.fail( + new StockItemRejected({ + code: 'stock_item_rejected', + reason: 'stock_item_retired', + stockItemId: item.stockItemRef.resourceId, + }), + ) + : toDomain(row), + ), + ), +}); diff --git a/app/verticals/inventory/src/persistence/stock-item-table.ts b/app/verticals/inventory/src/persistence/stock-item-table.ts new file mode 100644 index 000000000..c1acad7a8 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-item-table.ts @@ -0,0 +1,67 @@ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, index, integer, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import { inventorySchema } from '../database/inventory-schema.ts'; + +export const inventoryStockItemImmutabilityTriggerContract = { + columns: [ + 'stock_item_id', + 'tenant_id', + 'exact_selection_meaning_id', + 'exact_selection_kind', + 'stock_unit_module_id', + 'stock_unit_resource_id', + 'stock_unit_resource_type', + 'stock_unit_tenant_id', + ], + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE', + functionName: 'inventory.reject_stock_item_meaning_mutation', + table: 'inventory.stock_items', + timing: 'BEFORE', + triggerName: 'inventory_stock_items_immutable_meaning_trg', +} as const; + +export const inventoryStockItems = inventorySchema.table.withRLS( + 'stock_items', + { + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + exactSelectionKind: text('exact_selection_kind').notNull(), + exactSelectionMeaningId: text('exact_selection_meaning_id').notNull(), + lifecycleState: text('lifecycle_state').default('CURRENT').notNull(), + retiredAt: timestamp('retired_at', { withTimezone: true }), + revision: integer('revision').default(1).notNull(), + stockItemId: uuid('stock_item_id').primaryKey(), + stockUnitModuleId: text('stock_unit_module_id').notNull(), + stockUnitResourceId: uuid('stock_unit_resource_id').notNull(), + stockUnitResourceType: text('stock_unit_resource_type').notNull(), + stockUnitTenantId: uuid('stock_unit_tenant_id').notNull(), + tenantId: uuid('tenant_id').notNull(), + }, + (table) => [ + uniqueIndex('inventory_stock_items_scope_id_uk').on(table.tenantId, table.stockItemId), + uniqueIndex('inventory_stock_items_exact_meaning_uk') + .on(table.tenantId, table.exactSelectionMeaningId) + .where(sql`${table.lifecycleState} = 'CURRENT'`), + index('inventory_stock_items_current_idx') + .on(table.tenantId, table.lifecycleState) + .where(sql`${table.lifecycleState} = 'CURRENT'`), + check( + 'inventory_stock_items_meaning_ck', + sql`char_length(btrim(${table.exactSelectionMeaningId})) between 1 and 300 and ${table.exactSelectionKind} in ('PRODUCT_VARIANT', 'PACKAGE_OPTION', 'SET_VARIANT', 'CONFIGURED_SELECTION')`, + ), + check( + 'inventory_stock_items_unit_ck', + sql`${table.stockUnitModuleId} = 'commerce.catalog' and ${table.stockUnitResourceType} = 'commerce.catalog.product-unit' and ${table.stockUnitTenantId} = ${table.tenantId}`, + ), + check('inventory_stock_items_revision_ck', sql`${table.revision} >= 1`), + check('inventory_stock_items_lifecycle_ck', sql`${table.lifecycleState} in ('CURRENT', 'RETIRED')`), + check( + 'inventory_stock_items_retirement_ck', + sql`(${table.lifecycleState} = 'CURRENT' and ${table.retiredAt} is null) or (${table.lifecycleState} = 'RETIRED' and ${table.retiredAt} is not null)`, + ), + ...tenantRlsPolicies('inventory_stock_items_tenant', table.tenantId), + ], +); diff --git a/app/verticals/inventory/src/persistence/stock-location-persistence-rejected.ts b/app/verticals/inventory/src/persistence/stock-location-persistence-rejected.ts new file mode 100644 index 000000000..1b5259417 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-location-persistence-rejected.ts @@ -0,0 +1,19 @@ +import { Schema } from 'effect'; + +import { StockLocationRefSchema } from '../../shared/resources/stock-location.ts'; + +export class StockLocationPersistenceRejected extends Schema.TaggedError()( + 'StockLocationPersistenceRejected', + { + actualRevision: Schema.optionalKey(Schema.Int), + locationRef: StockLocationRefSchema, + reason: Schema.Literals([ + 'IDENTITY_CONFLICT', + 'INVALID_CREATE', + 'INVALID_TRANSITION', + 'NOT_FOUND', + 'REVISION_CONFLICT', + 'TENANT_SCOPE_MISMATCH', + ]), + }, +) {} diff --git a/app/verticals/inventory/src/persistence/stock-location-repository.ts b/app/verticals/inventory/src/persistence/stock-location-repository.ts new file mode 100644 index 000000000..d07931d9f --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-location-repository.ts @@ -0,0 +1,297 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq } from 'drizzle-orm'; +import type { Effect as EffectType } from 'effect'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { ActiveLifecycleSchema, StockLocationSchema } from '../../shared/domain/stock-location.ts'; +import type { + ExternalStockLocationKey, + StockLocation, + StockLocationCorrelation, +} from '../../shared/domain/stock-location.ts'; +import type { StockLocationRef } from '../../shared/resources/stock-location.ts'; +import { StockLocationPersistenceRejected } from './stock-location-persistence-rejected.ts'; +import { inventoryStockLocationRevisions, inventoryStockLocations } from './stock-location-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type StockLocationRow = typeof inventoryStockLocations.$inferSelect; + +export class StockLocationPersistenceUnavailable extends Schema.TaggedError()( + 'StockLocationPersistenceUnavailable', + { + code: Schema.Literal('stock_location_persistence_unavailable'), + reason: Schema.String, + }, +) {} + +/** Transaction-scoped owner port. Implementations must append a revision when saving a transition. */ +export interface StockLocationPersistence { + readonly create: ( + location: StockLocation, + ) => EffectType.Effect; + readonly read: ( + ref: StockLocationRef, + ) => EffectType.Effect< + Option.Option, + StockLocationPersistenceRejected | StockLocationPersistenceUnavailable + >; + readonly readHistory: ( + ref: StockLocationRef, + ) => EffectType.Effect< + readonly StockLocation[], + StockLocationPersistenceRejected | StockLocationPersistenceUnavailable + >; + readonly saveTransition: (input: { + readonly expectedRevision: number; + readonly next: StockLocation; + }) => EffectType.Effect; +} + +/** Narrow seam onto explicit Connector Registry correlations; it cannot perform fuzzy matching. */ +export interface StockLocationCorrelationReader { + readonly readExplicit: ( + source: ExternalStockLocationKey, + ) => EffectType.Effect; +} + +const unavailable = (cause: unknown): StockLocationPersistenceUnavailable => { + const failure = new StockLocationPersistenceUnavailable({ + code: 'stock_location_persistence_unavailable', + reason: 'Stock Location persistence is temporarily unavailable', + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +const reject = ( + locationRef: StockLocationRef, + reason: StockLocationPersistenceRejected['reason'], + actualRevision?: number, +) => + actualRevision === undefined + ? new StockLocationPersistenceRejected({ locationRef, reason }) + : new StockLocationPersistenceRejected({ actualRevision, locationRef, reason }); + +const refFor = (tenantId: string, stockLocationId: string) => ({ + moduleId: 'commerce.inventory' as const, + resourceId: stockLocationId, + resourceType: 'commerce.inventory.stock-location' as const, + tenantId, +}); + +const rowLifecycle = (row: StockLocationRow) => { + if (row.lifecycleState === 'ACTIVE') { + return { _tag: 'ACTIVE' as const }; + } + if (row.lifecycleState === 'RETIRED') { + return { + _tag: 'RETIRED' as const, + reason: row.transitionReason ?? '', + transitionedAt: row.transitionedAt?.toISOString() ?? '', + }; + } + const successorRef = refFor(row.tenantId, row.successorStockLocationId ?? ''); + return row.lifecycleState === 'REPLACED' + ? { + _tag: 'REPLACED' as const, + reason: row.transitionReason ?? '', + successorRef, + transitionedAt: row.transitionedAt?.toISOString() ?? '', + } + : { + _tag: 'MERGED' as const, + reason: row.transitionReason ?? '', + successorRef, + transitionedAt: row.transitionedAt?.toISOString() ?? '', + }; +}; + +const decodeRow = (row: StockLocationRow) => { + const candidate = { + displayName: row.displayName, + lifecycle: rowLifecycle(row), + operationalScope: { _tag: row.scopeKind, physicalSiteKeys: row.physicalSiteKeys }, + ref: refFor(row.tenantId, row.stockLocationId), + revision: row.currentRevision, + }; + return Schema.decodeUnknownEffect(StockLocationSchema)( + row.addressEvidence === null ? candidate : { ...candidate, addressEvidence: row.addressEvidence }, + ).pipe(Effect.mapError(unavailable)); +}; + +const lifecycleColumns = (location: StockLocation) => + Match.value(location.lifecycle).pipe( + Match.tag('ACTIVE', () => ({ + lifecycleState: 'ACTIVE', + successorStockLocationId: null, + transitionedAt: null, + transitionReason: null, + })), + Match.tag('RETIRED', ({ reason, transitionedAt }) => ({ + lifecycleState: 'RETIRED', + successorStockLocationId: null, + transitionedAt: DateTime.toDateUtc(DateTime.makeUnsafe(transitionedAt)), + transitionReason: reason, + })), + Match.tag('REPLACED', ({ reason, successorRef, transitionedAt }) => ({ + lifecycleState: 'REPLACED', + successorStockLocationId: successorRef.resourceId, + transitionedAt: DateTime.toDateUtc(DateTime.makeUnsafe(transitionedAt)), + transitionReason: reason, + })), + Match.tag('MERGED', ({ reason, successorRef, transitionedAt }) => ({ + lifecycleState: 'MERGED', + successorStockLocationId: successorRef.resourceId, + transitionedAt: DateTime.toDateUtc(DateTime.makeUnsafe(transitionedAt)), + transitionReason: reason, + })), + Match.exhaustive, + ); + +const rowValues = (location: StockLocation) => ({ + addressEvidence: location.addressEvidence ?? null, + currentRevision: location.revision, + displayName: location.displayName, + ...lifecycleColumns(location), + physicalSiteKeys: location.operationalScope.physicalSiteKeys, + scopeKind: location.operationalScope._tag, + stockLocationId: location.ref.resourceId, + tenantId: location.ref.tenantId, +}); + +const appendRevision = (transaction: ScopedTransaction, location: StockLocation) => + transaction + .insert(inventoryStockLocationRevisions) + .values({ + revision: location.revision, + snapshot: location, + stockLocationId: location.ref.resourceId, + tenantId: location.ref.tenantId, + }) + .pipe(Effect.mapError(unavailable)); + +const mapCreateError = (locationRef: StockLocationRef, cause: unknown) => { + const uniqueViolation = ['23', '505'].join(''); + const matched = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolation && + ['stock_locations_pkey', 'inventory_stock_locations_scope_id_uk'].includes(constraint ?? ''), + ); + return Option.isSome(matched) ? reject(locationRef, 'IDENTITY_CONFLICT') : unavailable(cause); +}; + +/** Concrete owner-local Drizzle adapter; its transaction is installed only after governed scope validation. */ +export const stockLocationPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): StockLocationPersistence => { + const requireTenant = (ref: StockLocationRef) => + ref.tenantId === scope.tenantId ? Effect.void : Effect.fail(reject(ref, 'TENANT_SCOPE_MISMATCH')); + + const readCurrentRow = (ref: StockLocationRef) => + transaction + .select() + .from(inventoryStockLocations) + .where( + and( + eq(inventoryStockLocations.tenantId, scope.tenantId), + eq(inventoryStockLocations.stockLocationId, ref.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + + const create: StockLocationPersistence['create'] = Effect.fn('StockLocationPersistence.create')( + function* createStockLocation(location) { + yield* requireTenant(location.ref); + if ( + !Schema.is(StockLocationSchema)(location) || + location.revision !== 1 || + !Schema.is(ActiveLifecycleSchema)(location.lifecycle) + ) { + return yield* reject(location.ref, 'INVALID_CREATE'); + } + const [row] = yield* transaction + .insert(inventoryStockLocations) + .values(rowValues(location)) + .returning() + .pipe(Effect.mapError((cause) => mapCreateError(location.ref, cause))); + if (row === undefined) { + return yield* unavailable('Stock Location insert returned no row'); + } + const created = yield* decodeRow(row); + yield* appendRevision(transaction, created); + return created; + }, + ); + + const read: StockLocationPersistence['read'] = Effect.fn('StockLocationPersistence.read')( + function* readStockLocation(ref) { + yield* requireTenant(ref); + const [row] = yield* readCurrentRow(ref); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }, + ); + + const readHistory: StockLocationPersistence['readHistory'] = Effect.fn('StockLocationPersistence.readHistory')( + function* readStockLocationHistory(ref) { + yield* requireTenant(ref); + const rows = yield* transaction + .select({ snapshot: inventoryStockLocationRevisions.snapshot }) + .from(inventoryStockLocationRevisions) + .where( + and( + eq(inventoryStockLocationRevisions.tenantId, scope.tenantId), + eq(inventoryStockLocationRevisions.stockLocationId, ref.resourceId), + ), + ) + .orderBy(asc(inventoryStockLocationRevisions.revision)) + .pipe(Effect.mapError(unavailable)); + return yield* Effect.forEach( + rows, + ({ snapshot }) => Schema.decodeEffect(StockLocationSchema)(snapshot).pipe(Effect.mapError(unavailable)), + { concurrency: 1 }, + ); + }, + ); + + const saveTransition: StockLocationPersistence['saveTransition'] = Effect.fn( + 'StockLocationPersistence.saveTransition', + )(function* saveStockLocationTransition({ expectedRevision, next }) { + yield* requireTenant(next.ref); + if ( + !Schema.is(StockLocationSchema)(next) || + next.revision !== expectedRevision + 1 || + Schema.is(ActiveLifecycleSchema)(next.lifecycle) + ) { + return yield* reject(next.ref, 'INVALID_TRANSITION'); + } + const [row] = yield* transaction + .update(inventoryStockLocations) + .set({ ...rowValues(next), updatedAt: DateTime.toDateUtc(yield* DateTime.now) }) + .where( + and( + eq(inventoryStockLocations.tenantId, scope.tenantId), + eq(inventoryStockLocations.stockLocationId, next.ref.resourceId), + eq(inventoryStockLocations.currentRevision, expectedRevision), + eq(inventoryStockLocations.lifecycleState, 'ACTIVE'), + ), + ) + .returning() + .pipe(Effect.mapError(unavailable)); + if (row === undefined) { + const [observed] = yield* readCurrentRow(next.ref); + if (observed === undefined) { + return yield* reject(next.ref, 'NOT_FOUND'); + } + return yield* reject(next.ref, 'REVISION_CONFLICT', observed.currentRevision); + } + const saved = yield* decodeRow(row); + yield* appendRevision(transaction, saved); + return saved; + }); + + return Object.freeze({ create, read, readHistory, saveTransition }); +}; diff --git a/app/verticals/inventory/src/persistence/stock-location-table.ts b/app/verticals/inventory/src/persistence/stock-location-table.ts new file mode 100644 index 000000000..0737b01d1 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-location-table.ts @@ -0,0 +1,88 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, jsonb, text, timestamp, unique, uuid } from 'drizzle-orm/pg-core'; + +import type { StockLocation, StockLocationAddressEvidence } from '../../shared/domain/stock-location.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; + +/** + * Current owner row. Terminal locations remain addressable and point forward instead of being + * deleted or having their identity rewritten. + */ +export const inventoryStockLocations = inventorySchema.table.withRLS( + 'stock_locations', + { + stockLocationId: uuid('stock_location_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + displayName: text('display_name').notNull(), + scopeKind: text('scope_kind').notNull(), + physicalSiteKeys: jsonb('physical_site_keys').$type().notNull(), + addressEvidence: jsonb('address_evidence').$type(), + lifecycleState: text('lifecycle_state').notNull(), + successorStockLocationId: uuid('successor_stock_location_id'), + transitionReason: text('transition_reason'), + transitionedAt: timestamp('transitioned_at', { withTimezone: true }), + currentRevision: integer('current_revision').default(1).notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + unique('inventory_stock_locations_scope_id_uk').on(table.tenantId, table.stockLocationId), + foreignKey({ + columns: [table.tenantId, table.successorStockLocationId], + foreignColumns: [table.tenantId, table.stockLocationId], + name: 'inventory_stock_locations_successor_fk', + }).onDelete('restrict'), + index('inventory_stock_locations_lifecycle_idx').on(table.tenantId, table.lifecycleState), + check('inventory_stock_locations_revision_ck', sql`${table.currentRevision} >= 1`), + check( + 'inventory_stock_locations_display_name_ck', + sql`${table.displayName} = btrim(${table.displayName}) and length(${table.displayName}) between 1 and 300`, + ), + check('inventory_stock_locations_scope_kind_ck', sql`${table.scopeKind} in ('PHYSICAL_SITE', 'LOGICAL_AGGREGATE')`), + check( + 'inventory_stock_locations_site_keys_ck', + sql`jsonb_typeof(${table.physicalSiteKeys}) = 'array' and jsonb_array_length(${table.physicalSiteKeys}) <= 100 and (${table.scopeKind} <> 'PHYSICAL_SITE' or jsonb_array_length(${table.physicalSiteKeys}) = 1)`, + ), + check( + 'inventory_stock_locations_lifecycle_ck', + sql`${table.lifecycleState} in ('ACTIVE', 'RETIRED', 'REPLACED', 'MERGED')`, + ), + check( + 'inventory_stock_locations_successor_ck', + sql`((${table.lifecycleState} in ('ACTIVE', 'RETIRED')) and ${table.successorStockLocationId} is null) or ((${table.lifecycleState} in ('REPLACED', 'MERGED')) and ${table.successorStockLocationId} is not null and ${table.successorStockLocationId} <> ${table.stockLocationId})`, + ), + check( + 'inventory_stock_locations_transition_ck', + sql`(${table.lifecycleState} = 'ACTIVE' and ${table.transitionReason} is null and ${table.transitionedAt} is null) or (${table.lifecycleState} <> 'ACTIVE' and ${table.transitionReason} = btrim(${table.transitionReason}) and length(${table.transitionReason}) between 1 and 1000 and ${table.transitionedAt} is not null)`, + ), + ...tenantRlsPolicies('inventory_stock_locations_tenant', table.tenantId), + ], +); + +/** Exact append-only snapshots used to reconstruct the meaning referenced by historical facts. */ +export const inventoryStockLocationRevisions = inventorySchema.table.withRLS( + 'stock_location_revisions', + { + stockLocationRevisionId: uuid('stock_location_revision_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + stockLocationId: uuid('stock_location_id').notNull(), + revision: integer('revision').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + unique('inventory_stock_location_revisions_scope_id_uk').on(table.tenantId, table.stockLocationRevisionId), + unique('inventory_stock_location_revisions_number_uk').on(table.tenantId, table.stockLocationId, table.revision), + foreignKey({ + columns: [table.tenantId, table.stockLocationId], + foreignColumns: [inventoryStockLocations.tenantId, inventoryStockLocations.stockLocationId], + name: 'inventory_stock_location_revisions_location_fk', + }).onDelete('restrict'), + check('inventory_stock_location_revisions_revision_ck', sql`${table.revision} >= 1`), + ...tenantRlsPolicies('inventory_stock_location_revisions_tenant', table.tenantId), + ], +); + +export const INVENTORY_STOCK_LOCATION_TABLES = [inventoryStockLocationRevisions, inventoryStockLocations] as const; diff --git a/app/verticals/inventory/src/persistence/stock-position-repository.ts b/app/verticals/inventory/src/persistence/stock-position-repository.ts new file mode 100644 index 000000000..89d94bcc7 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-position-repository.ts @@ -0,0 +1,404 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, eq } from 'drizzle-orm'; +import type { Effect as EffectType } from 'effect'; +import { DateTime, Effect, Match, Option, Schema } from 'effect'; + +import { StockPositionRejected, StockPositionSchema } from '../../shared/domain/stock-position.ts'; +import type { + StockPosition, + StockPositionOnHandEvidence, + StockPositionScope, +} from '../../shared/domain/stock-position.ts'; +import type { StockPositionRef } from '../../shared/resources/stock-position.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type StockPositionRow = typeof inventoryStockPositions.$inferSelect; +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; +const STOCK_POSITION_RESOURCE_TYPE = 'commerce.inventory.stock-position' as const; + +export class StockPositionPersistenceUnavailable extends Schema.TaggedError()( + 'StockPositionPersistenceUnavailable', + { + code: Schema.Literal('stock_position_persistence_unavailable'), + reason: Schema.String, + }, +) {} + +type StockPositionPersistenceError = StockPositionRejected | StockPositionPersistenceUnavailable; + +/** Transaction-scoped owner port. It stores ON_HAND only; RESERVED has no write operation. */ +export interface StockPositionPersistence { + readonly create: (position: StockPosition) => EffectType.Effect; + readonly findCurrent: ( + scope: StockPositionScope, + ) => EffectType.Effect, StockPositionPersistenceError>; + readonly read: ( + ref: StockPositionRef, + ) => EffectType.Effect, StockPositionPersistenceError>; + readonly save: (input: { + readonly expectedRevision: number; + readonly next: StockPosition; + }) => EffectType.Effect; +} + +const unavailable = (cause: unknown): StockPositionPersistenceUnavailable => { + const failure = new StockPositionPersistenceUnavailable({ + code: 'stock_position_persistence_unavailable', + reason: 'Stock Position persistence is temporarily unavailable', + }); + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + return failure; +}; + +const reject = (positionRef: StockPositionRef, reason: StockPositionRejected['reason']) => + new StockPositionRejected({ code: 'stock_position_rejected', positionRef, reason }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); + +export const mapStockPositionWriteError = ( + positionRef: StockPositionRef, + cause: unknown, +): StockPositionPersistenceError => { + const currentScope = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_stock_positions_current_scope_uk', + ); + if (Option.isSome(currentScope)) { + return reject(positionRef, 'POSITION_SCOPE_ALREADY_CURRENT'); + } + const exactItemUnit = findPostgresFailure( + cause, + ({ code, constraint }) => + code === checkViolationSqlState && constraint === 'inventory_stock_positions_exact_item_unit_ck', + ); + if (Option.isSome(exactItemUnit)) { + return reject(positionRef, 'STOCK_UNIT_MISMATCH'); + } + const ownerConfiguration = findPostgresFailure( + cause, + ({ code, constraint }) => + code === checkViolationSqlState && constraint === 'inventory_stock_positions_owner_configuration_ck', + ); + if (Option.isSome(ownerConfiguration)) { + return reject(positionRef, 'OWNER_CONFIGURATION_MISMATCH'); + } + const constrainedScopeForeignKey = findPostgresFailure(cause, ({ code, constraint }) => { + if (code !== foreignKeyViolationSqlState) { + return false; + } + return [ + 'inventory_stock_positions_backend_configuration_fk', + 'inventory_stock_positions_item_fk', + 'inventory_stock_positions_location_fk', + ].includes(constraint ?? ''); + }); + if (Option.isSome(constrainedScopeForeignKey)) { + if (constrainedScopeForeignKey.value.constraint === 'inventory_stock_positions_item_fk') { + return reject(positionRef, 'STOCK_ITEM_NOT_FOUND'); + } + if (constrainedScopeForeignKey.value.constraint === 'inventory_stock_positions_location_fk') { + return reject(positionRef, 'STOCK_LOCATION_NOT_FOUND'); + } + return reject(positionRef, 'OWNER_CONFIGURATION_MISMATCH'); + } + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + ['stock_positions_pkey', 'inventory_stock_positions_scope_id_uk'].includes(constraint ?? ''), + ); + return Option.isSome(identity) ? reject(positionRef, 'POSITION_IDENTITY_CONFLICT') : unavailable(cause); +}; + +const unitRefFor = (row: StockPositionRow) => ({ + moduleId: row.stockUnitModuleId, + resourceId: row.stockUnitResourceId, + resourceType: row.stockUnitResourceType, + tenantId: row.stockUnitTenantId, +}); + +const positionRefFor = (row: StockPositionRow) => ({ + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockPositionId, + resourceType: STOCK_POSITION_RESOURCE_TYPE, + tenantId: row.tenantId, +}); + +const storedNumericPattern = /^(?[0-9]+)(?:\.(?[0-9]+))?$/u; + +/** PostgreSQL numeric(scale) text is exact but padded; domain decimals are exact and canonical. */ +const canonicalAmount = (amount: string | null): string => { + if (amount === null) { + return ''; + } + const groups = storedNumericPattern.exec(amount)?.groups; + if (groups?.['integer'] === undefined) { + return amount; + } + const integer = BigInt(groups['integer']).toString(); + const fraction = (groups['fraction'] ?? '').replace(/0+$/u, ''); + return fraction.length === 0 ? integer : `${integer}.${fraction}`; +}; + +const ownerConfigurationRefFor = (row: StockPositionRow) => ({ + moduleId: INVENTORY_MODULE_ID, + resourceId: row.ownerConfigurationId, + resourceType: 'commerce.inventory.inventory-backend-configuration' as const, + tenantId: row.tenantId, +}); + +const onHandFor = (row: StockPositionRow) => { + const ownerConfigurationRef = ownerConfigurationRefFor(row); + const unitRef = unitRefFor(row); + if (row.onHandState === 'CURRENT') { + return { + _tag: 'CURRENT', + evidenceRef: row.onHandEvidenceRef ?? '', + meaning: 'ON_HAND', + observedAt: row.onHandObservedAt?.toISOString() ?? '', + ownerConfigurationRef, + quantity: { amount: canonicalAmount(row.onHandAmount), unitRef }, + } as const; + } + if (row.onHandState === 'STALE') { + return { + _tag: 'STALE', + evidenceRef: row.onHandEvidenceRef ?? '', + lastKnownQuantity: { amount: canonicalAmount(row.onHandAmount), unitRef }, + lastObservedAt: row.onHandObservedAt?.toISOString() ?? '', + meaning: 'ON_HAND', + ownerConfigurationRef, + } as const; + } + return { _tag: row.onHandState, meaning: 'ON_HAND' as const, ownerConfigurationRef, unitRef }; +}; + +const decodeRow = (row: StockPositionRow) => + Schema.decodeUnknownEffect(StockPositionSchema)({ + createdAt: row.createdAt.toISOString(), + endedAt: row.endedAt?.toISOString() ?? null, + lifecycle: row.lifecycleState, + onHand: onHandFor(row), + ref: positionRefFor(row), + revision: row.revision, + scope: { + customerConfigurationId: row.customerConfigurationId, + stockItemRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockItemId, + resourceType: 'commerce.inventory.stock-item', + tenantId: row.tenantId, + }, + stockLocationRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockLocationId, + resourceType: 'commerce.inventory.stock-location', + tenantId: row.tenantId, + }, + unitRef: unitRefFor(row), + }, + }).pipe(Effect.mapError(unavailable)); + +const evidenceColumns = (onHand: StockPositionOnHandEvidence) => + Match.value(onHand).pipe( + Match.tag('CURRENT', (current) => ({ + onHandAmount: current.quantity.amount, + onHandEvidenceRef: current.evidenceRef, + onHandObservedAt: DateTime.toDateUtc(DateTime.makeUnsafe(current.observedAt)), + onHandState: current._tag, + ownerConfigurationId: current.ownerConfigurationRef.resourceId, + })), + Match.tag('STALE', (stale) => ({ + onHandAmount: stale.lastKnownQuantity.amount, + onHandEvidenceRef: stale.evidenceRef, + onHandObservedAt: DateTime.toDateUtc(DateTime.makeUnsafe(stale.lastObservedAt)), + onHandState: stale._tag, + ownerConfigurationId: stale.ownerConfigurationRef.resourceId, + })), + Match.tag('UNKNOWN', 'MISSING', 'INDETERMINATE', (unavailableEvidence) => ({ + onHandAmount: null, + onHandEvidenceRef: null, + onHandObservedAt: null, + onHandState: unavailableEvidence._tag, + ownerConfigurationId: unavailableEvidence.ownerConfigurationRef.resourceId, + })), + Match.exhaustive, + ); + +const insertValues = (position: StockPosition) => ({ + createdAt: DateTime.toDateUtc(DateTime.makeUnsafe(position.createdAt)), + customerConfigurationId: position.scope.customerConfigurationId, + endedAt: position.endedAt === null ? null : DateTime.toDateUtc(DateTime.makeUnsafe(position.endedAt)), + ...evidenceColumns(position.onHand), + lifecycleState: position.lifecycle, + revision: position.revision, + stockItemId: position.scope.stockItemRef.resourceId, + stockLocationId: position.scope.stockLocationRef.resourceId, + stockPositionId: position.ref.resourceId, + stockUnitModuleId: position.scope.unitRef.moduleId, + stockUnitResourceId: position.scope.unitRef.resourceId, + stockUnitResourceType: position.scope.unitRef.resourceType, + stockUnitTenantId: position.scope.unitRef.tenantId, + tenantId: position.ref.tenantId, +}); + +const mutableValues = (position: StockPosition) => ({ + endedAt: position.endedAt === null ? null : DateTime.toDateUtc(DateTime.makeUnsafe(position.endedAt)), + ...evidenceColumns(position.onHand), + lifecycleState: position.lifecycle, + revision: position.revision, +}); + +export const stockPositionPersistenceForScope = ( + transaction: ScopedTransaction, + scope: OperationalScope, +): StockPositionPersistence => { + const requireTenant = (ref: StockPositionRef) => + ref.tenantId === scope.tenantId ? Effect.void : Effect.fail(reject(ref, 'TENANT_SCOPE_MISMATCH')); + + const readRows = (ref: StockPositionRef) => + transaction + .select() + .from(inventoryStockPositions) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.stockPositionId, ref.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + + const requireSelectedOwnerConfiguration = Effect.fn('StockPositionPersistence.requireSelectedOwnerConfiguration')( + function* requireSelectedOwner( + positionRef: StockPositionRef, + customerConfigurationId: string, + ownerConfigurationId: string, + ) { + const [selected] = yield* transaction + .select() + .from(inventoryBackendConfigurations) + .where( + and( + eq(inventoryBackendConfigurations.tenantId, scope.tenantId), + eq(inventoryBackendConfigurations.configurationId, ownerConfigurationId), + eq(inventoryBackendConfigurations.customerConfigurationId, customerConfigurationId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + if (selected === undefined) { + return yield* reject(positionRef, 'OWNER_CONFIGURATION_MISMATCH'); + } + return yield* Effect.void; + }, + ); + + const decodeOwnedRow = Effect.fn('StockPositionPersistence.decodeOwnedRow')(function* decodeSelectedOwnerRow( + row: StockPositionRow, + ) { + const positionRef = positionRefFor(row); + yield* requireSelectedOwnerConfiguration(positionRef, row.customerConfigurationId, row.ownerConfigurationId); + return yield* decodeRow(row); + }); + + const create: StockPositionPersistence['create'] = Effect.fn('StockPositionPersistence.create')( + function* createStockPosition(position) { + yield* requireTenant(position.ref); + if (!Schema.is(StockPositionSchema)(position) || position.lifecycle !== 'CURRENT' || position.revision !== 1) { + return yield* reject(position.ref, 'INVALID_POSITION'); + } + yield* requireSelectedOwnerConfiguration( + position.ref, + position.scope.customerConfigurationId, + position.onHand.ownerConfigurationRef.resourceId, + ); + const [row] = yield* transaction + .insert(inventoryStockPositions) + .values(insertValues(position)) + .returning() + .pipe(Effect.mapError((cause) => mapStockPositionWriteError(position.ref, cause))); + return row === undefined ? yield* unavailable('Stock Position insert returned no row') : yield* decodeRow(row); + }, + ); + + const read: StockPositionPersistence['read'] = Effect.fn('StockPositionPersistence.read')( + function* readStockPosition(ref) { + yield* requireTenant(ref); + const [row] = yield* readRows(ref); + return row === undefined ? Option.none() : Option.some(yield* decodeOwnedRow(row)); + }, + ); + + const findCurrent: StockPositionPersistence['findCurrent'] = Effect.fn('StockPositionPersistence.findCurrent')( + function* findCurrentStockPosition(positionScope) { + if ( + positionScope.stockItemRef.tenantId !== scope.tenantId || + positionScope.stockLocationRef.tenantId !== scope.tenantId || + positionScope.unitRef.tenantId !== scope.tenantId + ) { + const syntheticRef = { + moduleId: INVENTORY_MODULE_ID, + resourceId: '00000000-0000-4000-8000-000000000000', + resourceType: STOCK_POSITION_RESOURCE_TYPE, + tenantId: positionScope.stockItemRef.tenantId, + }; + return yield* reject(syntheticRef, 'TENANT_SCOPE_MISMATCH'); + } + const [row] = yield* transaction + .select() + .from(inventoryStockPositions) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.customerConfigurationId, positionScope.customerConfigurationId), + eq(inventoryStockPositions.stockItemId, positionScope.stockItemRef.resourceId), + eq(inventoryStockPositions.stockLocationId, positionScope.stockLocationRef.resourceId), + eq(inventoryStockPositions.lifecycleState, 'CURRENT'), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + return row === undefined ? Option.none() : Option.some(yield* decodeOwnedRow(row)); + }, + ); + + const save: StockPositionPersistence['save'] = Effect.fn('StockPositionPersistence.save')( + function* saveStockPosition({ expectedRevision, next }) { + yield* requireTenant(next.ref); + if (!Schema.is(StockPositionSchema)(next) || next.revision !== expectedRevision + 1) { + return yield* reject(next.ref, 'INVALID_POSITION'); + } + yield* requireSelectedOwnerConfiguration( + next.ref, + next.scope.customerConfigurationId, + next.onHand.ownerConfigurationRef.resourceId, + ); + const [row] = yield* transaction + .update(inventoryStockPositions) + .set({ ...mutableValues(next), updatedAt: DateTime.toDateUtc(yield* DateTime.now) }) + .where( + and( + eq(inventoryStockPositions.tenantId, scope.tenantId), + eq(inventoryStockPositions.stockPositionId, next.ref.resourceId), + eq(inventoryStockPositions.revision, expectedRevision), + ), + ) + .returning() + .pipe(Effect.mapError((cause) => mapStockPositionWriteError(next.ref, cause))); + if (row === undefined) { + const [observed] = yield* readRows(next.ref); + return yield* reject(next.ref, observed === undefined ? 'POSITION_NOT_FOUND' : 'POSITION_REVISION_CONFLICT'); + } + return yield* decodeRow(row); + }, + ); + + return Object.freeze({ create, findCurrent, read, save }); +}; diff --git a/app/verticals/inventory/src/persistence/stock-position-table.ts b/app/verticals/inventory/src/persistence/stock-position-table.ts new file mode 100644 index 000000000..481362c19 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-position-table.ts @@ -0,0 +1,146 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, numeric, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryStockItems } from './stock-item-table.ts'; +import { inventoryStockLocations } from './stock-location-table.ts'; + +const STOCK_POSITIONS_TABLE = 'inventory.stock_positions'; + +export const inventoryStockPositionImmutabilityTriggerContract = { + columns: [ + 'stock_position_id', + 'tenant_id', + 'customer_configuration_id', + 'stock_item_id', + 'stock_location_id', + 'stock_unit_module_id', + 'stock_unit_resource_id', + 'stock_unit_resource_type', + 'stock_unit_tenant_id', + ], + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE OR DELETE', + functionName: 'inventory.reject_stock_position_scope_mutation', + table: STOCK_POSITIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_positions_immutable_scope_trg', +} as const; + +/** Migration hardening for the exact Product Unit already fixed by the referenced Stock Item. */ +export const inventoryStockPositionUnitMatchTriggerContract = { + constraintName: 'inventory_stock_positions_exact_item_unit_ck', + errorCondition: 'check_violation', + event: 'INSERT OR UPDATE', + functionName: 'inventory.enforce_stock_position_stock_item_unit', + lookupColumns: [ + 'tenant_id', + 'stock_item_id', + 'stock_unit_module_id', + 'stock_unit_resource_id', + 'stock_unit_resource_type', + 'stock_unit_tenant_id', + ], + lookupTable: 'inventory.stock_items', + table: STOCK_POSITIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_positions_exact_item_unit_trg', +} as const; + +/** Migration hardening for the selected Customer Configuration-wide Inventory Backend owner. */ +export const inventoryStockPositionOwnerConfigurationTriggerContract = { + constraintName: 'inventory_stock_positions_owner_configuration_ck', + event: 'INSERT OR UPDATE', + foreignKeyName: 'inventory_stock_positions_backend_configuration_fk', + functionName: 'inventory.enforce_stock_position_owner_configuration', + lookupColumns: ['tenant_id', 'configuration_id', 'customer_configuration_id'], + lookupTable: 'inventory.backend_configurations', + table: STOCK_POSITIONS_TABLE, + timing: 'BEFORE', + triggerName: 'inventory_stock_positions_owner_configuration_trg', +} as const; + +/** + * Durable Position rows retain historical identities. RESERVED deliberately has no column: it is + * derived from Current successful Reservation Allocations at the owner read seam. + */ +export const inventoryStockPositions = inventorySchema.table.withRLS( + 'stock_positions', + { + stockPositionId: uuid('stock_position_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + stockItemId: uuid('stock_item_id').notNull(), + stockLocationId: uuid('stock_location_id').notNull(), + stockUnitModuleId: text('stock_unit_module_id').notNull(), + stockUnitResourceId: uuid('stock_unit_resource_id').notNull(), + stockUnitResourceType: text('stock_unit_resource_type').notNull(), + stockUnitTenantId: uuid('stock_unit_tenant_id').notNull(), + lifecycleState: text('lifecycle_state').default('CURRENT').notNull(), + onHandState: text('on_hand_state').notNull(), + onHandAmount: numeric('on_hand_amount', { precision: 38, scale: 9 }), + onHandEvidenceRef: text('on_hand_evidence_ref'), + onHandObservedAt: timestamp('on_hand_observed_at', { withTimezone: true }), + ownerConfigurationId: uuid('owner_configuration_id').notNull(), + revision: integer('revision').default(1).notNull(), + endedAt: timestamp('ended_at', { withTimezone: true }), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_stock_positions_scope_id_uk').on(table.tenantId, table.stockPositionId), + uniqueIndex('inventory_stock_positions_current_scope_uk') + .on(table.tenantId, table.customerConfigurationId, table.stockItemId, table.stockLocationId) + .where(sql`${table.lifecycleState} = 'CURRENT'`), + foreignKey({ + columns: [table.tenantId, table.stockItemId], + foreignColumns: [inventoryStockItems.tenantId, inventoryStockItems.stockItemId], + name: 'inventory_stock_positions_item_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockLocationId], + foreignColumns: [inventoryStockLocations.tenantId, inventoryStockLocations.stockLocationId], + name: 'inventory_stock_positions_location_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.ownerConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_stock_positions_backend_configuration_fk', + }).onDelete('restrict'), + index('inventory_stock_positions_item_idx').on(table.tenantId, table.stockItemId), + index('inventory_stock_positions_location_idx').on(table.tenantId, table.stockLocationId), + check( + 'inventory_stock_positions_customer_configuration_ck', + sql`${table.customerConfigurationId} = btrim(${table.customerConfigurationId}) and length(${table.customerConfigurationId}) between 1 and 300`, + ), + check( + 'inventory_stock_positions_unit_ck', + sql`${table.stockUnitModuleId} = 'commerce.catalog' and ${table.stockUnitResourceType} = 'commerce.catalog.product-unit' and ${table.stockUnitTenantId} = ${table.tenantId}`, + ), + check('inventory_stock_positions_lifecycle_ck', sql`${table.lifecycleState} in ('CURRENT', 'HISTORICAL')`), + check( + 'inventory_stock_positions_ended_at_ck', + sql`(${table.lifecycleState} = 'CURRENT' and ${table.endedAt} is null) or (${table.lifecycleState} = 'HISTORICAL' and ${table.endedAt} is not null)`, + ), + check( + 'inventory_stock_positions_historical_on_hand_ck', + sql`not (${table.lifecycleState} = 'HISTORICAL' and ${table.onHandState} = 'CURRENT')`, + ), + check( + 'inventory_stock_positions_on_hand_state_ck', + sql`${table.onHandState} in ('CURRENT', 'UNKNOWN', 'MISSING', 'STALE', 'INDETERMINATE')`, + ), + check( + 'inventory_stock_positions_on_hand_value_ck', + sql`((${table.onHandState} in ('CURRENT', 'STALE')) and ${table.onHandAmount} is not null and ${table.onHandAmount} >= 0 and ${table.onHandEvidenceRef} is not null and ${table.onHandObservedAt} is not null) or ((${table.onHandState} in ('UNKNOWN', 'MISSING', 'INDETERMINATE')) and ${table.onHandAmount} is null and ${table.onHandEvidenceRef} is null and ${table.onHandObservedAt} is null)`, + ), + check('inventory_stock_positions_revision_ck', sql`${table.revision} >= 1`), + ...tenantRlsPolicies('inventory_stock_positions_tenant', table.tenantId), + ], +); + +export const INVENTORY_STOCK_POSITION_TABLES = [inventoryStockPositions] as const; diff --git a/app/verticals/inventory/src/persistence/stock-sharing-eligibility-repository.ts b/app/verticals/inventory/src/persistence/stock-sharing-eligibility-repository.ts new file mode 100644 index 000000000..074710989 --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-sharing-eligibility-repository.ts @@ -0,0 +1,327 @@ +import { findPostgresFailure } from '@app/core-runtime'; +import type { OperationalScope, ReadServiceFactory } from '@app/core-runtime'; +import { and, asc, eq } from 'drizzle-orm'; +import { DateTime, Effect, Option, Schema } from 'effect'; + +import { + StockSharingEligibilityRejected, + StockSharingEligibilitySchema, +} from '../../shared/domain/stock-sharing-eligibility.ts'; +import type { + StockSharingEligibility, + StockSharingEligibilityError, + StockSharingEligibilityPersistence, +} from '../../shared/domain/stock-sharing-eligibility.ts'; +import { StockSharingEligibilityUnavailable } from '../../shared/domain/stock-sharing-eligibility-unavailable.ts'; +import type { StockSharingEligibilityRef } from '../../shared/resources/stock-sharing-eligibility.ts'; +import { + inventoryStockSharingEligibilities, + inventoryStockSharingEligibilityHistory, + inventoryStockSharingEligibilityScopeTriggerContract, +} from './stock-sharing-eligibility-table.ts'; + +type ScopedTransaction = Parameters>>>[0]; +type EligibilityRow = typeof inventoryStockSharingEligibilities.$inferSelect; +type HistoryRow = typeof inventoryStockSharingEligibilityHistory.$inferSelect; +const INVENTORY_MODULE_ID = 'commerce.inventory' as const; + +const unavailable = (cause?: unknown) => { + const failure = new StockSharingEligibilityUnavailable({ + code: 'stock_sharing_eligibility_unavailable', + reason: 'Stock Sharing Eligibility persistence or owner validation is temporarily unavailable', + }); + if (cause !== undefined) { + Object.defineProperty(failure, 'cause', { configurable: true, value: cause }); + } + return failure; +}; + +const reject = (reason: StockSharingEligibilityRejected['reason'], relationRef?: StockSharingEligibilityRef) => + relationRef === undefined + ? new StockSharingEligibilityRejected({ code: 'stock_sharing_eligibility_rejected', reason }) + : new StockSharingEligibilityRejected({ code: 'stock_sharing_eligibility_rejected', reason, relationRef }); + +const uniqueViolationSqlState = ['23', '505'].join(''); +const foreignKeyViolationSqlState = ['23', '503'].join(''); +const checkViolationSqlState = ['23', '514'].join(''); + +export const mapStockSharingEligibilityWriteError = (cause: unknown): StockSharingEligibilityError => { + const identity = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && + ['stock_sharing_eligibilities_pkey', 'inventory_stock_sharing_eligibilities_scope_id_uk'].includes( + constraint ?? '', + ), + ); + if (Option.isSome(identity)) { + return reject('RELATION_IDENTITY_CONFLICT'); + } + const revision = findPostgresFailure( + cause, + ({ code, constraint }) => + code === uniqueViolationSqlState && constraint === 'inventory_stock_sharing_eligibility_history_revision_uk', + ); + if (Option.isSome(revision)) { + return reject('REVISION_CONFLICT'); + } + const { constraintNames } = inventoryStockSharingEligibilityScopeTriggerContract; + const scope = findPostgresFailure( + cause, + ({ code, constraint }) => + (code === foreignKeyViolationSqlState && + [ + 'inventory_stock_sharing_eligibilities_backend_configuration_fk', + 'inventory_stock_sharing_eligibilities_position_fk', + ].includes(constraint ?? '')) || + (code === checkViolationSqlState && + (constraint === constraintNames.backend || constraint === constraintNames.position)), + ); + return Option.isSome(scope) ? reject('POSITION_SCOPE_MISMATCH') : unavailable(cause); +}; + +const instantAsDate = (instant: string) => DateTime.toDateUtc(DateTime.makeUnsafe(instant)); + +const valuesFor = (relation: StockSharingEligibility) => ({ + channel: relation.subject.channel, + commerceMarketId: relation.subject.commerceMarketRef?.resourceId ?? null, + commerceValidationEvidenceRef: relation.commerceValidation.evidenceRef, + commerceValidationObservedAt: instantAsDate(relation.commerceValidation.observedAt), + currentRevision: relation.revision, + customerConfigurationId: relation.scope.customerConfigurationId, + effectiveFrom: instantAsDate(relation.effectivePeriod.from), + effectiveTo: relation.effectivePeriod.to === null ? null : instantAsDate(relation.effectivePeriod.to), + eligibilityId: relation.ref.resourceId, + lifecycleState: relation.lifecycle, + ownerConfigurationId: relation.scope.ownerConfigurationRef.resourceId, + sellingLegalEntityId: relation.subject.sellingLegalEntityRef.resourceId, + stockPositionId: relation.scope.positionRef.resourceId, + storefrontAppId: relation.subject.storefrontRef?.appId ?? null, + tenantId: relation.ref.tenantId, +}); + +const subjectFor = (row: EligibilityRow) => { + const required = { + channel: row.channel, + sellingLegalEntityRef: { + moduleId: 'core.identity', + resourceId: row.sellingLegalEntityId, + resourceType: 'core.identity.legal-entity', + tenantId: row.tenantId, + }, + }; + const commerceMarketRef = + row.commerceMarketId === null + ? undefined + : { + moduleId: 'commerce.market-catalog' as const, + resourceId: row.commerceMarketId, + resourceType: 'commerce.market-catalog.market' as const, + tenantId: row.tenantId, + }; + const storefrontRef = + row.storefrontAppId === null ? undefined : { appId: row.storefrontAppId, tenantId: row.tenantId }; + if (commerceMarketRef === undefined && storefrontRef === undefined) { + return required; + } + if (commerceMarketRef !== undefined && storefrontRef === undefined) { + return { ...required, commerceMarketRef }; + } + if (commerceMarketRef === undefined && storefrontRef !== undefined) { + return { ...required, storefrontRef }; + } + return { + ...required, + commerceMarketRef, + storefrontRef, + }; +}; + +const decodeRow = (row: EligibilityRow) => + Schema.decodeUnknownEffect(StockSharingEligibilitySchema)({ + commerceValidation: { + evidenceRef: row.commerceValidationEvidenceRef, + observedAt: row.commerceValidationObservedAt.toISOString(), + verification: 'OWNER_VERIFIED_CURRENT', + }, + effectivePeriod: { + from: row.effectiveFrom.toISOString(), + to: row.effectiveTo?.toISOString() ?? null, + }, + lifecycle: row.lifecycleState, + ref: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.eligibilityId, + resourceType: 'commerce.inventory.stock-sharing-eligibility', + tenantId: row.tenantId, + }, + revision: row.currentRevision, + scope: { + customerConfigurationId: row.customerConfigurationId, + ownerConfigurationRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.ownerConfigurationId, + resourceType: 'commerce.inventory.inventory-backend-configuration', + tenantId: row.tenantId, + }, + positionRef: { + moduleId: INVENTORY_MODULE_ID, + resourceId: row.stockPositionId, + resourceType: 'commerce.inventory.stock-position', + tenantId: row.tenantId, + }, + }, + subject: subjectFor(row), + }).pipe(Effect.mapError(unavailable)); + +export const decodeStockSharingEligibilityHistoryRows = (rows: readonly HistoryRow[]) => + Effect.forEach( + rows, + (row) => Schema.decodeEffect(StockSharingEligibilitySchema)(row.snapshot).pipe(Effect.mapError(unavailable)), + { concurrency: 1 }, + ).pipe( + Effect.flatMap((snapshots) => + Effect.forEach( + snapshots, + (snapshot, index) => { + const successor = rows[index + 1]; + if (successor === undefined || snapshot.effectivePeriod.to !== null) { + return Effect.succeed(snapshot); + } + return Schema.decodeEffect(StockSharingEligibilitySchema)({ + ...snapshot, + effectivePeriod: { + from: snapshot.effectivePeriod.from, + to: successor.transitionAt.toISOString(), + }, + lifecycle: 'ENDED', + }).pipe(Effect.mapError(unavailable)); + }, + { concurrency: 1 }, + ), + ), + ); + +export const stockSharingEligibilityPersistenceForScope = ( + transaction: ScopedTransaction, + operationScope: OperationalScope, +): StockSharingEligibilityPersistence => { + const requireTenant = ( + tenantId: string, + relationRef?: StockSharingEligibilityRef, + ): Effect.Effect => + tenantId === operationScope.tenantId ? Effect.void : Effect.fail(reject('TENANT_SCOPE_MISMATCH', relationRef)); + + const findByRef: StockSharingEligibilityPersistence['findByRef'] = Effect.fn( + 'StockSharingEligibilityPersistence.findByRef', + )(function* findRelation(relationRef) { + yield* requireTenant(relationRef.tenantId, relationRef); + const [row] = yield* transaction + .select() + .from(inventoryStockSharingEligibilities) + .where( + and( + eq(inventoryStockSharingEligibilities.tenantId, operationScope.tenantId), + eq(inventoryStockSharingEligibilities.eligibilityId, relationRef.resourceId), + ), + ) + .limit(1) + .pipe(Effect.mapError(unavailable)); + return row === undefined ? Option.none() : Option.some(yield* decodeRow(row)); + }); + + const appendHistory = (relation: StockSharingEligibility, transitionAt: string) => + transaction + .insert(inventoryStockSharingEligibilityHistory) + .values({ + eligibilityId: relation.ref.resourceId, + revision: relation.revision, + snapshot: relation, + tenantId: relation.ref.tenantId, + transitionAt: instantAsDate(transitionAt), + }) + .pipe(Effect.mapError(mapStockSharingEligibilityWriteError), Effect.asVoid); + + const insertCurrent: StockSharingEligibilityPersistence['insertCurrent'] = Effect.fn( + 'StockSharingEligibilityPersistence.insertCurrent', + )(function* insertCurrentRelation(relation) { + yield* requireTenant(relation.ref.tenantId, relation.ref); + const [row] = yield* transaction + .insert(inventoryStockSharingEligibilities) + .values(valuesFor(relation)) + .returning() + .pipe(Effect.mapError(mapStockSharingEligibilityWriteError)); + if (row === undefined) { + return yield* unavailable(); + } + const persisted = yield* decodeRow(row); + yield* appendHistory(persisted, persisted.effectivePeriod.from); + return persisted; + }); + + const listCurrent: StockSharingEligibilityPersistence['listCurrent'] = (scope) => + requireTenant(scope.positionRef.tenantId).pipe( + Effect.flatMap(() => + transaction + .select() + .from(inventoryStockSharingEligibilities) + .where( + and( + eq(inventoryStockSharingEligibilities.tenantId, operationScope.tenantId), + eq(inventoryStockSharingEligibilities.customerConfigurationId, scope.customerConfigurationId), + eq(inventoryStockSharingEligibilities.ownerConfigurationId, scope.ownerConfigurationRef.resourceId), + eq(inventoryStockSharingEligibilities.stockPositionId, scope.positionRef.resourceId), + eq(inventoryStockSharingEligibilities.lifecycleState, 'CURRENT'), + ), + ) + .pipe( + Effect.mapError(unavailable), + Effect.flatMap((rows) => Effect.forEach(rows, decodeRow, { concurrency: 1 })), + ), + ), + ); + + const readHistory: StockSharingEligibilityPersistence['readHistory'] = (relationRef) => + requireTenant(relationRef.tenantId, relationRef).pipe( + Effect.flatMap(() => + transaction + .select() + .from(inventoryStockSharingEligibilityHistory) + .where( + and( + eq(inventoryStockSharingEligibilityHistory.tenantId, operationScope.tenantId), + eq(inventoryStockSharingEligibilityHistory.eligibilityId, relationRef.resourceId), + ), + ) + .orderBy(asc(inventoryStockSharingEligibilityHistory.revision)) + .pipe(Effect.mapError(unavailable), Effect.flatMap(decodeStockSharingEligibilityHistoryRows)), + ), + ); + + const saveRevision: StockSharingEligibilityPersistence['saveRevision'] = Effect.fn( + 'StockSharingEligibilityPersistence.saveRevision', + )(function* saveEligibilityRevision({ current, next }) { + yield* requireTenant(current.ref.tenantId, current.ref); + const [row] = yield* transaction + .update(inventoryStockSharingEligibilities) + .set(valuesFor(next)) + .where( + and( + eq(inventoryStockSharingEligibilities.tenantId, operationScope.tenantId), + eq(inventoryStockSharingEligibilities.eligibilityId, current.ref.resourceId), + eq(inventoryStockSharingEligibilities.currentRevision, current.revision), + ), + ) + .returning() + .pipe(Effect.mapError(mapStockSharingEligibilityWriteError)); + if (row === undefined) { + return yield* reject('REVISION_CONFLICT', current.ref); + } + const persisted = yield* decodeRow(row); + const transitionAt = persisted.effectivePeriod.to ?? persisted.effectivePeriod.from; + yield* appendHistory(persisted, transitionAt); + return persisted; + }); + + return Object.freeze({ findByRef, insertCurrent, listCurrent, readHistory, saveRevision }); +}; diff --git a/app/verticals/inventory/src/persistence/stock-sharing-eligibility-table.ts b/app/verticals/inventory/src/persistence/stock-sharing-eligibility-table.ts new file mode 100644 index 000000000..52baef9fe --- /dev/null +++ b/app/verticals/inventory/src/persistence/stock-sharing-eligibility-table.ts @@ -0,0 +1,123 @@ +/* oxlint-disable perfectionist/sort-objects -- Drizzle declaration order is the physical owner contract; expires: 2027-03-31. */ +import { tenantRlsPolicies } from '@app/core-runtime'; +import { sql } from 'drizzle-orm'; +import { check, foreignKey, index, integer, jsonb, text, timestamp, uniqueIndex, uuid } from 'drizzle-orm/pg-core'; + +import type { StockSharingEligibility } from '../../shared/domain/stock-sharing-eligibility.ts'; +import { inventorySchema } from '../database/inventory-schema.ts'; +import { inventoryBackendConfigurations } from './inventory-backend-configuration-table.ts'; +import { inventoryStockPositions } from './stock-position-table.ts'; + +export const inventoryStockSharingEligibilities = inventorySchema.table.withRLS( + 'stock_sharing_eligibilities', + { + eligibilityId: uuid('eligibility_id').primaryKey(), + tenantId: uuid('tenant_id').notNull(), + customerConfigurationId: text('customer_configuration_id').notNull(), + ownerConfigurationId: uuid('owner_configuration_id').notNull(), + stockPositionId: uuid('stock_position_id').notNull(), + sellingLegalEntityId: uuid('selling_legal_entity_id').notNull(), + channel: text('channel').notNull(), + commerceMarketId: text('commerce_market_id'), + storefrontAppId: text('storefront_app_id'), + commerceValidationEvidenceRef: text('commerce_validation_evidence_ref').notNull(), + commerceValidationObservedAt: timestamp('commerce_validation_observed_at', { withTimezone: true }).notNull(), + lifecycleState: text('lifecycle_state').default('CURRENT').notNull(), + effectiveFrom: timestamp('effective_from', { withTimezone: true }).notNull(), + effectiveTo: timestamp('effective_to', { withTimezone: true }), + currentRevision: integer('current_revision').default(1).notNull(), + createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_stock_sharing_eligibilities_scope_id_uk').on(table.tenantId, table.eligibilityId), + index('inventory_stock_sharing_eligibilities_current_position_idx') + .on(table.tenantId, table.customerConfigurationId, table.ownerConfigurationId, table.stockPositionId) + .where(sql`${table.lifecycleState} = 'CURRENT' and ${table.effectiveTo} is null`), + foreignKey({ + columns: [table.tenantId, table.ownerConfigurationId], + foreignColumns: [inventoryBackendConfigurations.tenantId, inventoryBackendConfigurations.configurationId], + name: 'inventory_stock_sharing_eligibilities_backend_configuration_fk', + }).onDelete('restrict'), + foreignKey({ + columns: [table.tenantId, table.stockPositionId], + foreignColumns: [inventoryStockPositions.tenantId, inventoryStockPositions.stockPositionId], + name: 'inventory_stock_sharing_eligibilities_position_fk', + }).onDelete('restrict'), + check( + 'inventory_stock_sharing_eligibilities_subject_ck', + sql`${table.channel} in ('B2C', 'B2B') and char_length(btrim(${table.commerceValidationEvidenceRef})) between 1 and 300 and (${table.commerceMarketId} is null or char_length(btrim(${table.commerceMarketId})) between 1 and 300) and (${table.storefrontAppId} is null or ${table.storefrontAppId} ~ '^[a-z0-9]+(?:-[a-z0-9]+)*$')`, + ), + check( + 'inventory_stock_sharing_eligibilities_lifecycle_ck', + sql`(${table.lifecycleState} = 'CURRENT' and ${table.effectiveTo} is null) or (${table.lifecycleState} = 'ENDED' and ${table.effectiveTo} is not null and ${table.effectiveFrom} < ${table.effectiveTo})`, + ), + check('inventory_stock_sharing_eligibilities_revision_ck', sql`${table.currentRevision} >= 1`), + ...tenantRlsPolicies('inventory_stock_sharing_eligibilities_tenant', table.tenantId), + ], +); + +export const inventoryStockSharingEligibilityHistory = inventorySchema.table.withRLS( + 'stock_sharing_eligibility_history', + { + historyId: uuid('history_id').defaultRandom().primaryKey(), + tenantId: uuid('tenant_id').notNull(), + eligibilityId: uuid('eligibility_id').notNull(), + revision: integer('revision').notNull(), + snapshot: jsonb('snapshot').$type().notNull(), + transitionAt: timestamp('transition_at', { withTimezone: true }).notNull(), + recordedAt: timestamp('recorded_at', { withTimezone: true }).defaultNow().notNull(), + }, + (table) => [ + uniqueIndex('inventory_stock_sharing_eligibility_history_scope_id_uk').on(table.tenantId, table.historyId), + uniqueIndex('inventory_stock_sharing_eligibility_history_revision_uk').on( + table.tenantId, + table.eligibilityId, + table.revision, + ), + foreignKey({ + columns: [table.tenantId, table.eligibilityId], + foreignColumns: [inventoryStockSharingEligibilities.tenantId, inventoryStockSharingEligibilities.eligibilityId], + name: 'inventory_stock_sharing_eligibility_history_eligibility_fk', + }).onDelete('restrict'), + check('inventory_stock_sharing_eligibility_history_revision_ck', sql`${table.revision} >= 1`), + ...tenantRlsPolicies('inventory_stock_sharing_eligibility_history_tenant', table.tenantId), + ], +); + +/** Migration hardening validates that Position and backend belong to this exact Customer Configuration scope. */ +export const inventoryStockSharingEligibilityScopeTriggerContract = { + constraintNames: { + backend: 'inventory_stock_sharing_eligibilities_backend_scope_ck', + position: 'inventory_stock_sharing_eligibilities_position_scope_ck', + }, + event: 'INSERT OR UPDATE', + functionName: 'inventory.enforce_stock_sharing_eligibility_scope', + positionRequiredLifecycle: 'CURRENT', + table: 'inventory.stock_sharing_eligibilities', + timing: 'BEFORE', + triggerName: 'inventory_stock_sharing_eligibilities_scope_trg', +} as const; + +export const inventoryStockSharingEligibilityIdentityImmutabilityContract = { + columns: ['eligibility_id', 'tenant_id', 'customer_configuration_id', 'owner_configuration_id', 'stock_position_id'], + comparison: 'IS DISTINCT FROM', + errorCondition: 'check_violation', + event: 'UPDATE OR DELETE', + functionName: 'inventory.reject_stock_sharing_eligibility_identity_mutation', + table: 'inventory.stock_sharing_eligibilities', + timing: 'BEFORE', + triggerName: 'inventory_stock_sharing_eligibilities_immutable_identity_trg', +} as const; + +export const inventoryStockSharingEligibilityHistoryImmutabilityContract = { + deleteTriggerName: 'inventory_stock_sharing_eligibility_history_no_delete_trg', + functionName: 'inventory.reject_stock_sharing_eligibility_history_mutation', + table: 'inventory.stock_sharing_eligibility_history', + updateTriggerName: 'inventory_stock_sharing_eligibility_history_no_update_trg', +} as const; + +export const INVENTORY_STOCK_SHARING_ELIGIBILITY_TABLES = [ + inventoryStockSharingEligibilityHistory, + inventoryStockSharingEligibilities, +] as const; diff --git a/app/verticals/inventory/src/routes/[lang]/_mf/fragment/widget/page.tsx b/app/verticals/inventory/src/routes/[lang]/_mf/fragment/widget/page.tsx new file mode 100644 index 000000000..83fdd15f3 --- /dev/null +++ b/app/verticals/inventory/src/routes/[lang]/_mf/fragment/widget/page.tsx @@ -0,0 +1,29 @@ +import { useDistributedSsrFragmentProps } from '@modern-js/federation-runtime/distributed-ssr'; +import type { ComponentProps } from 'react'; + +import Widget from '../../../../../components/inventory-widget'; + +const WidgetFragmentPage = () => { + const props = useDistributedSsrFragmentProps>({ + boundaryId: 'verticalInventory', + expose: './Widget', + }); + + return ( + <> +